diff options
Diffstat (limited to 'test/buildtool/execution_api')
12 files changed, 76 insertions, 36 deletions
diff --git a/test/buildtool/execution_api/bazel/TARGETS b/test/buildtool/execution_api/bazel/TARGETS index eb888328..4bb08931 100644 --- a/test/buildtool/execution_api/bazel/TARGETS +++ b/test/buildtool/execution_api/bazel/TARGETS @@ -14,6 +14,7 @@ , ["@", "src", "src/buildtool/execution_api/remote", "bazel_network"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] , ["@", "src", "src/buildtool/file_system", "object_type"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "bazel"] } @@ -32,6 +33,7 @@ , ["@", "src", "src/buildtool/execution_api/remote", "bazel_network"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] , ["@", "src", "src/buildtool/file_system", "object_type"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "bazel"] } @@ -50,6 +52,7 @@ , ["@", "src", "src/buildtool/execution_api/remote", "bazel_network"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] , ["@", "src", "src/buildtool/file_system", "object_type"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "bazel"] } @@ -70,6 +73,7 @@ , ["@", "src", "src/buildtool/execution_api/remote", "bazel_network"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] , ["@", "src", "src/buildtool/file_system", "object_type"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "bazel"] } @@ -89,6 +93,7 @@ ] , ["@", "src", "src/buildtool/file_system", "object_type"] , ["utils", "blob_creator"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "bazel"] } diff --git a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp index 5c906b44..498b0492 100644 --- a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp @@ -20,6 +20,7 @@ #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/remote/retry_config.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_execution_client.hpp" @@ -47,7 +48,8 @@ TEST_CASE("Bazel internals: CAS Client", "[execution_api]") { SECTION("Valid digest and blob") { // digest of "test" - auto digest = ArtifactDigest::Create<ObjectType::File>(content); + auto digest = ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content); // Valid blob BazelBlob blob{digest, content, /*is_exec=*/false}; diff --git a/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp b/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp index 57967957..00da3636 100755..100644 --- a/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp @@ -17,6 +17,7 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/remote/retry_config.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_execution_client.hpp" #include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/file_system/object_type.hpp" @@ -27,8 +28,9 @@ TEST_CASE("Bazel internals: Execution Client", "[execution_api]") { std::string instance_name{"remote-execution"}; std::string content("test"); - auto test_digest = static_cast<bazel_re::Digest>( - ArtifactDigest::Create<ObjectType::File>(content)); + auto test_digest = + static_cast<bazel_re::Digest>(ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content)); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); @@ -48,11 +50,11 @@ TEST_CASE("Bazel internals: Execution Client", "[execution_api]") { config.skip_cache_lookup = false; SECTION("Immediate execution and response") { - auto action_immediate = - CreateAction(instance_name, - {"echo", "-n", content}, - {}, - remote_config->platform_properties); + auto action_immediate = CreateAction(instance_name, + {"echo", "-n", content}, + {}, + remote_config->platform_properties, + HashFunction::Instance()); REQUIRE(action_immediate); auto response = execution_client.Execute( @@ -71,7 +73,8 @@ TEST_CASE("Bazel internals: Execution Client", "[execution_api]") { CreateAction(instance_name, {"sh", "-c", "sleep 1s; echo -n test"}, {}, - remote_config->platform_properties); + remote_config->platform_properties, + HashFunction::Instance()); SECTION("Blocking, immediately obtain result") { auto response = execution_client.Execute( @@ -105,8 +108,9 @@ TEST_CASE("Bazel internals: Execution Client using env variables", "[execution_api]") { std::string instance_name{"remote-execution"}; std::string content("contents of env variable"); - auto test_digest = static_cast<bazel_re::Digest>( - ArtifactDigest::Create<ObjectType::File>(content)); + auto test_digest = + static_cast<bazel_re::Digest>(ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content)); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); @@ -128,7 +132,8 @@ TEST_CASE("Bazel internals: Execution Client using env variables", CreateAction(instance_name, {"/bin/sh", "-c", "set -e\necho -n ${MYTESTVAR}"}, {{"MYTESTVAR", content}}, - remote_config->platform_properties); + remote_config->platform_properties, + HashFunction::Instance()); REQUIRE(action); auto response = diff --git a/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp b/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp index b56021c8..233621e9 100644 --- a/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp @@ -17,6 +17,7 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/common/artifact_description.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" @@ -36,9 +37,9 @@ TEST_CASE("Bazel internals: MessageFactory", "[execution_api]") { REQUIRE(FileSystemManager::CreateSymlink("file1", link)); // create the corresponding blobs - auto file1_blob = CreateBlobFromPath(file1); - auto file2_blob = CreateBlobFromPath(file2); - auto link_blob = CreateBlobFromPath(link); + auto file1_blob = CreateBlobFromPath(file1, HashFunction::Instance()); + auto file2_blob = CreateBlobFromPath(file2, HashFunction::Instance()); + auto link_blob = CreateBlobFromPath(link, HashFunction::Instance()); CHECK(file1_blob); CHECK(file2_blob); diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp index d60af9fc..ff05eefb 100644 --- a/test/buildtool/execution_api/bazel/bazel_network.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp @@ -22,6 +22,7 @@ #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/compatibility/compatibility.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_execution_client.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_network.hpp" @@ -55,13 +56,16 @@ TEST_CASE("Bazel network: write/read blobs", "[execution_api]") { std::string content_bar("bar"); std::string content_baz(kLargeSize, 'x'); // single larger blob - BazelBlob foo{ArtifactDigest::Create<ObjectType::File>(content_foo), + BazelBlob foo{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_foo), content_foo, /*is_exec=*/false}; - BazelBlob bar{ArtifactDigest::Create<ObjectType::File>(content_bar), + BazelBlob bar{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_bar), content_bar, /*is_exec=*/false}; - BazelBlob baz{ArtifactDigest::Create<ObjectType::File>(content_baz), + BazelBlob baz{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_baz), content_baz, /*is_exec=*/false}; @@ -113,10 +117,12 @@ TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") { std::string content_foo("foo"); std::string content_bar(kLargeSize, 'x'); // single larger blob - BazelBlob foo{ArtifactDigest::Create<ObjectType::File>(content_foo), + BazelBlob foo{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_foo), content_foo, /*is_exec=*/false}; - BazelBlob bar{ArtifactDigest::Create<ObjectType::File>(content_bar), + BazelBlob bar{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_bar), content_bar, /*is_exec=*/false}; diff --git a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp index 293d2c45..fda769e1 100644 --- a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp @@ -19,6 +19,7 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/auth/authentication.hpp" #include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/common/execution_common.hpp" #include "src/buildtool/execution_api/remote/bazel/bytestream_client.hpp" @@ -48,7 +49,8 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { // digest of "foobar" auto digest = static_cast<bazel_re::Digest>( - ArtifactDigest::Create<ObjectType::File>(content)); + ArtifactDigest::Create<ObjectType::File>(HashFunction::Instance(), + content)); CHECK(stream.Write(fmt::format("{}/uploads/{}/blobs/{}/{}", instance_name, @@ -77,7 +79,8 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { // digest of "instance_nameinstance_nameinstance_..." auto digest = static_cast<bazel_re::Digest>( - ArtifactDigest::Create<ObjectType::File>(content)); + ArtifactDigest::Create<ObjectType::File>(HashFunction::Instance(), + content)); CHECK(stream.Write(fmt::format("{}/uploads/{}/blobs/{}/{}", instance_name, @@ -131,13 +134,16 @@ TEST_CASE("ByteStream Client: Transfer multiple blobs", "[execution_api]") { SECTION("Upload small blobs") { std::string instance_name{"remote-execution"}; - BazelBlob foo{ArtifactDigest::Create<ObjectType::File>("foo"), + BazelBlob foo{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), "foo"), "foo", /*is_exec=*/false}; - BazelBlob bar{ArtifactDigest::Create<ObjectType::File>("bar"), + BazelBlob bar{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), "bar"), "bar", /*is_exec=*/false}; - BazelBlob baz{ArtifactDigest::Create<ObjectType::File>("baz"), + BazelBlob baz{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), "baz"), "baz", /*is_exec=*/false}; @@ -184,13 +190,16 @@ TEST_CASE("ByteStream Client: Transfer multiple blobs", "[execution_api]") { content_baz[i] = instance_name[(i + 2) % instance_name.size()]; } - BazelBlob foo{ArtifactDigest::Create<ObjectType::File>(content_foo), + BazelBlob foo{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_foo), content_foo, /*is_exec=*/false}; - BazelBlob bar{ArtifactDigest::Create<ObjectType::File>(content_bar), + BazelBlob bar{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_bar), content_bar, /*is_exec=*/false}; - BazelBlob baz{ArtifactDigest::Create<ObjectType::File>(content_baz), + BazelBlob baz{ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), content_baz), content_baz, /*is_exec=*/false}; diff --git a/test/buildtool/execution_api/common/TARGETS b/test/buildtool/execution_api/common/TARGETS index b4e2c4a9..89da6ab8 100644 --- a/test/buildtool/execution_api/common/TARGETS +++ b/test/buildtool/execution_api/common/TARGETS @@ -10,6 +10,7 @@ , ["@", "src", "src/buildtool/file_system", "file_system_manager"] , ["@", "src", "src/buildtool/logging", "log_level"] , ["@", "src", "src/buildtool/logging", "logging"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "common"] } diff --git a/test/buildtool/execution_api/common/api_test.hpp b/test/buildtool/execution_api/common/api_test.hpp index e2d8a17d..e00a3b32 100644 --- a/test/buildtool/execution_api/common/api_test.hpp +++ b/test/buildtool/execution_api/common/api_test.hpp @@ -21,6 +21,7 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/common/artifact_description.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/execution_action.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/common/execution_response.hpp" @@ -128,7 +129,8 @@ using ExecProps = std::map<std::string, std::string>; ExecProps const& props, bool is_hermetic = false) { std::string test_content("test"); - auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content); + auto test_digest = ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), test_content); std::string output_path{"output_file"}; @@ -205,7 +207,8 @@ using ExecProps = std::map<std::string, std::string>; ExecProps const& props, bool is_hermetic = false) { std::string test_content("test"); - auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content); + auto test_digest = ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), test_content); auto input_artifact_opt = ArtifactDescription::CreateKnown(test_digest, ObjectType::File) @@ -289,7 +292,8 @@ using ExecProps = std::map<std::string, std::string>; ApiFactory const& api_factory, ExecProps const& props) { std::string test_content("test"); - auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content); + auto test_digest = ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), test_content); std::string output_path{"output_file"}; diff --git a/test/buildtool/execution_api/execution_service/TARGETS b/test/buildtool/execution_api/execution_service/TARGETS index 754615d5..f50057c7 100644 --- a/test/buildtool/execution_api/execution_service/TARGETS +++ b/test/buildtool/execution_api/execution_service/TARGETS @@ -17,6 +17,7 @@ , ["@", "src", "src/buildtool/storage", "config"] , ["@", "src", "src/buildtool/storage", "storage"] , ["@", "gsl", "", "gsl"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "execution_service"] } diff --git a/test/buildtool/execution_api/execution_service/cas_server.test.cpp b/test/buildtool/execution_api/execution_service/cas_server.test.cpp index f0fcf949..845d94aa 100644 --- a/test/buildtool/execution_api/execution_service/cas_server.test.cpp +++ b/test/buildtool/execution_api/execution_service/cas_server.test.cpp @@ -17,6 +17,7 @@ #include "catch2/catch_test_macros.hpp" #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/execution_service/cas_server.hpp" #include "src/buildtool/file_system/git_repo.hpp" #include "src/buildtool/file_system/object_type.hpp" @@ -57,15 +58,16 @@ TEST_CASE("CAS Service: upload incomplete tree", "[execution_service]") { auto empty_entries = GitRepo::tree_entries_t{}; auto empty_tree = GitRepo::CreateShallowTree(empty_entries); REQUIRE(empty_tree); - auto empty_tree_digest = - ArtifactDigest::Create<ObjectType::Tree>(empty_tree->second); + auto empty_tree_digest = ArtifactDigest::Create<ObjectType::Tree>( + HashFunction::Instance(), empty_tree->second); // Create a tree containing the empty tree. auto entries = GitRepo::tree_entries_t{}; entries[empty_tree->first].emplace_back("empty_tree", ObjectType::Tree); auto tree = GitRepo::CreateShallowTree(entries); REQUIRE(tree); - auto tree_digest = ArtifactDigest::Create<ObjectType::Tree>(tree->second); + auto tree_digest = ArtifactDigest::Create<ObjectType::Tree>( + HashFunction::Instance(), tree->second); // Upload tree. The tree invariant is violated, thus, a negative answer is // expected. diff --git a/test/buildtool/execution_api/local/TARGETS b/test/buildtool/execution_api/local/TARGETS index 41870428..212bf0b6 100644 --- a/test/buildtool/execution_api/local/TARGETS +++ b/test/buildtool/execution_api/local/TARGETS @@ -15,6 +15,7 @@ , ["utils", "test_storage_config"] , ["@", "src", "src/buildtool/storage", "storage"] , ["@", "src", "src/buildtool/storage", "config"] + , ["@", "src", "src/buildtool/crypto", "hash_function"] ] , "stage": ["test", "buildtool", "execution_api", "local"] } diff --git a/test/buildtool/execution_api/local/local_execution.test.cpp b/test/buildtool/execution_api/local/local_execution.test.cpp index 72db2800..cac83b2a 100644 --- a/test/buildtool/execution_api/local/local_execution.test.cpp +++ b/test/buildtool/execution_api/local/local_execution.test.cpp @@ -21,6 +21,7 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/common/artifact_description.hpp" #include "src/buildtool/common/repository_config.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/execution_api/local/local_api.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" @@ -172,7 +173,8 @@ TEST_CASE("LocalExecution: No input, create output", "[execution_api]") { &storage_config.Get(), &storage, &local_exec_config, &repo_config); std::string test_content("test"); - auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content); + auto test_digest = ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), test_content); std::string output_path{"output_file"}; std::vector<std::string> const cmdline = { @@ -231,7 +233,8 @@ TEST_CASE("LocalExecution: One input copied to output", "[execution_api]") { &storage_config.Get(), &storage, &local_exec_config, &repo_config); std::string test_content("test"); - auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content); + auto test_digest = ArtifactDigest::Create<ObjectType::File>( + HashFunction::Instance(), test_content); REQUIRE(api.Upload(ArtifactBlobContainer{{ArtifactBlob{ test_digest, test_content, /*is_exec=*/false}}}, false)); |