summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/bazel
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-21 12:52:19 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-03-24 09:25:05 +0100
commitfc0c842eb2e938c7de405e365ff320eb28e04bc7 (patch)
tree2fd4e62cec95b94b77643e89e8ff5a47e8ae7263 /test/buildtool/execution_api/bazel
parent82bfeff1389446f8743bd551f9833998eb7a1424 (diff)
downloadjustbuild-fc0c842eb2e938c7de405e365ff320eb28e04bc7.tar.gz
Pass TmpDir to BazelNetwork and BazelCasClient
Diffstat (limited to 'test/buildtool/execution_api/bazel')
-rw-r--r--test/buildtool/execution_api/bazel/TARGETS6
-rw-r--r--test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp23
-rw-r--r--test/buildtool/execution_api/bazel/bazel_network.test.cpp42
3 files changed, 42 insertions, 29 deletions
diff --git a/test/buildtool/execution_api/bazel/TARGETS b/test/buildtool/execution_api/bazel/TARGETS
index 230c6f48..c2898d1c 100644
--- a/test/buildtool/execution_api/bazel/TARGETS
+++ b/test/buildtool/execution_api/bazel/TARGETS
@@ -13,11 +13,12 @@
, ["@", "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/storage", "config"]
, ["@", "src", "src/utils/cpp", "expected"]
, ["utils", "catch-main-remote-execution"]
, ["utils", "test_auth_config"]
- , ["utils", "test_hash_function_type"]
, ["utils", "test_remote_config"]
+ , ["utils", "test_storage_config"]
]
, "stage": ["test", "buildtool", "execution_api", "bazel"]
}
@@ -88,12 +89,13 @@
, ["@", "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/storage", "config"]
, ["@", "src", "src/utils/cpp", "expected"]
, ["utils", "catch-main-remote-execution"]
, ["utils", "execution_bazel"]
, ["utils", "test_auth_config"]
- , ["utils", "test_hash_function_type"]
, ["utils", "test_remote_config"]
+ , ["utils", "test_storage_config"]
]
, "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 814de567..4b129920 100644
--- a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp
@@ -30,8 +30,9 @@
#include "src/buildtool/execution_api/remote/bazel/bazel_capabilities_client.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/file_system/object_type.hpp"
+#include "src/buildtool/storage/config.hpp"
#include "src/utils/cpp/expected.hpp"
-#include "test/utils/hermeticity/test_hash_function_type.hpp"
+#include "test/utils/hermeticity/test_storage_config.hpp"
#include "test/utils/remote_execution/test_auth_config.hpp"
#include "test/utils/remote_execution/test_remote_config.hpp"
@@ -39,6 +40,8 @@ TEST_CASE("Bazel internals: CAS Client", "[execution_api]") {
std::string instance_name{"remote-execution"};
std::string content("test");
+ auto const storage_config = TestStorageConfig::Create();
+
auto auth_config = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth_config);
@@ -51,18 +54,18 @@ TEST_CASE("Bazel internals: CAS Client", "[execution_api]") {
remote_config->remote_address->port,
&*auth_config,
&retry_config);
- BazelCasClient cas_client(remote_config->remote_address->host,
- remote_config->remote_address->port,
- &*auth_config,
- &retry_config,
- &capabilities);
+ BazelCasClient cas_client(
+ remote_config->remote_address->host,
+ remote_config->remote_address->port,
+ &*auth_config,
+ &retry_config,
+ &capabilities,
+ storage_config.Get().CreateTypedTmpDir("test_space"));
SECTION("Valid digest and blob") {
- // digest of "test"
- HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
// Valid blob
- auto const blob =
- ArtifactBlob::FromMemory(hash_function, ObjectType::File, content);
+ auto const blob = ArtifactBlob::FromMemory(
+ storage_config.Get().hash_function, ObjectType::File, content);
REQUIRE(blob.has_value());
// Search blob via digest
diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
index b902473b..6b8f7940 100644
--- a/test/buildtool/execution_api/bazel/bazel_network.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
@@ -36,8 +36,9 @@
#include "src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/file_system/object_type.hpp"
+#include "src/buildtool/storage/config.hpp"
#include "src/utils/cpp/expected.hpp"
-#include "test/utils/hermeticity/test_hash_function_type.hpp"
+#include "test/utils/hermeticity/test_storage_config.hpp"
#include "test/utils/remote_execution/test_auth_config.hpp"
#include "test/utils/remote_execution/test_remote_config.hpp"
@@ -46,6 +47,8 @@ constexpr std::size_t kLargeSize = GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH + 1;
TEST_CASE("Bazel network: write/read blobs", "[execution_api]") {
std::string instance_name{"remote-execution"};
+ auto const storage_config = TestStorageConfig::Create();
+
auto auth_config = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth_config);
@@ -55,15 +58,17 @@ TEST_CASE("Bazel network: write/read blobs", "[execution_api]") {
RetryConfig retry_config{}; // default retry config
- HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+ HashFunction const hash_function = storage_config.Get().hash_function;
- auto network = BazelNetwork{instance_name,
- remote_config->remote_address->host,
- remote_config->remote_address->port,
- &*auth_config,
- &retry_config,
- {},
- hash_function};
+ auto network =
+ BazelNetwork{instance_name,
+ remote_config->remote_address->host,
+ remote_config->remote_address->port,
+ &*auth_config,
+ &retry_config,
+ {},
+ hash_function,
+ storage_config.Get().CreateTypedTmpDir("test_space")};
std::string content_foo("foo");
std::string content_bar("bar");
@@ -107,7 +112,8 @@ TEST_CASE("Bazel network: write/read blobs", "[execution_api]") {
}
TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") {
- HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+ auto const storage_config = TestStorageConfig::Create();
+ HashFunction const hash_function = storage_config.Get().hash_function;
if (not ProtocolTraits::IsNative(hash_function.GetType())) {
// only supported in native mode
return;
@@ -124,13 +130,15 @@ TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") {
RetryConfig retry_config{}; // default retry config
- auto network = BazelNetwork{instance_name,
- remote_config->remote_address->host,
- remote_config->remote_address->port,
- &*auth_config,
- &retry_config,
- {},
- hash_function};
+ auto network =
+ BazelNetwork{instance_name,
+ remote_config->remote_address->host,
+ remote_config->remote_address->port,
+ &*auth_config,
+ &retry_config,
+ {},
+ hash_function,
+ storage_config.Get().CreateTypedTmpDir("test_space")};
std::string content_foo("foo");
std::string content_bar(kLargeSize, 'x'); // single larger blob