Skip to content

Commit

Permalink
RCORE-2254 Run baas integration tests against stable branch of baas
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreams committed Aug 30, 2024
1 parent 1760013 commit 56286a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 0 additions & 4 deletions dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion test/object-store/util/sync/baas_admin_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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");
}
Expand Down Expand Up @@ -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<std::vector<std::string>>();
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()) {
Expand Down Expand Up @@ -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\"");
Expand Down

0 comments on commit 56286a0

Please sign in to comment.