feat add test for future
Some checks failed
linux-arm-gcc / linux-gcc-armhf (Release) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-x86-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x86-gcc / linux-gcc (Release) (push) Waiting to run
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 1m22s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 1m47s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 1m38s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 2m3s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Has been cancelled
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (pull_request) Failing after 1m23s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (pull_request) Failing after 1m48s
linux-arm-gcc / linux-gcc-arm (Debug) (pull_request) Failing after 1m40s
linux-arm-gcc / linux-gcc-arm (Release) (pull_request) Failing after 1m36s
linux-arm-gcc / linux-gcc-armhf (Debug) (pull_request) Failing after 2m9s
linux-arm-gcc / linux-gcc-armhf (Release) (pull_request) Successful in 1m53s
linux-mips-gcc / linux-gcc-mipsel (Debug) (pull_request) Successful in 1m30s
linux-mips-gcc / linux-gcc-mipsel (Release) (pull_request) Failing after 1m41s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (pull_request) Failing after 1m25s
linux-mips64-gcc / linux-gcc-mips64el (Release) (pull_request) Successful in 1m48s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (pull_request) Successful in 3m5s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (pull_request) Successful in 1m47s
linux-x64-gcc / linux-gcc (Debug) (pull_request) Failing after 1m0s
linux-x64-gcc / linux-gcc (Release) (pull_request) Failing after 1m27s
linux-x86-gcc / linux-gcc (Debug) (pull_request) Failing after 1m12s
linux-x86-gcc / linux-gcc (Release) (pull_request) Failing after 1m38s
Some checks failed
linux-arm-gcc / linux-gcc-armhf (Release) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-x86-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x86-gcc / linux-gcc (Release) (push) Waiting to run
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 1m22s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 1m47s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 1m38s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 2m3s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Has been cancelled
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (pull_request) Failing after 1m23s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (pull_request) Failing after 1m48s
linux-arm-gcc / linux-gcc-arm (Debug) (pull_request) Failing after 1m40s
linux-arm-gcc / linux-gcc-arm (Release) (pull_request) Failing after 1m36s
linux-arm-gcc / linux-gcc-armhf (Debug) (pull_request) Failing after 2m9s
linux-arm-gcc / linux-gcc-armhf (Release) (pull_request) Successful in 1m53s
linux-mips-gcc / linux-gcc-mipsel (Debug) (pull_request) Successful in 1m30s
linux-mips-gcc / linux-gcc-mipsel (Release) (pull_request) Failing after 1m41s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (pull_request) Failing after 1m25s
linux-mips64-gcc / linux-gcc-mips64el (Release) (pull_request) Successful in 1m48s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (pull_request) Successful in 3m5s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (pull_request) Successful in 1m47s
linux-x64-gcc / linux-gcc (Debug) (pull_request) Failing after 1m0s
linux-x64-gcc / linux-gcc (Release) (pull_request) Failing after 1m27s
linux-x86-gcc / linux-gcc (Debug) (pull_request) Failing after 1m12s
linux-x86-gcc / linux-gcc (Release) (pull_request) Failing after 1m38s
This commit is contained in:
parent
2780b81406
commit
8238c310f6
@ -268,17 +268,21 @@ if(TILE_BUILD_TESTS)
|
||||
|
||||
add_executable(tile_test_all "tile/testing/main.cc")
|
||||
target_link_libraries(tile_test_all PRIVATE gtest gmock tile::tile)
|
||||
|
||||
macro(tile_add_test test_name test_file)
|
||||
|
||||
macro(tile_add_custom_test test_name test_file)
|
||||
add_executable(${test_name} ${test_file} "tile/testing/main.cc")
|
||||
target_link_libraries(
|
||||
${test_name} PUBLIC gtest gmock ${WHOLE_ARCHIVE_PREFIX} tile::tile
|
||||
${WHOLE_ARCHIVE_SUFFIX})
|
||||
add_test(NAME ${test_name} COMMAND ${test_name})
|
||||
|
||||
target_sources(${PROJECT_NAME}_test_all PRIVATE ${test_file})
|
||||
endmacro()
|
||||
|
||||
macro(tile_add_test test_name test_file)
|
||||
tile_add_custom_test(${test_name} ${test_file})
|
||||
add_test(NAME ${test_name} COMMAND ${test_name})
|
||||
endmacro()
|
||||
|
||||
tile_add_test(fiber_detail_scheduler_test "tile/fiber/detail/scheduler_test.cc")
|
||||
tile_add_test(base_internal_meta_test "tile/base/internal/meta_test.cc")
|
||||
# tile_add_test(net_internal_http_engine_test
|
||||
@ -348,7 +352,7 @@ tile_add_test(fiber_detail_scheduler_test "tile/fiber/detail/scheduler_test.cc")
|
||||
tile_add_test(base_internal_logging_test "tile/base/internal/logging_test.cc")
|
||||
tile_add_test(base_chrono_test "tile/base/chrono_test.cc")
|
||||
tile_add_test(init_override_flag_test "tile/init/override_flag_test.cc")
|
||||
# tile_add_test("custom_http_client_test" "tests/http_client_test.cc")
|
||||
tile_add_custom_test("custom_http_client_test" "tests/http_client_test.cc")
|
||||
# tile_add_test(base_internal_time_keeper_test
|
||||
# "tile/base/internal/time_keeper_test.cc")
|
||||
endif(TILE_BUILD_TESTS)
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "tile/base/thread/latch.h"
|
||||
|
||||
const std::string url = "http://127.0.0.1:8000/";
|
||||
|
||||
TEST(HttpClient, Request) {
|
||||
@ -45,3 +47,39 @@ TEST(HttpClient, Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HttpClient, RequestNoWait) {
|
||||
tile::HttpClient client;
|
||||
tile::HttpClient::RequestOptions options;
|
||||
options.timeout = std::chrono::seconds(20);
|
||||
int cnt = 0;
|
||||
|
||||
for (int i = 0; i != 1000; ++i) {
|
||||
for (auto code : tile::AllHttpStatus) {
|
||||
if (static_cast<int>(code) < 200) {
|
||||
continue;
|
||||
}
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
tile::Latch latch(cnt);
|
||||
std::atomic<int> count{0};
|
||||
|
||||
for (int i = 0; i != 1000; ++i) {
|
||||
for (auto code : tile::AllHttpStatus) {
|
||||
if (static_cast<int>(code) < 200) {
|
||||
continue;
|
||||
}
|
||||
|
||||
client.AsyncGet(url + std::to_string(static_cast<int>(code)), options)
|
||||
.Then([&](std::expected<tile::HttpResponse,
|
||||
tile::HttpClient::ErrorCode> &&) {
|
||||
int cnt = count.fetch_add(1) + 1;
|
||||
TILE_LOG_INFO_EVERY_SECOND("complete {}", cnt);
|
||||
latch.CountDown();
|
||||
});
|
||||
}
|
||||
}
|
||||
latch.Wait();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user