@@ -157,6 +157,55 @@ TEST_P(IntegrationTest, PerWorkerStatsAndBalancing) {
157
157
check_listener_stats (0 , 1 );
158
158
}
159
159
160
+ // Make sure we have correctly specified per-worker performance stats.
161
+ TEST_P (IntegrationTest, AllWorkersAreHandlingLoad) {
162
+ concurrency_ = 2 ;
163
+ initialize ();
164
+
165
+ std::string worker0_stat_name, worker1_stat_name;
166
+ if (GetParam () == Network::Address::IpVersion::v4) {
167
+ worker0_stat_name = " listener.127.0.0.1_0.worker_0.downstream_cx_total" ;
168
+ worker1_stat_name = " listener.127.0.0.1_0.worker_1.downstream_cx_total" ;
169
+ } else {
170
+ worker0_stat_name = " listener.[__1]_0.worker_0.downstream_cx_total" ;
171
+ worker1_stat_name = " listener.[__1]_0.worker_1.downstream_cx_total" ;
172
+ }
173
+
174
+ test_server_->waitForCounterEq (worker0_stat_name, 0 );
175
+ test_server_->waitForCounterEq (worker1_stat_name, 0 );
176
+
177
+ // We set the counters for the two workers to see how many connections each handles.
178
+ uint64_t w0_ctr = 0 ;
179
+ uint64_t w1_ctr = 0 ;
180
+ constexpr int loops = 5 ;
181
+ for (int i = 0 ; i < loops; i++) {
182
+ constexpr int requests_per_loop = 4 ;
183
+ std::array<IntegrationCodecClientPtr, requests_per_loop> connections;
184
+ for (int j = 0 ; j < requests_per_loop; j++) {
185
+ connections[j] = makeHttpConnection (lookupPort (" http" ));
186
+ }
187
+
188
+ auto worker0_ctr = test_server_->counter (worker0_stat_name);
189
+ auto worker1_ctr = test_server_->counter (worker1_stat_name);
190
+ auto target = w0_ctr + w1_ctr + requests_per_loop;
191
+ ENVOY_LOG_MISC (info, " current values are {} {} with target {}" , worker0_ctr->value (),
192
+ worker1_ctr->value (), target);
193
+ while (test_server_->counter (worker0_stat_name)->value () +
194
+ test_server_->counter (worker1_stat_name)->value () <
195
+ target) {
196
+ timeSystem ().advanceTimeWait (std::chrono::milliseconds (10 ));
197
+ }
198
+ w0_ctr = test_server_->counter (worker0_stat_name)->value ();
199
+ w1_ctr = test_server_->counter (worker1_stat_name)->value ();
200
+ for (int j = 0 ; j < requests_per_loop; j++) {
201
+ connections[j]->close ();
202
+ }
203
+ }
204
+
205
+ EXPECT_TRUE (w0_ctr > 1 );
206
+ EXPECT_TRUE (w1_ctr > 1 );
207
+ }
208
+
160
209
TEST_P (IntegrationTest, RouterDirectResponseWithBody) {
161
210
const std::string body = " Response body" ;
162
211
const std::string file_path = TestEnvironment::writeStringToFileForTest (" test_envoy" , body);
0 commit comments