diff options
Diffstat (limited to 'test/buildtool/execution_engine')
3 files changed, 82 insertions, 32 deletions
diff --git a/test/buildtool/execution_engine/executor/TARGETS b/test/buildtool/execution_engine/executor/TARGETS index a27e8dac..184c9fe1 100644 --- a/test/buildtool/execution_engine/executor/TARGETS +++ b/test/buildtool/execution_engine/executor/TARGETS @@ -59,10 +59,13 @@ , ["@", "src", "src/buildtool/file_system", "object_type"] , ["@", "src", "src/buildtool/logging", "logging"] , ["@", "src", "src/buildtool/progress_reporting", "progress"] + , ["@", "src", "src/buildtool/storage", "config"] , ["@", "src", "src/utils/cpp", "expected"] + , ["@", "src", "src/utils/cpp", "tmp_dir"] , ["", "catch-main"] , ["utils", "test_api_bundle"] , ["utils", "test_hash_function_type"] + , ["utils", "test_storage_config"] ] , "stage": ["test", "buildtool", "execution_engine", "executor"] } @@ -108,10 +111,11 @@ , ["@", "src", "src/buildtool/execution_api/remote", "bazel_api"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] , ["@", "src", "src/buildtool/progress_reporting", "progress"] + , ["@", "src", "src/buildtool/storage", "config"] , ["utils", "catch-main-remote-execution"] , ["utils", "test_auth_config"] - , ["utils", "test_hash_function_type"] , ["utils", "test_remote_config"] + , ["utils", "test_storage_config"] ] , "stage": ["test", "buildtool", "execution_engine", "executor"] } diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp index a9f91ade..93dd10b6 100644 --- a/test/buildtool/execution_engine/executor/executor.test.cpp +++ b/test/buildtool/execution_engine/executor/executor.test.cpp @@ -57,9 +57,12 @@ #include "src/buildtool/file_system/object_type.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/progress_reporting/progress.hpp" +#include "src/buildtool/storage/config.hpp" #include "src/utils/cpp/expected.hpp" +#include "src/utils/cpp/tmp_dir.hpp" #include "test/utils/executor/test_api_bundle.hpp" #include "test/utils/hermeticity/test_hash_function_type.hpp" +#include "test/utils/hermeticity/test_storage_config.hpp" /// \brief Mockup API test config. struct TestApiConfig { @@ -190,8 +193,11 @@ class TestAction : public IExecutionAction { class TestApi : public IExecutionApi { public: explicit TestApi(TestApiConfig config, - HashFunction::Type hash_type) noexcept - : config_{std::move(config)}, hash_type_{hash_type} {} + HashFunction::Type hash_type, + TmpDir::Ptr temp_space) noexcept + : config_{std::move(config)}, + hash_type_{hash_type}, + temp_space_{std::move(temp_space)} {} [[nodiscard]] auto CreateAction( ArtifactDigest const& /*unused*/, @@ -284,9 +290,14 @@ class TestApi : public IExecutionApi { return hash_type_; } + [[nodiscard]] auto GetTempSpace() const noexcept -> TmpDir::Ptr final { + return temp_space_; + } + private: TestApiConfig config_{}; HashFunction::Type hash_type_; + TmpDir::Ptr temp_space_; }; [[nodiscard]] auto SetupConfig(std::filesystem::path const& ws) @@ -334,12 +345,13 @@ class TestApi : public IExecutionApi { } TEST_CASE("Executor: Process artifact", "[executor]") { + auto const storage_config = TestStorageConfig::Create(); std::filesystem::path workspace_path{ "test/buildtool/execution_engine/executor"}; DependencyGraph g; auto [config, repo_config] = CreateTest(&g, workspace_path); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + HashFunction const hash_function = storage_config.Get().hash_function; auto const local_cpp_id = ArtifactDescription::CreateLocal("local.cpp", "").Id(); @@ -356,7 +368,10 @@ TEST_CASE("Executor: Process artifact", "[executor]") { .exec_config = &remote_config}; SECTION("Processing succeeds for valid config") { - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -375,7 +390,10 @@ TEST_CASE("Executor: Process artifact", "[executor]") { SECTION("Processing fails if uploading local artifact failed") { config.artifacts[NamedDigest("local.cpp").hash()].uploads = false; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -394,7 +412,10 @@ TEST_CASE("Executor: Process artifact", "[executor]") { SECTION("Processing fails if known artifact is not available") { config.artifacts[NamedDigest("known.cpp").hash()].available = false; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -412,13 +433,14 @@ TEST_CASE("Executor: Process artifact", "[executor]") { } TEST_CASE("Executor: Process action", "[executor]") { + auto const storage_config = TestStorageConfig::Create(); std::filesystem::path workspace_path{ "test/buildtool/execution_engine/executor"}; DependencyGraph g; auto [config, repo_config] = CreateTest(&g, workspace_path); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + HashFunction const hash_function = storage_config.Get().hash_function; auto const local_cpp_id = ArtifactDescription::CreateLocal("local.cpp", "").Id(); @@ -442,7 +464,10 @@ TEST_CASE("Executor: Process action", "[executor]") { .exec_config = &remote_config}; SECTION("Processing succeeds for valid config") { - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -464,7 +489,10 @@ TEST_CASE("Executor: Process action", "[executor]") { SECTION("Processing succeeds even if result was is not cached") { config.response.cached = false; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -486,7 +514,10 @@ TEST_CASE("Executor: Process action", "[executor]") { SECTION("Processing succeeds even if output is not available in CAS") { config.artifacts[NamedDigest("output2.exe").hash()].available = false; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -511,7 +542,10 @@ TEST_CASE("Executor: Process action", "[executor]") { SECTION("Processing fails if execution failed") { config.execution.failed = true; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -533,7 +567,10 @@ TEST_CASE("Executor: Process action", "[executor]") { SECTION("Processing fails if exit code is non-zero") { config.response.exit_code = 1; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); @@ -558,7 +595,10 @@ TEST_CASE("Executor: Process action", "[executor]") { SECTION("Processing fails if any output is missing") { config.execution.outputs = {"output1.exe" /*, "output2.exe"*/}; - auto api = std::make_shared<TestApi>(config, hash_function.GetType()); + auto api = std::make_shared<TestApi>( + config, + hash_function.GetType(), + storage_config.Get().CreateTypedTmpDir("temp_space")); Statistics stats{}; Progress progress{}; auto const apis = CreateTestApiBundle(api); diff --git a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp index a809d04f..c92f3aef 100644 --- a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp +++ b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp @@ -21,13 +21,13 @@ #include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/common/repository_config.hpp" #include "src/buildtool/common/statistics.hpp" -#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/bazel_msg/execution_config.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp" #include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/progress_reporting/progress.hpp" +#include "src/buildtool/storage/config.hpp" #include "test/buildtool/execution_engine/executor/executor_api.test.hpp" -#include "test/utils/hermeticity/test_hash_function_type.hpp" +#include "test/utils/hermeticity/test_storage_config.hpp" #include "test/utils/remote_execution/test_auth_config.hpp" #include "test/utils/remote_execution/test_remote_config.hpp" @@ -44,16 +44,18 @@ TEST_CASE("Executor<BazelApi>: Upload blob", "[executor]") { RetryConfig retry_config{}; // default retry config - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + auto storage_config = TestStorageConfig::Create(); TestBlobUpload(&repo_config, [&] { - return std::make_shared<BazelApi>("remote-execution", - remote_config->remote_address->host, - remote_config->remote_address->port, - &*auth_config, - &retry_config, - config, - hash_function); + return std::make_shared<BazelApi>( + "remote-execution", + remote_config->remote_address->host, + remote_config->remote_address->port, + &*auth_config, + &retry_config, + config, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")); }); } @@ -73,7 +75,7 @@ TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") { RetryConfig retry_config{}; // default retry config - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + auto storage_config = TestStorageConfig::Create(); TestHelloWorldCompilation( &repo_config, @@ -87,7 +89,8 @@ TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") { &*auth_config, &retry_config, config, - hash_function); + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")); }, &*auth_config, false /* not hermetic */); @@ -109,7 +112,7 @@ TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") { RetryConfig retry_config{}; // default retry config - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + auto storage_config = TestStorageConfig::Create(); TestGreeterCompilation( &repo_config, @@ -123,7 +126,8 @@ TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") { &*auth_config, &retry_config, config, - hash_function); + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")); }, &*auth_config, false /* not hermetic */); @@ -145,7 +149,7 @@ TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") { RetryConfig retry_config{}; // default retry config - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + auto storage_config = TestStorageConfig::Create(); TestUploadAndDownloadTrees( &repo_config, @@ -159,7 +163,8 @@ TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") { &*auth_config, &retry_config, config, - hash_function); + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")); }, &*auth_config, false /* not hermetic */); @@ -181,7 +186,7 @@ TEST_CASE("Executor<BazelApi>: Retrieve output directories", "[executor]") { RetryConfig retry_config{}; // default retry config - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; + auto storage_config = TestStorageConfig::Create(); TestRetrieveOutputDirectories( &repo_config, @@ -195,7 +200,8 @@ TEST_CASE("Executor<BazelApi>: Retrieve output directories", "[executor]") { &*auth_config, &retry_config, config, - hash_function); + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")); }, &*auth_config, false /* not hermetic */); |