-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathtables_stress_test.cpp
More file actions
60 lines (49 loc) · 1.65 KB
/
tables_stress_test.cpp
File metadata and controls
60 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @brief Validates the Azure Core transport adapters with fault responses from server.
*
* @note This test requires the Http-fault-injector
* (https://github.com/Azure/azure-sdk-tools/tree/main/tools/http-fault-injector) running. Follow
* the instructions to install and run the server before running this test.
*
*/
#define REQUESTS 250
#define WARMUP 100
#define ROUNDS 1000
#include "azure/data/tables.hpp"
#include <iostream>
using namespace Azure::Data::Tables;
std::string Transactions(int num)
{
TableClient client("http://localhost:7777", "table");
auto transaction = client.CreateTransaction("pk1");
for (int i = 0; i < num; i++)
{
Models::TableEntity entity;
entity.PartitionKey = "pk1";
entity.RowKey = "rk1";
entity.Properties.emplace("prop1", "value1");
entity.Properties.emplace("prop2", "value2");
transaction.CreateEntity(entity);
transaction.DeleteEntity(entity);
transaction.UpdateEntity(entity);
transaction.MergeEntity(entity);
}
auto result = transaction.PreparePayload();
return result;
}
int main()
{
std::cout << "--------------\tSTARTING TEST\t--------------" << std::endl;
std::cout << "--------------\tPRE WARMUP\t--------------" << std::endl;
Transactions(WARMUP);
std::cout << "--------------\tPOST WARMUP\t--------------" << std::endl;
for (int i = 0; i < ROUNDS; i++)
{
std::cout << "--------------\tTEST ITERATION:" << i << "\t--------------" << std::endl;
Transactions(REQUESTS);
std::cout << "--------------\tDONE ITERATION:" << i << "\t--------------" << std::endl;
}
return 0;
}