summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/bazel/bazel_network.test.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-22 17:03:21 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-22 17:03:21 +0100
commit619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 (patch)
tree01868de723cb82c86842f33743fa7b14e24c1fa3 /test/buildtool/execution_api/bazel/bazel_network.test.cpp
downloadjustbuild-619def44c1cca9f3cdf63544d5f24f2c7a7d9b77.tar.gz
Initial self-hosting commit
This is the initial version of our tool that is able to build itself. In can be bootstrapped by ./bin/bootstrap.py Co-authored-by: Oliver Reiche <oliver.reiche@huawei.com> Co-authored-by: Victor Moreno <victor.moreno1@huawei.com>
Diffstat (limited to 'test/buildtool/execution_api/bazel/bazel_network.test.cpp')
-rw-r--r--test/buildtool/execution_api/bazel/bazel_network.test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
new file mode 100644
index 00000000..6a668406
--- /dev/null
+++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
@@ -0,0 +1,45 @@
+#include <string>
+
+#include "catch2/catch.hpp"
+#include "src/buildtool/execution_api/remote/bazel/bazel_execution_client.hpp"
+#include "src/buildtool/execution_api/remote/bazel/bazel_network.hpp"
+#include "src/buildtool/execution_api/remote/config.hpp"
+
+constexpr std::size_t kLargeSize = GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH + 1;
+
+TEST_CASE("Bazel network: write/read blobs", "[execution_api]") {
+ auto const& info = RemoteExecutionConfig::Instance();
+ std::string instance_name{"remote-execution"};
+ auto network = BazelNetwork{instance_name, info.Host(), info.Port(), {}};
+
+ std::string content_foo("foo");
+ std::string content_bar("bar");
+ std::string content_baz(kLargeSize, 'x'); // single larger blob
+
+ BazelBlob foo{ArtifactDigest::Create(content_foo), content_foo};
+ BazelBlob bar{ArtifactDigest::Create(content_bar), content_bar};
+ BazelBlob baz{ArtifactDigest::Create(content_baz), content_baz};
+
+ // Search blobs via digest
+ REQUIRE(network.UploadBlobs(BlobContainer{{foo, bar, baz}}));
+
+ // Read blobs in order
+ auto reader = network.ReadBlobs(
+ {foo.digest, bar.digest, baz.digest, bar.digest, foo.digest});
+ std::vector<BazelBlob> blobs{};
+ while (true) {
+ auto next = reader.Next();
+ if (next.empty()) {
+ break;
+ }
+ blobs.insert(blobs.end(), next.begin(), next.end());
+ }
+
+ // Check order maintained
+ REQUIRE(blobs.size() == 5);
+ CHECK(blobs[0].data == content_foo);
+ CHECK(blobs[1].data == content_bar);
+ CHECK(blobs[2].data == content_baz);
+ CHECK(blobs[3].data == content_bar);
+ CHECK(blobs[4].data == content_foo);
+}