From 56286a0106152be09864f82ec7e527c7be30fd12 Mon Sep 17 00:00:00 2001 From: Jonathan Reams Date: Fri, 30 Aug 2024 15:53:32 -0400 Subject: [PATCH] RCORE-2254 Run baas integration tests against stable branch of baas --- dependencies.yml | 4 ---- evergreen/config.yml | 2 +- .../object-store/util/sync/baas_admin_api.cpp | 22 ++++++++++++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dependencies.yml b/dependencies.yml index 3bf50ca20f..e76bbbee24 100644 --- a/dependencies.yml +++ b/dependencies.yml @@ -2,7 +2,3 @@ PACKAGE_NAME: realm-core VERSION: 14.12.1 OPENSSL_VERSION: 3.3.1 ZLIB_VERSION: 1.2.13 -# https://github.com/10gen/baas/commits -# 2f308db is 2024 July 10 -BAAS_VERSION: 2f308db6f65333728a101d1fecbb792f9659a5ce -BAAS_VERSION_TYPE: githash diff --git a/evergreen/config.yml b/evergreen/config.yml index e14afde6c9..26f0452c8e 100644 --- a/evergreen/config.yml +++ b/evergreen/config.yml @@ -278,7 +278,7 @@ functions: BAASAAS_API_KEY: "${baasaas_api_key}" # BAAS_VERSION and VERSION_TYPE are set by realm-core/dependencies.yml BAASAAS_REF_SPEC: "${BAAS_VERSION}" - BAASAAS_START_MODE: "${BAAS_VERSION_TYPE|githash}" + BAASAAS_START_MODE: "${BAAS_VERSION_TYPE|currentstable}" script: |- set -o errexit set -o verbose diff --git a/test/object-store/util/sync/baas_admin_api.cpp b/test/object-store/util/sync/baas_admin_api.cpp index 6306f279f1..55a852bba7 100644 --- a/test/object-store/util/sync/baas_admin_api.cpp +++ b/test/object-store/util/sync/baas_admin_api.cpp @@ -380,7 +380,7 @@ app::Response do_http_request(const app::Request& request) class Baasaas { public: - enum class StartMode { Default, GitHash, Branch, PatchId }; + enum class StartMode { Default, GitHash, Branch, PatchId, CurrentStable }; explicit Baasaas(std::string api_key, StartMode mode, std::string ref_spec) : m_api_key(std::move(api_key)) , m_base_url(get_baasaas_base_url()) @@ -400,6 +400,11 @@ class Baasaas { url_path = util::format("startContainer?patchId=%1", ref_spec); logger->info("Starting baasaas container for patch id %1", ref_spec); } + else if (mode == StartMode::CurrentStable) { + auto stable_branch = get_current_stable_image(); + url_path = util::format("startContainer?branch=%1", stable_branch); + logger->info("Starting baasaas container on stable branch %1", stable_branch); + } else { logger->info("Starting baasaas container"); } @@ -561,6 +566,18 @@ class Baasaas { } } + std::string get_current_stable_image() + { + auto [images, coid] = do_request("images", app::HttpMethod::get); + auto all_branches = images["allBranches"].template get>(); + if (all_branches.size() < 2) { + throw RuntimeError( + ErrorCodes::MalformedJson, + util::format("No stable branch found in baasaas response %1 (coid: %2)", images.dump(), coid)); + } + return all_branches[1]; + } + std::string baas_coid_from_response(const app::Response& resp) { if (auto it = resp.headers.find(g_baas_coid_header_name); it != resp.headers.end()) { @@ -662,6 +679,9 @@ class BaasaasLauncher : public Catch::EventListenerBase { } mode = Baasaas::StartMode::PatchId; } + else if (mode_spec == "currentstable") { + mode = Baasaas::StartMode::CurrentStable; + } else { if (!mode_spec.empty()) { throw std::runtime_error("Expected BAASAAS_START_MODE to be \"githash\", \"patchid\", or \"branch\"");