From c0264199e0b5c93e1be7f2b08e7fe548ffef2b01 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Wed, 25 Oct 2023 12:41:45 +0200
Subject: [PATCH] REVERT: revert to caosdb-cpplib-v0.2.2

---
 .docker/Dockerfile                         |  3 +--
 .gitlab-ci.yml                             |  6 +++++-
 .gitlab/merge_request_templates/Default.md |  4 +---
 CHANGELOG.md                               |  2 --
 README.md                                  |  5 -----
 conanfile.txt                              |  2 +-
 test/test_async.cpp                        | 18 ++++++------------
 test/test_select.cpp                       |  4 +++-
 test/test_transaction.cpp                  |  2 ++
 9 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/.docker/Dockerfile b/.docker/Dockerfile
index 29e439b..98f12aa 100644
--- a/.docker/Dockerfile
+++ b/.docker/Dockerfile
@@ -15,8 +15,7 @@ RUN rm -rf .git
 
 COPY .docker/caosdb-client.json /caosdb-client.json
 
-# Build and run tests.
-# If no other command is given to the Docker image
+# build and run tests
 CMD mkdir build && \
     cd build && \
     conan install .. -s "compiler.libcxx=libstdc++11" && \
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 93e5484..8027bef 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -78,12 +78,16 @@ 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" ; echo "Using cpplib@dev instead."; docker pull $CPPLIB_REGISTRY_IMAGE ; }
+    - docker pull $CPPLIB_REGISTRY_IMAGE || { CPPLIB_REGISTRY_IMAGE="$CI_REGISTRY/caosdb/src/caosdb-cpplib/testenv:dev" ; docker pull $CPPLIB_REGISTRY_IMAGE ; }
     - docker build
       --build-arg CPPLIB_REGISTRY_IMAGE=$CPPLIB_REGISTRY_IMAGE
       --file .docker/Dockerfile
diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md
index 3629e0c..35c6d01 100644
--- a/.gitlab/merge_request_templates/Default.md
+++ b/.gitlab/merge_request_templates/Default.md
@@ -28,7 +28,6 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md)
 - [ ] Up-to-date CHANGELOG.md (or not necessary)
 - [ ] Up-to-date JSON schema (or not necessary)
 - [ ] Appropriate user and developer documentation (or not necessary)
-  - Update / write published documentation (`make doc`).
   - How do I use the software?  Assume "stupid" users.
   - How do I develop or debug the software?  Assume novice developers.
 - [ ] Annotations in code (Gitlab comments)
@@ -42,8 +41,7 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md)
 - [ ] I understand the intent of this MR
 - [ ] All automated tests pass
 - [ ] Up-to-date CHANGELOG.md (or not necessary)
-- [ ] Appropriate user and developer documentation (or not necessary), also in published
-      documentation.
+- [ ] Appropriate user and developer documentation (or not necessary)
 - [ ] The test environment setup works and the intended behavior is reproducible in the test
   environment
 - [ ] In-code documentation and comments are up-to-date.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fcdf016..449e425 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
-* Fixed failing async test.
-
 ### Security
diff --git a/README.md b/README.md
index 4606072..2940e2a 100644
--- a/README.md
+++ b/README.md
@@ -25,11 +25,6 @@ Create a local conan package from the caosdb-cpplib repository
    path to the pem file in the `CAOSDB_SERVER_CERT` environment variable.
 7. Run with `ctest` in the build directory.
 
-### Troubleshooting ###
-
-- If you don't have `clang-tidy` installed, you can run the first `cmake` command with
-  `LINTING=OFF`: `cmake -D LINTING=OFF -B . ..`
-
 ## Formatting, style, linting ##
 
 `make format`
diff --git a/conanfile.txt b/conanfile.txt
index cd80b14..54cdf1b 100644
--- a/conanfile.txt
+++ b/conanfile.txt
@@ -1,5 +1,5 @@
 [requires]
-caosdb/[>=0.3.0-dev, include_prerelease=True]
+caosdb/0.2.2
 
 [build_requires]
 gtest/1.11.0
diff --git a/test/test_async.cpp b/test/test_async.cpp
index bf437f6..c804986 100644
--- a/test/test_async.cpp
+++ b/test/test_async.cpp
@@ -53,19 +53,13 @@ TEST(test_async, retrieve_non_existing) {
   auto status = transaction->GetStatus();
   EXPECT_EQ(status.GetCode(), StatusCode::EXECUTING);
 
-  // 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);
+  // wait some time
+  std::this_thread::sleep_for(1000ms);
 
-    // 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);
+  // 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);
 
   const auto &result_set = transaction->GetResultSet();
 
diff --git a/test/test_select.cpp b/test/test_select.cpp
index fa63eef..f880954 100644
--- a/test/test_select.cpp
+++ b/test/test_select.cpp
@@ -363,7 +363,9 @@ TEST_F(test_select, test_select_property_unit) {
   EXPECT_EQ(query_transaction->GetResultTable().size(), 1);
   for (const auto &row : query_transaction->GetResultTable().GetRows()) {
 
-    EXPECT_EQ(row.GetValue("TestPropDouble.unit").GetAsString(), "m");
+    // Fails due to https://gitlab.indiscale.com/caosdb/src/caosdb-server/-/issues/264
+    EXPECT_NONFATAL_FAILURE({ EXPECT_EQ(row.GetValue("TestPropDouble.unit").GetAsString(), "m"); },
+                            "TestPropDouble.unit");
   }
 }
 
diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp
index 2b1be4c..aff1c6e 100644
--- a/test/test_transaction.cpp
+++ b/test/test_transaction.cpp
@@ -1342,9 +1342,11 @@ TEST_F(test_transaction, test_delete_string_id) {
   EXPECT_TRUE(transaction->GetStatus().IsTerminated());
   EXPECT_TRUE(transaction->GetStatus().IsError());
   const auto &results = transaction->GetResultSet();
+  EXPECT_FALSE(results.at(0).HasErrors());
   EXPECT_TRUE(results.at(1).HasErrors());
   EXPECT_EQ(results.at(1).GetErrors().size(), 1);
   EXPECT_EQ(results.at(1).GetErrors().at(0).GetDescription(), "Entity does not exist.");
+  EXPECT_FALSE(results.at(2).HasErrors());
 }
 
 } // namespace caosdb::transaction
-- 
GitLab