summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/bazel/bazel_ac_client.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_ac_client.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_ac_client.test.cpp')
-rw-r--r--test/buildtool/execution_api/bazel/bazel_ac_client.test.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_ac_client.test.cpp b/test/buildtool/execution_api/bazel/bazel_ac_client.test.cpp
new file mode 100644
index 00000000..4a352a8e
--- /dev/null
+++ b/test/buildtool/execution_api/bazel/bazel_ac_client.test.cpp
@@ -0,0 +1,50 @@
+#include <string>
+
+#include "catch2/catch.hpp"
+#include "src/buildtool/execution_api/remote/bazel/bazel_ac_client.hpp"
+#include "src/buildtool/execution_api/remote/config.hpp"
+#include "test/utils/remote_execution/bazel_action_creator.hpp"
+#include "test/utils/test_env.hpp"
+
+auto CreateActionCacheEntry(BazelAcClient* ac_client,
+ std::string const& instance_name,
+ bazel_re::Digest const& action_id,
+ std::string const& output) {
+ bazel_re::ActionResult result{};
+ result.set_stdout_raw(output);
+ REQUIRE(ac_client->UpdateActionResult(instance_name, action_id, result, 1));
+}
+
+// IMPORTANT: we are hiding this test case because the version of buildbarn we
+// are currently using does not allow us to upload the action to the AC
+// directly. The test was not failing due to a similar action being updated by
+// another test (and lack of hermeticity), so it is better to disable it than to
+// have it fail if we change that other test or reset the buildbarn server and
+// run only the current test case. See issue#30 in
+// https://rnd-gitlab-eu-c.huawei.com/germany-research-center/intelligent-cloud-technologies-laboratory/9424510-devcloud-build-tool-technology-project-de/-/issues/30
+TEST_CASE("Bazel internals: AC Client", "[!hide][execution_api]") {
+ auto const& info = RemoteExecutionConfig::Instance();
+
+ BazelAcClient ac_client(info.Host(), info.Port());
+
+ std::string instance_name{"remote-execution"};
+ std::string content("test");
+ auto test_digest = ArtifactDigest::Create(content);
+
+ auto action_id = CreateAction(instance_name,
+ {"echo", "-n", content},
+ {},
+ ReadPlatformPropertiesFromEnv());
+ REQUIRE(action_id);
+
+ // TODO(investigate): Upload fails due to permission issues. The BuildBarn
+ // revision we are currently using seems to ignore the
+ // 'allowAcUpdatesForInstances' setting.
+ CreateActionCacheEntry(&ac_client, instance_name, *action_id, content);
+
+ auto ac_result =
+ ac_client.GetActionResult(instance_name, *action_id, true, true, {});
+ REQUIRE(ac_result);
+ CHECK(std::equal_to<bazel_re::Digest>{}(ac_result->stdout_digest(),
+ test_digest));
+}