diff options
Diffstat (limited to 'test/buildtool/execution_api/bazel/bytestream_client.test.cpp')
-rw-r--r-- | test/buildtool/execution_api/bazel/bytestream_client.test.cpp | 124 |
1 files changed, 2 insertions, 122 deletions
diff --git a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp index c8b7cac6..03b70ae4 100644 --- a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp @@ -22,7 +22,6 @@ #include "src/buildtool/auth/authentication.hpp" #include "src/buildtool/common/bazel_digest_factory.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/config.hpp" #include "src/buildtool/file_system/object_type.hpp" @@ -30,8 +29,6 @@ #include "test/utils/remote_execution/test_auth_config.hpp" #include "test/utils/remote_execution/test_remote_config.hpp" -constexpr std::size_t kLargeSize = GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH + 1; - TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); @@ -90,6 +87,8 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { } SECTION("Upload large blob") { + static constexpr std::size_t kLargeSize = + GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH + 1; std::string instance_name{"remote-execution"}; std::string content(kLargeSize, '\0'); @@ -136,122 +135,3 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { } } } - -TEST_CASE("ByteStream Client: Transfer multiple blobs", "[execution_api]") { - auto auth_config = TestAuthConfig::ReadFromEnvironment(); - REQUIRE(auth_config); - - auto remote_config = TestRemoteConfig::ReadFromEnvironment(); - REQUIRE(remote_config); - REQUIRE(remote_config->remote_address); - - auto stream = ByteStreamClient{remote_config->remote_address->host, - remote_config->remote_address->port, - &*auth_config}; - auto uuid = CreateUUIDVersion4(*CreateProcessUniqueId()); - - HashFunction const hash_function{TestHashType::ReadFromEnvironment()}; - - SECTION("Upload small blobs") { - std::string instance_name{"remote-execution"}; - - BazelBlob foo{BazelDigestFactory::HashDataAs<ObjectType::File>( - hash_function, "foo"), - "foo", - /*is_exec=*/false}; - BazelBlob bar{BazelDigestFactory::HashDataAs<ObjectType::File>( - hash_function, "bar"), - "bar", - /*is_exec=*/false}; - BazelBlob baz{BazelDigestFactory::HashDataAs<ObjectType::File>( - hash_function, "baz"), - "baz", - /*is_exec=*/false}; - - CHECK(stream.WriteMany<BazelBlob>( - {foo, bar, baz}, - [&instance_name, &uuid](auto const& blob) { - return fmt::format("{}/uploads/{}/blobs/{}/{}", - instance_name, - uuid, - blob.digest.hash(), - blob.digest.size_bytes()); - }, - [](auto const& blob) { return *blob.data; })); - - SECTION("Download small blobs") { - std::vector<std::string> contents{}; - stream.ReadMany<bazel_re::Digest>( - {foo.digest, bar.digest, baz.digest}, - [&instance_name](auto const& digest) -> std::string { - return fmt::format("{}/blobs/{}/{}", - instance_name, - digest.hash(), - digest.size_bytes()); - }, - [&contents](auto data) { - contents.emplace_back(std::move(data)); - }); - REQUIRE(contents.size() == 3); - CHECK(contents[0] == *foo.data); - CHECK(contents[1] == *bar.data); - CHECK(contents[2] == *baz.data); - } - } - - SECTION("Upload large blobs") { - std::string instance_name{"remote-execution"}; - - std::string content_foo(kLargeSize, '\0'); - std::string content_bar(kLargeSize, '\0'); - std::string content_baz(kLargeSize, '\0'); - for (std::size_t i{}; i < content_foo.size(); ++i) { - content_foo[i] = instance_name[(i + 0) % instance_name.size()]; - content_bar[i] = instance_name[(i + 1) % instance_name.size()]; - content_baz[i] = instance_name[(i + 2) % instance_name.size()]; - } - - BazelBlob foo{BazelDigestFactory::HashDataAs<ObjectType::File>( - hash_function, content_foo), - content_foo, - /*is_exec=*/false}; - BazelBlob bar{BazelDigestFactory::HashDataAs<ObjectType::File>( - hash_function, content_bar), - content_bar, - /*is_exec=*/false}; - BazelBlob baz{BazelDigestFactory::HashDataAs<ObjectType::File>( - hash_function, content_baz), - content_baz, - /*is_exec=*/false}; - - CHECK(stream.WriteMany<BazelBlob>( - {foo, bar, baz}, - [&instance_name, &uuid](auto const& blob) { - return fmt::format("{}/uploads/{}/blobs/{}/{}", - instance_name, - uuid, - blob.digest.hash(), - blob.digest.size_bytes()); - }, - [](auto const& blob) { return *blob.data; })); - - SECTION("Download large blobs") { - std::vector<std::string> contents{}; - stream.ReadMany<bazel_re::Digest>( - {foo.digest, bar.digest, baz.digest}, - [&instance_name](auto const& digest) -> std::string { - return fmt::format("{}/blobs/{}/{}", - instance_name, - digest.hash(), - digest.size_bytes()); - }, - [&contents](auto data) { - contents.emplace_back(std::move(data)); - }); - REQUIRE(contents.size() == 3); - CHECK(contents[0] == *foo.data); - CHECK(contents[1] == *bar.data); - CHECK(contents[2] == *baz.data); - } - } -} |