From 461ba224785cba270b37375d9dc25f06a630d723 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 26 Jul 2024 12:50:44 +0200 Subject: Pass LocalContext and RemoteContext to ServeApi Also switch to using the fields from RemoteContext instances instead of those from ApiBundle. --- .../build_engine/target_map/target_map.test.cpp | 24 ++++++++++++++-------- test/buildtool/serve_api/TARGETS | 3 +++ .../serve_api/source_tree_client.test.cpp | 11 +++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/buildtool/build_engine/target_map/target_map.test.cpp b/test/buildtool/build_engine/target_map/target_map.test.cpp index a305a8e8..ed859e31 100644 --- a/test/buildtool/build_engine/target_map/target_map.test.cpp +++ b/test/buildtool/build_engine/target_map/target_map.test.cpp @@ -129,7 +129,8 @@ TEST_CASE("simple targets", "[target_map]") { ApiBundle const apis{&local_context, &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, .statistics = &stats, @@ -592,7 +593,8 @@ TEST_CASE("configuration deduplication", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, @@ -701,7 +703,8 @@ TEST_CASE("generator functions in string arguments", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, @@ -822,7 +825,8 @@ TEST_CASE("built-in rules", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, @@ -1055,7 +1059,8 @@ TEST_CASE("target reference", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, @@ -1219,7 +1224,8 @@ TEST_CASE("trees", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, @@ -1347,7 +1353,8 @@ TEST_CASE("RESULT error reporting", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, @@ -1534,7 +1541,8 @@ TEST_CASE("wrong arguments", "[target_map]") { &remote_context, /*repo_config=*/nullptr}; - auto serve = ServeApi::Create(*serve_config, &storage, &apis); + auto serve = + ServeApi::Create(*serve_config, &local_context, &remote_context, &apis); AnalyseContext ctx{.repo_config = &repo_config, .storage = &storage, diff --git a/test/buildtool/serve_api/TARGETS b/test/buildtool/serve_api/TARGETS index 279692ad..4e903d83 100644 --- a/test/buildtool/serve_api/TARGETS +++ b/test/buildtool/serve_api/TARGETS @@ -7,6 +7,9 @@ [ ["@", "catch2", "", "catch2"] , ["utils", "catch-main-serve"] , ["@", "src", "src/buildtool/auth", "auth"] + , ["@", "src", "src/buildtool/common/remote", "retry_config"] + , ["@", "src", "src/buildtool/execution_api/remote", "config"] + , ["@", "src", "src/buildtool/execution_api/remote", "context"] , ["@", "src", "src/buildtool/serve_api/remote", "source_tree_client"] , ["utils", "test_serve_config"] , ["@", "src", "src/buildtool/serve_api/remote", "config"] diff --git a/test/buildtool/serve_api/source_tree_client.test.cpp b/test/buildtool/serve_api/source_tree_client.test.cpp index e1f6d84b..d44a1605 100644 --- a/test/buildtool/serve_api/source_tree_client.test.cpp +++ b/test/buildtool/serve_api/source_tree_client.test.cpp @@ -17,6 +17,9 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/auth/authentication.hpp" +#include "src/buildtool/common/remote/retry_config.hpp" +#include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/serve_api/remote/config.hpp" #include "src/buildtool/serve_api/remote/source_tree_client.hpp" #include "test/utils/serve_service/test_serve_config.hpp" @@ -38,7 +41,13 @@ TEST_CASE("Serve service client: tree-of-commit request", "[serve_api]") { // Create TLC client Auth auth{}; - SourceTreeClient st_client(*config->remote_address, &auth); + RetryConfig retry_config{}; + RemoteExecutionConfig exec_config{}; + RemoteContext const remote_context{.auth = &auth, + .retry_config = &retry_config, + .exec_config = &exec_config}; + + SourceTreeClient st_client(*config->remote_address, &remote_context); SECTION("Commit in bare checkout") { auto root_id = st_client.ServeCommitTree(kRootCommit, ".", false); -- cgit v1.2.3