summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/execution_api/common/execution_api.hpp4
-rw-r--r--src/buildtool/execution_api/local/local_api.cpp5
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp3
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp5
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.hpp2
-rw-r--r--src/buildtool/execution_api/serve/TARGETS1
-rw-r--r--src/buildtool/execution_api/serve/mr_local_api.cpp5
-rw-r--r--src/buildtool/execution_api/serve/mr_local_api.hpp3
-rw-r--r--test/buildtool/execution_engine/executor/executor.test.cpp29
9 files changed, 45 insertions, 12 deletions
diff --git a/src/buildtool/execution_api/common/execution_api.hpp b/src/buildtool/execution_api/common/execution_api.hpp
index 1a2a0771..c8415764 100644
--- a/src/buildtool/execution_api/common/execution_api.hpp
+++ b/src/buildtool/execution_api/common/execution_api.hpp
@@ -26,6 +26,7 @@
#include "src/buildtool/common/artifact.hpp" // Artifact::ObjectInfo
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/artifact_blob.hpp"
#include "src/buildtool/execution_api/common/execution_action.hpp"
#include "src/buildtool/execution_engine/dag/dag.hpp"
@@ -152,6 +153,9 @@ class IExecutionApi {
[[nodiscard]] virtual auto BlobSpliceSupport() const noexcept -> bool {
return false;
}
+
+ [[nodiscard]] virtual auto GetHashType() const noexcept
+ -> HashFunction::Type = 0;
};
#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_COMMON_EXECUTION_APIHPP
diff --git a/src/buildtool/execution_api/local/local_api.cpp b/src/buildtool/execution_api/local/local_api.cpp
index ae59d3bc..bd8a51b6 100644
--- a/src/buildtool/execution_api/local/local_api.cpp
+++ b/src/buildtool/execution_api/local/local_api.cpp
@@ -28,7 +28,6 @@
#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/common/protocol_traits.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/bazel_msg/directory_tree.hpp"
#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/common/stream_dumper.hpp"
@@ -342,3 +341,7 @@ auto LocalApi::SpliceBlob(ArtifactDigest const& blob_digest,
}
return *std::move(splice_result);
}
+
+auto LocalApi::GetHashType() const noexcept -> HashFunction::Type {
+ return local_context_.storage_config->hash_function.GetType();
+}
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index 853b0622..c1e91c12 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -26,6 +26,7 @@
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/artifact_blob.hpp"
#include "src/buildtool/execution_api/common/execution_action.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
@@ -102,6 +103,8 @@ class LocalApi final : public IExecutionApi {
return true;
}
+ [[nodiscard]] auto GetHashType() const noexcept -> HashFunction::Type final;
+
private:
LocalContext const& local_context_;
std::optional<GitApi> const git_api_;
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index 2dfe07de..5511fcb1 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -603,3 +603,8 @@ auto BazelApi::CreateAction(
[[nodiscard]] auto BazelApi::BlobSpliceSupport() const noexcept -> bool {
return network_->BlobSpliceSupport();
}
+
+[[nodiscard]] auto BazelApi::GetHashType() const noexcept
+ -> HashFunction::Type {
+ return network_->GetHashFunction().GetType();
+}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
index 53445385..21e24c52 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
@@ -122,6 +122,8 @@ class BazelApi final : public IExecutionApi {
[[nodiscard]] auto BlobSpliceSupport() const noexcept -> bool final;
+ [[nodiscard]] auto GetHashType() const noexcept -> HashFunction::Type final;
+
private:
std::shared_ptr<BazelNetwork> network_;
diff --git a/src/buildtool/execution_api/serve/TARGETS b/src/buildtool/execution_api/serve/TARGETS
index cdf40c43..3e7777fd 100644
--- a/src/buildtool/execution_api/serve/TARGETS
+++ b/src/buildtool/execution_api/serve/TARGETS
@@ -27,6 +27,7 @@
, "deps":
[ ["@", "gsl", "", "gsl"]
, ["src/buildtool/common", "common"]
+ , ["src/buildtool/crypto", "hash_function"]
, ["src/buildtool/execution_api/common", "artifact_blob"]
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/execution_api/local", "context"]
diff --git a/src/buildtool/execution_api/serve/mr_local_api.cpp b/src/buildtool/execution_api/serve/mr_local_api.cpp
index d9364a4e..3394c270 100644
--- a/src/buildtool/execution_api/serve/mr_local_api.cpp
+++ b/src/buildtool/execution_api/serve/mr_local_api.cpp
@@ -147,3 +147,8 @@ auto MRLocalApi::GetMissingDigests(
}
return compat_local_api_->GetMissingDigests(digests);
}
+
+auto MRLocalApi::GetHashType() const noexcept -> HashFunction::Type {
+ return compat_local_api_ == nullptr ? native_local_api_->GetHashType()
+ : compat_local_api_->GetHashType();
+}
diff --git a/src/buildtool/execution_api/serve/mr_local_api.hpp b/src/buildtool/execution_api/serve/mr_local_api.hpp
index 815ad662..11a3cbb2 100644
--- a/src/buildtool/execution_api/serve/mr_local_api.hpp
+++ b/src/buildtool/execution_api/serve/mr_local_api.hpp
@@ -25,6 +25,7 @@
#include "gsl/gsl"
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/artifact_blob.hpp"
#include "src/buildtool/execution_api/common/execution_action.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
@@ -130,6 +131,8 @@ class MRLocalApi final : public IExecutionApi {
std::unordered_set<ArtifactDigest> const& digests) const noexcept
-> std::unordered_set<ArtifactDigest> final;
+ [[nodiscard]] auto GetHashType() const noexcept -> HashFunction::Type final;
+
private:
// retain local context references to have direct access to storages
gsl::not_null<LocalContext const*> native_context_;
diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp
index 891c8198..5a72c87b 100644
--- a/test/buildtool/execution_engine/executor/executor.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor.test.cpp
@@ -178,8 +178,9 @@ class TestAction : public IExecutionAction {
/// \brief Mockup Api, use config to create action and handle artifact upload
class TestApi : public IExecutionApi {
public:
- explicit TestApi(TestApiConfig config) noexcept
- : config_{std::move(config)} {}
+ explicit TestApi(TestApiConfig config,
+ HashFunction::Type hash_type) noexcept
+ : config_{std::move(config)}, hash_type_{hash_type} {}
[[nodiscard]] auto CreateAction(
ArtifactDigest const& /*unused*/,
@@ -263,8 +264,14 @@ class TestApi : public IExecutionApi {
return result;
}
+ [[nodiscard]] auto GetHashType() const noexcept
+ -> HashFunction::Type final {
+ return hash_type_;
+ }
+
private:
TestApiConfig config_{};
+ HashFunction::Type hash_type_;
};
[[nodiscard]] auto SetupConfig(std::filesystem::path const& ws)
@@ -334,7 +341,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
.exec_config = &remote_config};
SECTION("Processing succeeds for valid config") {
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -352,7 +359,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
SECTION("Processing fails if uploading local artifact failed") {
config.artifacts[NamedDigest("local.cpp").hash()].uploads = false;
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -370,7 +377,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
SECTION("Processing fails if known artifact is not available") {
config.artifacts[NamedDigest("known.cpp").hash()].available = false;
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -417,7 +424,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
.exec_config = &remote_config};
SECTION("Processing succeeds for valid config") {
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -438,7 +445,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing succeeds even if result was is not cached") {
config.response.cached = false;
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -459,7 +466,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing succeeds even if output is not available in CAS") {
config.artifacts[NamedDigest("output2.exe").hash()].available = false;
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -483,7 +490,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing fails if execution failed") {
config.execution.failed = true;
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -504,7 +511,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing fails if exit code is non-zero") {
config.response.exit_code = 1;
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);
@@ -528,7 +535,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing fails if any output is missing") {
config.execution.outputs = {"output1.exe" /*, "output2.exe"*/};
- auto api = std::make_shared<TestApi>(config);
+ auto api = std::make_shared<TestApi>(config, hash_function.GetType());
Statistics stats{};
Progress progress{};
auto const apis = CreateTestApiBundle(hash_function, api);