diff options
Diffstat (limited to 'test/buildtool/execution_api/bazel')
6 files changed, 56 insertions, 28 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}; |