diff options
Diffstat (limited to 'test/buildtool/execution_api')
-rw-r--r-- | test/buildtool/execution_api/bazel/TARGETS | 4 | ||||
-rw-r--r-- | test/buildtool/execution_api/bazel/bazel_api.test.cpp | 71 |
2 files changed, 54 insertions, 21 deletions
diff --git a/test/buildtool/execution_api/bazel/TARGETS b/test/buildtool/execution_api/bazel/TARGETS index c2898d1c..acbee81f 100644 --- a/test/buildtool/execution_api/bazel/TARGETS +++ b/test/buildtool/execution_api/bazel/TARGETS @@ -140,11 +140,13 @@ , ["@", "src", "src/buildtool/execution_api/common", "common"] , ["@", "src", "src/buildtool/execution_api/remote", "bazel_api"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] + , ["@", "src", "src/buildtool/storage", "config"] + , ["@", "src", "src/utils/cpp", "tmp_dir"] , ["buildtool/execution_api/common", "api_test"] , ["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_api", "bazel"] } diff --git a/test/buildtool/execution_api/bazel/bazel_api.test.cpp b/test/buildtool/execution_api/bazel/bazel_api.test.cpp index 230ee2dc..8fb50006 100644 --- a/test/buildtool/execution_api/bazel/bazel_api.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_api.test.cpp @@ -15,6 +15,7 @@ #include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp" #include <optional> +#include <utility> #include "catch2/catch_test_macros.hpp" #include "gsl/gsl" @@ -24,8 +25,10 @@ #include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/storage/config.hpp" +#include "src/utils/cpp/tmp_dir.hpp" #include "test/buildtool/execution_api/common/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" @@ -36,10 +39,12 @@ class FactoryApi final { explicit FactoryApi( gsl::not_null<ServerAddress const*> const& server_address, gsl::not_null<Auth const*> const& auth, - HashFunction hash_function) noexcept + HashFunction hash_function, + TmpDir::Ptr temp_space) noexcept : address_{*server_address}, auth_{*auth}, - hash_function_{hash_function} {} + hash_function_{hash_function}, + temp_space_{std::move(temp_space)} {} [[nodiscard]] auto operator()() const -> IExecutionApi::Ptr { static RetryConfig retry_config{}; // default retry config @@ -49,20 +54,22 @@ class FactoryApi final { &auth_, &retry_config, {}, - hash_function_}}; + hash_function_, + temp_space_}}; } private: ServerAddress const& address_; Auth const& auth_; HashFunction const hash_function_; + TmpDir::Ptr temp_space_; }; } // namespace TEST_CASE("BazelAPI: No input, no output", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -70,13 +77,16 @@ TEST_CASE("BazelAPI: No input, no output", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestNoInputNoOutput(api_factory, remote_config->platform_properties); } TEST_CASE("BazelAPI: No input, create output", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -84,13 +94,16 @@ TEST_CASE("BazelAPI: No input, create output", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestNoInputCreateOutput(api_factory, remote_config->platform_properties); } TEST_CASE("BazelAPI: One input copied to output", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -98,13 +111,16 @@ TEST_CASE("BazelAPI: One input copied to output", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestOneInputCopiedToOutput(api_factory, remote_config->platform_properties); } TEST_CASE("BazelAPI: Non-zero exit code, create output", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -112,14 +128,17 @@ TEST_CASE("BazelAPI: Non-zero exit code, create output", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestNonZeroExitCodeCreateOutput(api_factory, remote_config->platform_properties); } TEST_CASE("BazelAPI: Retrieve two identical trees to path", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -127,15 +146,18 @@ TEST_CASE("BazelAPI: Retrieve two identical trees to path", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestRetrieveTwoIdenticalTreesToPath( api_factory, remote_config->platform_properties, "two_trees"); } TEST_CASE("BazelAPI: Retrieve file and symlink with same content to path", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -143,14 +165,17 @@ TEST_CASE("BazelAPI: Retrieve file and symlink with same content to path", REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestRetrieveFileAndSymlinkWithSameContentToPath( api_factory, remote_config->platform_properties, "file_and_symlink"); } TEST_CASE("BazelAPI: Retrieve mixed blobs and trees", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -158,14 +183,17 @@ TEST_CASE("BazelAPI: Retrieve mixed blobs and trees", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestRetrieveMixedBlobsAndTrees( api_factory, remote_config->platform_properties, "blobs_and_trees"); } TEST_CASE("BazelAPI: Create directory prior to execution", "[execution_api]") { + auto storage_config = TestStorageConfig::Create(); auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; REQUIRE(remote_config); REQUIRE(remote_config->remote_address); @@ -173,7 +201,10 @@ TEST_CASE("BazelAPI: Create directory prior to execution", "[execution_api]") { REQUIRE(auth); FactoryApi api_factory{ - &*remote_config->remote_address, &*auth, hash_function}; + &*remote_config->remote_address, + &*auth, + storage_config.Get().hash_function, + storage_config.Get().CreateTypedTmpDir("test_space")}; TestCreateDirPriorToExecution(api_factory, remote_config->platform_properties); } |