diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 98f12aabb4ddf22f9375c97669e025adaed6b627..29e439b0a97505591a74e2407ba17bcc584f45e4 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -15,7 +15,8 @@ RUN rm -rf .git COPY .docker/caosdb-client.json /caosdb-client.json -# build and run tests +# Build and run tests. +# If no other command is given to the Docker image CMD mkdir build && \ cd build && \ conan install .. -s "compiler.libcxx=libstdc++11" && \ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8027befbc7deb93168a888f7c3354685eb661f81..93e5484652c11d1694a21f0aee6703e56d9d879f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,16 +78,12 @@ build-testenv: &build-testenv stage: setup timeout: 2h needs: [] - only: - - pipelines - - schedules - - web script: - *env - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY #build testenv image - - docker pull $CPPLIB_REGISTRY_IMAGE || { CPPLIB_REGISTRY_IMAGE="$CI_REGISTRY/caosdb/src/caosdb-cpplib/testenv:dev" ; docker pull $CPPLIB_REGISTRY_IMAGE ; } + - docker pull $CPPLIB_REGISTRY_IMAGE || { CPPLIB_REGISTRY_IMAGE="$CI_REGISTRY/caosdb/src/caosdb-cpplib/testenv:dev" ; echo "Using cpplib@dev instead."; docker pull $CPPLIB_REGISTRY_IMAGE ; } - docker build --build-arg CPPLIB_REGISTRY_IMAGE=$CPPLIB_REGISTRY_IMAGE --file .docker/Dockerfile diff --git a/CHANGELOG.md b/CHANGELOG.md index 449e4256f907780bfbd0ce3d6a23853f20de0ae6..fcdf01692fe8dbcd0dfa40ae7ae9eb7f596a5cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,4 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* Fixed failing async test. + ### Security diff --git a/test/test_async.cpp b/test/test_async.cpp index c8049865abfb74b662c9f2e63619da80fcc7376b..bf437f6065f386ccfd49b01c56bc6b6d31848af0 100644 --- a/test/test_async.cpp +++ b/test/test_async.cpp @@ -53,13 +53,19 @@ TEST(test_async, retrieve_non_existing) { auto status = transaction->GetStatus(); EXPECT_EQ(status.GetCode(), StatusCode::EXECUTING); - // wait some time - std::this_thread::sleep_for(1000ms); + // 1000ms are not always sufficient, when there is very high pipeline load. + auto count = 1000; + auto code = transaction->GetStatus().GetCode(); + do { + // wait some time + std::this_thread::sleep_for(10ms); - // DONT call WaitForIt -> the transaction finishes in the back-ground - status = transaction->GetStatus(); - EXPECT_EQ(status.GetCode(), TransactionStatus::TRANSACTION_ERROR().GetCode()); - ASSERT_EQ(status.GetCode(), StatusCode::GENERIC_TRANSACTION_ERROR); + // DONT call WaitForIt -> the transaction finishes in the background + code = transaction->GetStatus().GetCode(); + } while (--count > 0 && code == StatusCode::EXECUTING); + ASSERT_GT(count, 0) << "ERROR: Timeout while waiting for transaction."; + EXPECT_EQ(code, TransactionStatus::TRANSACTION_ERROR().GetCode()); + ASSERT_EQ(code, StatusCode::GENERIC_TRANSACTION_ERROR); const auto &result_set = transaction->GetResultSet();