Skip to content

Commit 965a975

Browse files
committed
Fix test-throttle CI
1 parent 83a6ffb commit 965a975

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

.github/workflows/ci.linux.arm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
-D PHOTON_ENABLE_URING=ON \
3535
-D PHOTON_ENABLE_LIBCURL=ON \
3636
-D PHOTON_ENABLE_EXTFS=ON
37-
cmake --build build -j $(nproc) -- VERBOSE=1
37+
cmake --build build -j $(nproc)
3838
3939
- name: Test
4040
run: |
4141
cd build
4242
nohup redis-server &
43-
ctest -E test-lockfree --timeout 3600 -V
43+
ctest --timeout 3600 -V
4444
pkill redis-server
4545
4646
debug-build-from-source:

.github/workflows/ci.linux.x86_64.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ jobs:
2929
-D PHOTON_ENABLE_URING=ON \
3030
-D PHOTON_ENABLE_LIBCURL=ON \
3131
-D PHOTON_ENABLE_EXTFS=ON
32-
cmake --build build -j $(nproc) -- VERBOSE=1
32+
cmake --build build -j $(nproc)
3333
- name: Test epoll
3434
run: |
3535
nohup redis-server &
36-
cd build && ctest -E test-lockfree --timeout 3600 -V
36+
cd build && ctest --timeout 3600 -V
3737
pkill redis-server
3838
- name: Test io_uring
3939
run: |
4040
nohup redis-server &
4141
export PHOTON_CI_EV_ENGINE=io_uring
42-
cd build && ctest -E test-lockfree --timeout 3600 -V
42+
cd build && ctest --timeout 3600 -V
4343
pkill redis-server
4444
- name: Test epoll_ng
4545
run: |
4646
nohup redis-server &
4747
export PHOTON_CI_EV_ENGINE=epoll_ng
48-
cd build && ctest -E test-lockfree --timeout 3600 -V
48+
cd build && ctest --timeout 3600 -V
4949
pkill redis-server
5050
5151
gcc921:
@@ -71,23 +71,23 @@ jobs:
7171
-D PHOTON_ENABLE_URING=ON \
7272
-D PHOTON_ENABLE_LIBCURL=ON \
7373
-D PHOTON_ENABLE_EXTFS=ON
74-
cmake --build build -j $(nproc) -- VERBOSE=1
74+
cmake --build build -j $(nproc)
7575
- name: Test epoll
7676
run: |
7777
nohup redis-server &
78-
cd build && ctest -E test-lockfree --timeout 3600 -V
78+
cd build && ctest --timeout 3600 -V
7979
pkill redis-server
8080
- name: Test io_uring
8181
run: |
8282
nohup redis-server &
8383
export PHOTON_CI_EV_ENGINE=io_uring
84-
cd build && ctest -E test-lockfree --timeout 3600 -V
84+
cd build && ctest --timeout 3600 -V
8585
pkill redis-server
8686
- name: Test epoll_ng
8787
run: |
8888
nohup redis-server &
8989
export PHOTON_CI_EV_ENGINE=epoll_ng
90-
cd build && ctest -E test-lockfree --timeout 3600 -V
90+
cd build && ctest --timeout 3600 -V
9191
pkill redis-server
9292
9393
gcc1031:
@@ -113,23 +113,23 @@ jobs:
113113
-D PHOTON_ENABLE_URING=ON \
114114
-D PHOTON_ENABLE_LIBCURL=ON \
115115
-D PHOTON_ENABLE_EXTFS=ON
116-
cmake --build build -j $(nproc) -- VERBOSE=1
116+
cmake --build build -j $(nproc)
117117
- name: Test epoll
118118
run: |
119119
nohup redis-server &
120-
cd build && ctest -E test-lockfree --timeout 3600 -V
120+
cd build && ctest --timeout 3600 -V
121121
pkill redis-server
122122
- name: Test io_uring
123123
run: |
124124
nohup redis-server &
125125
export PHOTON_CI_EV_ENGINE=io_uring
126-
cd build && ctest -E test-lockfree --timeout 3600 -V
126+
cd build && ctest --timeout 3600 -V
127127
pkill redis-server
128128
- name: Test epoll_ng
129129
run: |
130130
nohup redis-server &
131131
export PHOTON_CI_EV_ENGINE=epoll_ng
132-
cd build && ctest -E test-lockfree --timeout 3600 -V
132+
cd build && ctest --timeout 3600 -V
133133
pkill redis-server
134134
135135
gcc1121:
@@ -155,23 +155,23 @@ jobs:
155155
-D PHOTON_ENABLE_URING=ON \
156156
-D PHOTON_ENABLE_LIBCURL=ON \
157157
-D PHOTON_ENABLE_EXTFS=ON
158-
cmake --build build -j $(nproc) -- VERBOSE=1
158+
cmake --build build -j $(nproc)
159159
- name: Test epoll
160160
run: |
161161
nohup redis-server &
162-
cd build && ctest -E test-lockfree --timeout 3600 -V
162+
cd build && ctest --timeout 3600 -V
163163
pkill redis-server
164164
- name: Test io_uring
165165
run: |
166166
nohup redis-server &
167167
export PHOTON_CI_EV_ENGINE=io_uring
168-
cd build && ctest -E test-lockfree --timeout 3600 -V
168+
cd build && ctest --timeout 3600 -V
169169
pkill redis-server
170170
- name: Test epoll_ng
171171
run: |
172172
nohup redis-server &
173173
export PHOTON_CI_EV_ENGINE=epoll_ng
174-
cd build && ctest -E test-lockfree --timeout 3600 -V
174+
cd build && ctest --timeout 3600 -V
175175
pkill redis-server
176176
177177
gcc1211:
@@ -197,23 +197,23 @@ jobs:
197197
-D PHOTON_ENABLE_URING=ON \
198198
-D PHOTON_ENABLE_LIBCURL=ON \
199199
-D PHOTON_ENABLE_EXTFS=ON
200-
cmake --build build -j $(nproc) -- VERBOSE=1
200+
cmake --build build -j $(nproc)
201201
- name: Test epoll
202202
run: |
203203
nohup redis-server &
204-
cd build && ctest -E test-lockfree --timeout 3600 -V
204+
cd build && ctest --timeout 3600 -V
205205
pkill redis-server
206206
- name: Test io_uring
207207
run: |
208208
nohup redis-server &
209209
export PHOTON_CI_EV_ENGINE=io_uring
210-
cd build && ctest -E test-lockfree --timeout 3600 -V
210+
cd build && ctest --timeout 3600 -V
211211
pkill redis-server
212212
- name: Test epoll_ng
213213
run: |
214214
nohup redis-server &
215215
export PHOTON_CI_EV_ENGINE=epoll_ng
216-
cd build && ctest -E test-lockfree --timeout 3600 -V
216+
cd build && ctest --timeout 3600 -V
217217
pkill redis-server
218218
219219
fstack:

common/test/test_throttle.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class FindAppropriateSliceNumTest : public testing::TestWithParam<FindAppropriat
183183
TEST_P(FindAppropriateSliceNumTest, run) {
184184
const auto& p = GetParam();
185185

186-
const uint64_t test_time_sec = 10;
186+
const uint64_t test_time_sec = 5;
187187
const uint64_t bw = 100'000'000UL;
188188
const uint64_t time_window = 1'000'000UL;
189189
const uint64_t slice_num = p.slice_num;
@@ -205,10 +205,10 @@ TEST_P(FindAppropriateSliceNumTest, run) {
205205
t.consume(bs_per_io);
206206
bytes += bs_per_io;
207207
}
208-
auto goal = bw * 10;
208+
auto goal = bw * test_time_sec;
209209
auto diff = int64_t(bytes) - int64_t(goal);
210210
auto loss = double(std::abs(diff)) / double(goal);
211-
LOG_INFO("Consume ` bytes in 10 seconds, loss ratio `", bytes, loss);
211+
LOG_INFO("Consume ` bytes in ` seconds, loss ratio `", bytes, test_time_sec, loss);
212212
GTEST_ASSERT_LE(loss, p.performance_loss_max_ratio);
213213
}
214214

@@ -320,24 +320,24 @@ INSTANTIATE_TEST_P(Throttle, ThrottlePriorityTest, testing::Values(
320320
PriorityTestSuite{
321321
// 7. Real socket. Low priority gets the rest BW that high priority doesn't need
322322
PriorityTestSuite::RealSocket,
323-
10'000'000,
324-
{5'000'000, 10'000, photon::throttle::Priority::High},
325-
{100'000'000, 4'000'000, photon::throttle::Priority::Low},
323+
100'000'000,
324+
{50'000'000, 10'000, photon::throttle::Priority::High},
325+
{1'000'000'000, 4'000'000, photon::throttle::Priority::Low},
326326
0.4, 0.6,
327327
0.4, 0.6,
328328
}
329329
));
330330

331-
static void run_real_socket(const std::atomic<bool>& running, const PriorityTestSuite& p,
331+
static void run_real_socket(const std::shared_ptr<std::atomic<bool>>& running, const PriorityTestSuite& p,
332332
uint64_t& bw1, uint64_t& bw2) {
333333
photon::throttle t(p.limit_bw);
334334
uint64_t buf_size = std::max(p.io1.bs, p.io2.bs);
335335
auto server = photon::net::new_tcp_socket_server();
336336
DEFER(delete server);
337337

338-
auto handler = [&](photon::net::ISocketStream* sock) -> int {
338+
auto handler = [&, _running=running](photon::net::ISocketStream* sock) -> int {
339339
char buf[buf_size];
340-
while (running) {
340+
while (_running->load()) {
341341
ssize_t ret = sock->recv(buf, buf_size);
342342
if (ret <= 0) break;
343343
photon::thread_yield();
@@ -355,12 +355,12 @@ static void run_real_socket(const std::atomic<bool>& running, const PriorityTest
355355
auto cli = photon::net::new_tcp_socket_client();
356356
DEFER(delete cli);
357357

358-
photon::thread_create11([&] {
358+
photon::thread_create11([&, _running=running] {
359359
photon::throttle src(p.io1.bw);
360360
auto conn = cli->connect(server_ep);
361361
DEFER(delete conn);
362362
char buf[buf_size];
363-
while (running) {
363+
while (_running->load()) {
364364
src.consume(p.io1.bs);
365365
ssize_t ret = conn->send(buf, p.io1.bs);
366366
if (ret <= 0) break;
@@ -369,12 +369,12 @@ static void run_real_socket(const std::atomic<bool>& running, const PriorityTest
369369
}
370370
sem.signal(1);
371371
});
372-
photon::thread_create11([&] {
372+
photon::thread_create11([&, _running=running] {
373373
photon::throttle src(p.io2.bw);
374374
auto conn = cli->connect(server_ep);
375375
DEFER(delete conn);
376376
char buf[buf_size];
377-
while (running) {
377+
while (_running->load()) {
378378
src.consume(p.io2.bs);
379379
ssize_t ret = conn->send(buf, p.io2.bs);
380380
if (ret <= 0) break;
@@ -386,22 +386,22 @@ static void run_real_socket(const std::atomic<bool>& running, const PriorityTest
386386
sem.wait(2);
387387
}
388388

389-
static void run_simulate(const std::atomic<bool>& running, const PriorityTestSuite& p,
389+
static void run_simulate(const std::shared_ptr<std::atomic<bool>>& running, const PriorityTestSuite& p,
390390
uint64_t& bw1, uint64_t& bw2) {
391391
photon::throttle t(p.limit_bw);
392392
photon::semaphore sem;
393-
photon::thread_create11([&] {
393+
photon::thread_create11([&, _running=running] {
394394
uint64_t sleep_interval = 1'000'000UL / (p.io1.bw / p.io1.bs);
395-
while (running) {
395+
while (_running->load()) {
396396
photon::thread_usleep(sleep_interval);
397397
t.consume(p.io1.bs, p.io1.prio);
398398
bw1 += p.io1.bs;
399399
}
400400
sem.signal(1);
401401
});
402-
photon::thread_create11([&] {
402+
photon::thread_create11([&, _running=running] {
403403
uint64_t sleep_interval = 1'000'000UL / (p.io2.bw / p.io2.bs);
404-
while (running) {
404+
while (_running->load()) {
405405
photon::thread_usleep(sleep_interval);
406406
t.consume(p.io2.bs, p.io2.prio);
407407
bw2 += p.io2.bs;
@@ -413,13 +413,13 @@ static void run_simulate(const std::atomic<bool>& running, const PriorityTestSui
413413

414414
TEST_P(ThrottlePriorityTest, run) {
415415
const auto& p = GetParam();
416-
const uint64_t test_time_sec = 10;
416+
const uint64_t test_time_sec = 5;
417417
uint64_t bw1 = 0, bw2 = 0;
418418

419-
std::atomic<bool> running{true};
419+
auto running = std::make_shared<std::atomic<bool>>(true);
420420
std::thread([&] {
421421
::sleep(test_time_sec);
422-
running = false;
422+
running->store(false);
423423
}).detach();
424424

425425
if (p.type == PriorityTestSuite::Simulate)

0 commit comments

Comments
 (0)