From: Michael Wallner Date: Tue, 6 Oct 2020 16:48:04 +0000 (+0200) Subject: testing: pools X-Git-Tag: 1.1.0-beta1~236^2~18 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=6a0eee5f5b6163f06fa660dde37e8fe5e580483e;p=awesomized%2Flibmemcached testing: pools --- diff --git a/.github/workflows/cmake-build-ci.gen b/.github/workflows/cmake-build-ci.gen index bff77cd0..2648ecaf 100755 --- a/.github/workflows/cmake-build-ci.gen +++ b/.github/workflows/cmake-build-ci.gen @@ -214,8 +214,8 @@ env: jobs: # new memcached - ci-new: - name: ci-dbg (, memcached-1.6) + dbg-new: + name: dbg-new () runs-on: # env: INSTALL_MEMCACHED: @@ -231,8 +231,8 @@ jobs: # sanitizer build - ci-san: - name: ci-dbg (, sanitizers) + dbg-san: + name: dbg-san () runs-on: # env: ENABLE_SANITIZERS: "address;undefined" @@ -241,8 +241,8 @@ jobs: # coverage build - ci-cov: - name: ci-dbg (, coverage) + dbg-cov: + name: dbg-cov () runs-on: # env: CFLAGS: -O0 --coverage @@ -253,8 +253,8 @@ jobs: - uses: codecov/codecov-action@v1.0.13 # mac build - ci-mac: - name: ci-dbg (, , ) + dbg-mac: + name: dbg-mac (, , ) runs-on: # continue-on-error: true steps: @@ -262,7 +262,7 @@ jobs: # release builds - ci-rel: + release: strategy: fail-fast: false matrix: diff --git a/.github/workflows/cmake-build-ci.yml b/.github/workflows/cmake-build-ci.yml index 4cf46a6d..7e5939f8 100644 --- a/.github/workflows/cmake-build-ci.yml +++ b/.github/workflows/cmake-build-ci.yml @@ -28,8 +28,8 @@ env: jobs: # new memcached - ci-new: - name: ci-dbg (ubuntu-20.04, gnu, cur, memcached-1.6) + dbg-new: + name: dbg-new (ubuntu-20.04, gnu, cur) runs-on: ubuntu-20.04 # env: INSTALL_MEMCACHED: @@ -96,8 +96,8 @@ jobs: run: cat build/Testing/Temporary/LastTest.log || true # sanitizer build - ci-san: - name: ci-dbg (ubuntu-20.04, gnu, cur, sanitizers) + dbg-san: + name: dbg-san (ubuntu-20.04, gnu, cur) runs-on: ubuntu-20.04 # env: ENABLE_SANITIZERS: "address;undefined" @@ -157,8 +157,8 @@ jobs: run: cat build/Testing/Temporary/LastTest.log || true # coverage build - ci-cov: - name: ci-dbg (ubuntu-20.04, gnu, cur, coverage) + dbg-cov: + name: dbg-cov (ubuntu-20.04, gnu, cur) runs-on: ubuntu-20.04 # env: CFLAGS: -O0 --coverage @@ -220,8 +220,8 @@ jobs: - uses: codecov/codecov-action@v1.0.13 # mac build - ci-mac: - name: ci-dbg (macos-10.15, clang, apple) + dbg-mac: + name: dbg-mac (macos-10.15, clang, apple) runs-on: macos-10.15 # continue-on-error: true steps: @@ -275,7 +275,7 @@ jobs: run: cat build/Testing/Temporary/LastTest.log || true # release builds - ci-rel: + release: strategy: fail-fast: false matrix: diff --git a/CMake/_Include.cmake b/CMake/_Include.cmake index 3c00c79c..a6b5463c 100644 --- a/CMake/_Include.cmake +++ b/CMake/_Include.cmake @@ -78,7 +78,6 @@ check_header(io.h) check_header(limits.h) check_header(netdb.h) check_header(poll.h) -check_header(semaphore.h) check_header(stddef.h) check_header(stdlib.h) check_header(strings.h) diff --git a/codecov.yml b/codecov.yml index 38e8c508..df50744d 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,8 @@ ignore: - "/usr" + - "example/" + - "test/" coverage: status: @@ -16,5 +18,3 @@ coverage: default: url: "https://webhooks.gitter.im/e/a6210fd7fb7b5105b2b0" threshold: 1% - - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ebb39afe..7a6faee9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,8 @@ endif() include(CMake/Catch.cmake) +check_header(semaphore.h) + check_decl(pipe2 unistd.h) check_decl(SOCK_NONBLOCK sys/socket.h) check_decl(SOCK_CLOEXEC sys/socket.h) diff --git a/test/conf.h.in b/test/conf.h.in index 91843964..931aab96 100644 --- a/test/conf.h.in +++ b/test/conf.h.in @@ -1,5 +1,6 @@ #pragma once +#cmakedefine HAVE_SEMAPHORE_H 1 #cmakedefine HAVE_PIPE2 1 #cmakedefine HAVE_SOCK_NONBLOCK 1 #cmakedefine HAVE_SOCK_CLOEXEC 1 diff --git a/test/tests/memcached/regression/lp_000-962-815.cpp b/test/tests/memcached/regression/lp_000-962-815.cpp index 658c339e..5c168a12 100644 --- a/test/tests/memcached/regression/lp_000-962-815.cpp +++ b/test/tests/memcached/regression/lp_000-962-815.cpp @@ -33,7 +33,8 @@ struct worker_ctx { } stringstream &err() { - return errors[errors.size()]; + errors.resize(errors.size()+1); + return errors[errors.size()-1]; } }; @@ -42,25 +43,32 @@ static void *worker(void *arg) { while (is_running()) { memcached_return_t rc; - timespec block{5, 0}; + timespec block{0, 1000}; auto *mc = memcached_pool_fetch(ctx->pool, &block, &rc); + if (!mc && rc == MEMCACHED_TIMEOUT) { + continue; + } if (!mc || memcached_failed(rc)) { - ctx->err() << "failed to fetch connection from pool: " - << memcached_strerror(nullptr, rc); - this_thread::sleep_for(100ms); + cerr << "failed to fetch connection from pool: " + << memcached_strerror(nullptr, rc) + << endl; + this_thread::sleep_for(10ms); + continue; } auto rs = random_ascii_string(12); rc = memcached_set(mc, rs.c_str(), rs.length(), rs.c_str(), rs.length(), 0, 0); if (memcached_failed(rc)) { - ctx->err() << "failed to memcached_set() " - << memcached_last_error_message(mc); + cerr << "failed to memcached_set() " + << memcached_last_error_message(mc) + << endl; } rc = memcached_pool_release(ctx->pool, mc); if (memcached_failed(rc)) { - ctx->err() << "failed to release connection to pool: " - << memcached_strerror(nullptr, rc); + cerr << "failed to release connection to pool: " + << memcached_strerror(nullptr, rc) + << endl; } } diff --git a/test/tests/memcached/util.cpp b/test/tests/memcached/util.cpp index 3fb018a3..ae91ffa4 100644 --- a/test/tests/memcached/util.cpp +++ b/test/tests/memcached/util.cpp @@ -149,6 +149,21 @@ TEST_CASE("memcached_util") { REQUIRE_SUCCESS(rc); REQUIRE(h); REQUIRE(9999 == memcached_behavior_get(h, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK)); + REQUIRE_FALSE(9999 == memcached_behavior_get(h, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK)); + REQUIRE_SUCCESS(memcached_pool_release(pool, h)); + } + + REQUIRE_SUCCESS(memcached_pool_behavior_get(pool, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, &val)); + REQUIRE_FALSE(val == 9999); + REQUIRE_SUCCESS(memcached_pool_behavior_set(pool, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, 9999)); + REQUIRE_SUCCESS(memcached_pool_behavior_get(pool, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, &val)); + REQUIRE(val == 9999); + + for (auto &h : hold) { + h = memcached_pool_fetch(pool, nullptr, &rc); + REQUIRE_SUCCESS(rc); + REQUIRE(h); + REQUIRE(9999 == memcached_behavior_get(h, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK)); } } diff --git a/test/tests/memcached/util_pool_thread.cpp b/test/tests/memcached/util_pool_thread.cpp index 88330284..55e9a027 100644 --- a/test/tests/memcached/util_pool_thread.cpp +++ b/test/tests/memcached/util_pool_thread.cpp @@ -84,7 +84,7 @@ TEST_CASE("memcached_util_pool_thread") { if (memcached_success(rc)) { break; } -cerr << "rc == " << memcached_strerror(nullptr, rc); + if (memcached_failed(rc)) { REQUIRE_FALSE(pop_memc); REQUIRE(rc != MEMCACHED_TIMEOUT); // As long as relative_time is zero, MEMCACHED_TIMEOUT is invalid @@ -98,7 +98,7 @@ cerr << "rc == " << memcached_strerror(nullptr, rc); REQUIRE(MEMCACHED_SUCCESS == memcached_pool_release(pool, pop_memc)); REQUIRE(memcached_pool_destroy(pool) == *memc); -#endif __APPLE__ +#endif // __APPLE__ } #endif // HAVE_SEMAPHORE_H