testing: pools
authorMichael Wallner <mike@php.net>
Tue, 6 Oct 2020 16:48:04 +0000 (18:48 +0200)
committerMichael Wallner <mike@php.net>
Tue, 6 Oct 2020 16:48:04 +0000 (18:48 +0200)
.github/workflows/cmake-build-ci.gen
.github/workflows/cmake-build-ci.yml
CMake/_Include.cmake
codecov.yml
test/CMakeLists.txt
test/conf.h.in
test/tests/memcached/regression/lp_000-962-815.cpp
test/tests/memcached/util.cpp
test/tests/memcached/util_pool_thread.cpp

index bff77cd03da6e49c4067cfa7c90cd7aef101065e..2648ecafaa623ef2d482588afcc820dcc42f3b0a 100755 (executable)
@@ -214,8 +214,8 @@ env:
 jobs:
 
   # new memcached
-  ci-new:
-    name: ci-dbg (<?=defaults()?>, memcached-1.6)
+  dbg-new:
+    name: dbg-new (<?=defaults()?>)
     runs-on: <?=DEF[DEF["os"]]?> #
     env:
       INSTALL_MEMCACHED:
@@ -231,8 +231,8 @@ jobs:
 <?php steps(); ?>
 
   # sanitizer build
-  ci-san:
-    name: ci-dbg (<?=defaults()?>, sanitizers)
+  dbg-san:
+    name: dbg-san (<?=defaults()?>)
     runs-on: <?=DEF[DEF["os"]]?> #
     env:
       ENABLE_SANITIZERS: "address;undefined"
@@ -241,8 +241,8 @@ jobs:
 <?php steps(); ?>
 
   # coverage build
-  ci-cov:
-    name: ci-dbg (<?=defaults()?>, coverage)
+  dbg-cov:
+    name: dbg-cov (<?=defaults()?>)
     runs-on: <?=DEF[DEF["os"]]?> #
     env:
       CFLAGS: -O0 --coverage
@@ -253,8 +253,8 @@ jobs:
       - uses: codecov/codecov-action@v1.0.13
 
   # mac build
-  ci-mac:
-    name: ci-dbg (<?=DEF["macOS"]?>, <?=DEF[DEF["macOS"]]?>, <?=DEF[DEF[DEF["macOS"]]]["ver"]?>)
+  dbg-mac:
+    name: dbg-mac (<?=DEF["macOS"]?>, <?=DEF[DEF["macOS"]]?>, <?=DEF[DEF[DEF["macOS"]]]["ver"]?>)
     runs-on: <?=DEF["macOS"]?> #
     continue-on-error: true
     steps:
@@ -262,7 +262,7 @@ jobs:
 <?php steps(false); ?>
 
   # release builds
-  ci-rel:
+  release:
     strategy:
       fail-fast: false
       matrix:
index 4cf46a6dbf0e24298630e29f4c6861641bdd0195..7e5939f889a27386e1bbca51fb27c3a8c19b5dcd 100644 (file)
@@ -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:
index 3c00c79c7306aea7e351ae4e3e9189ca01e2c5eb..a6b5463c1a1b201be45a823df8a0f5d1884e0cef 100644 (file)
@@ -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)
index 38e8c50836e4f031a1df44144d87935afe21e862..df50744daa2d6f29e638388b26ca56b63234b6d2 100644 (file)
@@ -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%
-
-
index ebb39afe84a755f11b8da79f8ca69ac91b1f7f2d..7a6faee9682a749b1aa9eb1809d4d2c7fbe1b3e7 100644 (file)
@@ -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)
index 91843964527538ecf40ceade4b0b812a0f5a010a..931aab96aacb361ee50f500c55a9f9e10156436e 100644 (file)
@@ -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
index 658c339ee19810819527eda0da476b7c48c2e179..5c168a12985d0b8fe6e0415fb43734c7d5b18af6 100644 (file)
@@ -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;
     }
   }
 
index 3fb018a3a635708e624daed8fd98b0c55ecdc612..ae91ffa42872b0af0cf91f9288a5885123056f40 100644 (file)
@@ -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));
         }
       }
 
index 88330284f2919716e2af7b7641c741430fca68b5..55e9a02734b60a9ecedc97082cb5ea22c4f17e78 100644 (file)
@@ -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