summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-25 17:02:03 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-30 12:10:06 +0200
commitb5a92a60035ea3731a96bbdc8bca18986b558a05 (patch)
tree088d85e95d929b31cf74afb1a922b34c4afa7138 /test
parentdeba068d8692bf6d265926885de5601d72f5d461 (diff)
downloadjustbuild-b5a92a60035ea3731a96bbdc8bca18986b558a05.tar.gz
Pass RemoteContext to ApiBundle
The CreateRemote method is also updated to receive all remote-related information as arguments, such that it does not have to rely on the ApiBundle internal fields which will eventually be removed.
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/build_engine/target_map/TARGETS1
-rw-r--r--test/buildtool/build_engine/target_map/target_map.test.cpp175
-rw-r--r--test/buildtool/graph_traverser/TARGETS1
-rw-r--r--test/buildtool/graph_traverser/graph_traverser.test.hpp155
4 files changed, 235 insertions, 97 deletions
diff --git a/test/buildtool/build_engine/target_map/TARGETS b/test/buildtool/build_engine/target_map/TARGETS
index af1a400e..f87cc475 100644
--- a/test/buildtool/build_engine/target_map/TARGETS
+++ b/test/buildtool/build_engine/target_map/TARGETS
@@ -35,6 +35,7 @@
, ["@", "src", "src/buildtool/execution_api/local", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "context"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
+ , ["@", "src", "src/buildtool/execution_api/remote", "context"]
, ["@", "src", "src/buildtool/file_system", "file_root"]
, ["@", "src", "src/buildtool/progress_reporting", "progress"]
, ["@", "src", "src/buildtool/storage", "config"]
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 4524d1b0..a305a8e8 100644
--- a/test/buildtool/build_engine/target_map/target_map.test.cpp
+++ b/test/buildtool/build_engine/target_map/target_map.test.cpp
@@ -34,6 +34,7 @@
#include "src/buildtool/execution_api/local/config.hpp"
#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
+#include "src/buildtool/execution_api/remote/context.hpp"
#include "src/buildtool/file_system/file_root.hpp"
#include "src/buildtool/main/analyse_context.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
@@ -110,18 +111,24 @@ TEST_CASE("simple targets", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
@@ -566,19 +573,27 @@ TEST_CASE("configuration deduplication", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
@@ -667,19 +682,27 @@ TEST_CASE("generator functions in string arguments", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
@@ -780,19 +803,27 @@ TEST_CASE("built-in rules", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
@@ -1005,19 +1036,27 @@ TEST_CASE("target reference", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
@@ -1161,19 +1200,27 @@ TEST_CASE("trees", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
@@ -1281,19 +1328,27 @@ TEST_CASE("RESULT error reporting", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
@@ -1460,19 +1515,27 @@ TEST_CASE("wrong arguments", "[target_map]") {
REQUIRE(serve_config);
LocalExecutionConfig local_exec_config{};
- RemoteExecutionConfig remote_exec_config{};
- Auth auth{};
- RetryConfig retry_config{};
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config.Get(),
.storage = &storage};
+
+ Auth auth{};
+ RetryConfig retry_config{};
+ RemoteExecutionConfig remote_exec_config{};
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = &auth,
+ .retry_config = &retry_config,
+ .exec_config = &remote_exec_config};
+
ApiBundle const apis{&local_context,
- /*repo_config=*/nullptr,
- &auth,
- &retry_config,
- &remote_exec_config};
+ &remote_context,
+ /*repo_config=*/nullptr};
+
auto serve = ServeApi::Create(*serve_config, &storage, &apis);
+
AnalyseContext ctx{.repo_config = &repo_config,
.storage = &storage,
.statistics = &stats,
diff --git a/test/buildtool/graph_traverser/TARGETS b/test/buildtool/graph_traverser/TARGETS
index 189ad233..1035fbcd 100644
--- a/test/buildtool/graph_traverser/TARGETS
+++ b/test/buildtool/graph_traverser/TARGETS
@@ -11,6 +11,7 @@
, ["@", "src", "src/buildtool/execution_api/local", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "context"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
+ , ["@", "src", "src/buildtool/execution_api/remote", "context"]
, ["@", "src", "src/buildtool/file_system", "file_system_manager"]
, ["@", "src", "src/buildtool/file_system", "jsonfs"]
, ["@", "src", "src/buildtool/graph_traverser", "graph_traverser"]
diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp
index c28f3a6c..0f3de2e6 100644
--- a/test/buildtool/graph_traverser/graph_traverser.test.hpp
+++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp
@@ -35,6 +35,7 @@
#include "src/buildtool/execution_api/local/config.hpp"
#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
+#include "src/buildtool/execution_api/remote/context.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/jsonfs.hpp"
#include "src/buildtool/graph_traverser/graph_traverser.hpp"
@@ -169,15 +170,24 @@ class TestProject {
auto const local_exec_config = CreateLocalExecConfig();
auto const clargs = p.CmdLineArgs();
+
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -204,12 +214,6 @@ class TestProject {
SECTION("Executable is retrieved as executable") {
auto const clargs_exec = p.CmdLineArgs("_entry_points_get_executable");
- RetryConfig retry_config{}; // default retry config
- ApiBundle const apis{&local_context,
- p.GetRepoConfig(),
- auth,
- &retry_config,
- remote_config};
GraphTraverser const gt_get_exec{clargs_exec.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -246,15 +250,24 @@ class TestProject {
auto const local_exec_config = CreateLocalExecConfig();
auto const clargs = p.CmdLineArgs();
+
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -286,15 +299,24 @@ class TestProject {
auto const local_exec_config = CreateLocalExecConfig();
auto const clargs = p.CmdLineArgs();
+
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -346,18 +368,25 @@ class TestProject {
auto const local_exec_config = CreateLocalExecConfig();
auto const clargs_update_cpp =
full_hello_world.CmdLineArgs("_entry_points_upload_source");
+
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{&local_context,
- full_hello_world.GetRepoConfig(),
- auth,
- &retry_config,
- remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{
+ &local_context, &remote_context, full_hello_world.GetRepoConfig()};
+
GraphTraverser const gt_upload{clargs_update_cpp.gtargs,
full_hello_world.GetRepoConfig(),
remote_config->platform_properties,
@@ -414,16 +443,25 @@ static void TestBlobsUploadedAndUsed(
TestProject p("use_uploaded_blobs");
auto const clargs = p.CmdLineArgs();
- auto const local_exec_config = CreateLocalExecConfig();
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
+ auto const local_exec_config = CreateLocalExecConfig();
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -462,16 +500,25 @@ static void TestEnvironmentVariablesSetAndUsed(
TestProject p("use_env_variables");
auto const clargs = p.CmdLineArgs();
- auto const local_exec_config = CreateLocalExecConfig();
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
+ auto const local_exec_config = CreateLocalExecConfig();
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -510,16 +557,25 @@ static void TestTreesUsed(
TestProject p("use_trees");
auto const clargs = p.CmdLineArgs();
- auto const local_exec_config = CreateLocalExecConfig();
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
+ auto const local_exec_config = CreateLocalExecConfig();
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -558,16 +614,25 @@ static void TestNestedTreesUsed(
TestProject p("use_nested_trees");
auto const clargs = p.CmdLineArgs();
- auto const local_exec_config = CreateLocalExecConfig();
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
+ auto const local_exec_config = CreateLocalExecConfig();
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
+
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
remote_config->platform_properties,
@@ -605,16 +670,24 @@ static void TestFlakyHelloWorldDetected(
bool /*is_hermetic*/ = true) {
TestProject p("flaky_hello_world");
- auto const local_exec_config = CreateLocalExecConfig();
Statistics stats{};
Progress progress{};
- RetryConfig retry_config{}; // default retry config
+
+ auto const local_exec_config = CreateLocalExecConfig();
+
// pack the local context instances to be passed to ApiBundle
LocalContext const local_context{.exec_config = &local_exec_config,
.storage_config = &storage_config,
.storage = &storage};
- ApiBundle const apis{
- &local_context, p.GetRepoConfig(), auth, &retry_config, remote_config};
+
+ RetryConfig retry_config{}; // default retry config
+
+ // pack the remote context instances to be passed to ApiBundle
+ RemoteContext const remote_context{.auth = auth,
+ .retry_config = &retry_config,
+ .exec_config = remote_config};
+
+ ApiBundle const apis{&local_context, &remote_context, p.GetRepoConfig()};
{
auto clargs = p.CmdLineArgs("_entry_points_ctimes");