@@ -45,14 +45,33 @@ struct TTetsEnv {
45
45
TIntrusivePtr<::NMonitoring::TDynamicCounters> Counters;
46
46
};
47
47
48
+ std::vector<ui64> GetOutputValue (const TStringBuf& html, const TStringBuf& param) {
49
+ TStringBuilder str;
50
+ str << " <tr><td>" << param << " </td><td>" ;
51
+ std::vector<ui64> result;
52
+ TStringBuf::size_type pos = 0 ;
53
+ do {
54
+ pos = html.find (str, pos);
55
+ if (TStringBuf::npos != pos) {
56
+ const auto from = pos + str.length ();
57
+ const auto to = html.find (" </td></tr>" , from);
58
+ if (TStringBuf::npos != to) {
59
+ result.emplace_back (FromString<ui64>(html.substr (from, to - from)));
60
+ pos = to + 10U ;
61
+ }
62
+ }
63
+ } while (TStringBuf::npos != pos);
64
+ UNIT_ASSERT (!result.empty ());
65
+ return result;
48
66
}
49
67
50
- Y_UNIT_TEST_SUITE (GroupWriteTest) {
68
+ }
51
69
70
+ Y_UNIT_TEST_SUITE (GroupWriteTest) {
52
71
Y_UNIT_TEST (Simple) {
53
72
TTetsEnv env;
54
73
55
- const TString conf (R"( DurationSeconds: 3
74
+ const TString conf (R"( DurationSeconds: 30
56
75
Tablets: {
57
76
Tablets: { TabletId: 1 Channel: 0 GroupId: )" + ToString (env.GroupInfo ->GroupID ) + R"( Generation: 1 }
58
77
WriteSizes: { Weight: 1.0 Min: 1000000 Max: 4000000 }
@@ -64,6 +83,94 @@ Y_UNIT_TEST_SUITE(GroupWriteTest) {
64
83
);
65
84
66
85
const auto html = env.RunSingleLoadTest (conf);
67
- UNIT_ASSERT (html.Contains (" <tr><td>BadPutResults</td><td>0</td></tr>" ));
86
+ UNIT_ASSERT (GetOutputValue (html, " OkPutResults" ).front () >= 300U );
87
+ UNIT_ASSERT (GetOutputValue (html, " BadPutResults" ).front () == 0U );
88
+ UNIT_ASSERT (GetOutputValue (html, " TotalBytesWritten" ).front () >= 300000000U );
89
+ UNIT_ASSERT (GetOutputValue (html, " TotalBytesRead" ).front () == 0U );
90
+ }
91
+
92
+ Y_UNIT_TEST (ByTableName) {
93
+ TTetsEnv env;
94
+
95
+ const TString conf (R"( DurationSeconds: 30
96
+ Tablets: {
97
+ Tablets: { TabletName: "NewTable" Channel: 0 GroupId: )" + ToString (env.GroupInfo ->GroupID ) + R"( Generation: 1 }
98
+ WriteSizes: { Weight: 1.0 Min: 2000000 Max: 2000000 }
99
+ WriteIntervals: { Weight: 1.0 Uniform: { MinUs: 100000 MaxUs: 100000 } }
100
+ MaxInFlightWriteRequests: 10
101
+ FlushIntervals: { Weight: 1.0 Uniform: { MinUs: 1000000 MaxUs: 1000000 } }
102
+ PutHandleClass: TabletLog
103
+ })"
104
+ );
105
+
106
+ const auto html = env.RunSingleLoadTest (conf);
107
+ UNIT_ASSERT (GetOutputValue (html, " OkPutResults" ).front () >= 300U );
108
+ UNIT_ASSERT (GetOutputValue (html, " BadPutResults" ).front () == 0U );
109
+ UNIT_ASSERT (GetOutputValue (html, " TotalBytesWritten" ).front () >= 600000000U );
110
+ UNIT_ASSERT (GetOutputValue (html, " TotalBytesRead" ).front () == 0U );
111
+ }
112
+
113
+ Y_UNIT_TEST (WithRead) {
114
+ TTetsEnv env;
115
+
116
+ const TString conf (R"( DurationSeconds: 10
117
+ Tablets: {
118
+ Tablets: { TabletId: 3 Channel: 0 GroupId: )" + ToString (env.GroupInfo ->GroupID ) + R"( Generation: 1 }
119
+ WriteSizes: { Weight: 1.0 Min: 1000000 Max: 3000000 }
120
+ WriteIntervals: { Weight: 1.0 Uniform: { MinUs: 100000 MaxUs: 100000 } }
121
+ MaxInFlightWriteRequests: 1
122
+ FlushIntervals: { Weight: 1.0 Uniform: { MinUs: 1000000 MaxUs: 1000000 } }
123
+ ReadSizes: { Weight: 1.0 Min: 1000000 Max: 2000000 }
124
+ ReadIntervals: { Weight: 1.0 Uniform: { MinUs: 100000 MaxUs: 100000 } }
125
+ MaxInFlightReadRequests: 1
126
+ PutHandleClass: UserData
127
+ })"
128
+ );
129
+
130
+ const auto html = env.RunSingleLoadTest (conf);
131
+ UNIT_ASSERT (GetOutputValue (html, " OkPutResults" ).front () >= 100U );
132
+ UNIT_ASSERT (GetOutputValue (html, " BadPutResults" ).front () == 0U );
133
+ const auto totalWritten = GetOutputValue (html, " TotalBytesWritten" ).front ();
134
+ const auto totalRead = GetOutputValue (html, " TotalBytesRead" ).front ();
135
+ UNIT_ASSERT (totalWritten >= 100000000U );
136
+ UNIT_ASSERT (totalWritten <= 300000000U );
137
+ UNIT_ASSERT (totalRead >= 100000000U );
138
+ UNIT_ASSERT (totalRead <= 200000000U );
139
+ }
140
+
141
+ Y_UNIT_TEST (TwoTables) {
142
+ TTetsEnv env;
143
+
144
+ const TString conf (R"( DurationSeconds: 20
145
+ Tablets: {
146
+ Tablets: { TabletName: "TableOne" Channel: 0 GroupId: )" + ToString (env.GroupInfo ->GroupID ) + R"( Generation: 1 }
147
+ WriteSizes: { Weight: 1.0 Min: 2000000 Max: 3000000 }
148
+ WriteIntervals: { Weight: 1.0 Uniform: { MinUs: 100000 MaxUs: 100000 } }
149
+ MaxInFlightWriteRequests: 10
150
+ FlushIntervals: { Weight: 1.0 Uniform: { MinUs: 1000000 MaxUs: 1000000 } }
151
+ PutHandleClass: TabletLog
152
+ }
153
+ Tablets: {
154
+ Tablets: { TabletName: "TableTwo" Channel: 0 GroupId: )" + ToString (env.GroupInfo ->GroupID ) + R"( Generation: 1 }
155
+ WriteSizes: { Weight: 1.0 Min: 100000 Max: 200000 }
156
+ WriteIntervals: { Weight: 1.0 Uniform: { MinUs: 100000 MaxUs: 100000 } }
157
+ MaxInFlightWriteRequests: 10
158
+ FlushIntervals: { Weight: 1.0 Uniform: { MinUs: 1000000 MaxUs: 1000000 } }
159
+ PutHandleClass: TabletLog
160
+ }
161
+ )" );
162
+
163
+ const auto html = env.RunSingleLoadTest (conf);
164
+ const auto okResults = GetOutputValue (html, " OkPutResults" );
165
+ const auto badResults = GetOutputValue (html, " BadPutResults" );
166
+ const auto totalWritten = GetOutputValue (html, " TotalBytesWritten" );
167
+ const auto totalRead = GetOutputValue (html, " TotalBytesRead" );
168
+ UNIT_ASSERT (okResults.front () >= 200U );
169
+ UNIT_ASSERT (okResults.back () >= 200U );
170
+ UNIT_ASSERT (badResults.front () + badResults.back () == 0U );
171
+ UNIT_ASSERT (totalWritten.front () >= 400000000U );
172
+ UNIT_ASSERT (totalWritten.front () <= 600000000U );
173
+ UNIT_ASSERT (totalWritten.back () >= 20000000U );
174
+ UNIT_ASSERT (totalWritten.back () <= 40000000U );
68
175
}
69
176
}
0 commit comments