diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-12 16:09:28 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-16 17:51:12 +0200 |
commit | 62d204ff4cc94c12c1635f189255710901682825 (patch) | |
tree | 0c5cdc5faf98d28ddf74721280756804a6decf83 /test/buildtool/graph_traverser/graph_traverser_remote.test.cpp | |
parent | de3ef374983d987d8ffd8e8516a4877fe68b3e4e (diff) | |
download | justbuild-62d204ff4cc94c12c1635f189255710901682825.tar.gz |
Remove the RemoteExecutionConfig singleton
...and replace it with passed instances created early via a builder
pattern.
Tests are also updated accordingly.
Diffstat (limited to 'test/buildtool/graph_traverser/graph_traverser_remote.test.cpp')
-rw-r--r-- | test/buildtool/graph_traverser/graph_traverser_remote.test.cpp | 124 |
1 files changed, 90 insertions, 34 deletions
diff --git a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp index 5fa3bc95..504b96a1 100644 --- a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp +++ b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp @@ -18,8 +18,10 @@ #include "src/buildtool/storage/storage.hpp" #include "test/buildtool/graph_traverser/graph_traverser.test.hpp" #include "test/utils/remote_execution/test_auth_config.hpp" +#include "test/utils/remote_execution/test_remote_config.hpp" -[[nodiscard]] static auto CreateConfig() -> StorageConfig { +[[nodiscard]] static auto CreateStorageConfig( + RemoteExecutionConfig const& remote_config) -> StorageConfig { auto cache_dir = FileSystemManager::GetCurrentDirectory() / "cache"; if (not FileSystemManager::RemoveDirectory(cache_dir, true) or not FileSystemManager::CreateDirectoryExclusive(cache_dir)) { @@ -30,12 +32,11 @@ } StorageConfig::Builder builder; - auto config = - builder.SetBuildRoot(cache_dir) - .SetRemoteExecutionArgs(RemoteExecutionConfig::RemoteAddress(), - RemoteExecutionConfig::PlatformProperties(), - RemoteExecutionConfig::DispatchList()) - .Build(); + auto config = builder.SetBuildRoot(cache_dir) + .SetRemoteExecutionArgs(remote_config.remote_address, + remote_config.platform_properties, + remote_config.dispatch) + .Build(); if (not config) { Logger::Log(LogLevel::Error, config.error()); std::exit(EXIT_FAILURE); @@ -45,93 +46,148 @@ TEST_CASE("Remote: Output created and contents are correct", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); + auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestHelloWorldCopyMessage( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestHelloWorldCopyMessage(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Output created when entry point is local artifact", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestCopyLocalFile( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestCopyLocalFile(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Actions are not re-run", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestSequencePrinterBuildLibraryOnly( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestSequencePrinterBuildLibraryOnly(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: KNOWN artifact", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestHelloWorldWithKnownSource( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestHelloWorldWithKnownSource(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Blobs uploaded and correctly used", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestBlobsUploadedAndUsed( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestBlobsUploadedAndUsed(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Environment variables are set and used", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestEnvironmentVariablesSetAndUsed( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestEnvironmentVariablesSetAndUsed(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Trees correctly used", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestTreesUsed( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestTreesUsed(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Nested trees correctly used", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestNestedTreesUsed( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestNestedTreesUsed(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } TEST_CASE("Remote: Detect flaky actions", "[graph_traverser]") { - StorageConfig const storage_config = CreateConfig(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + + StorageConfig const storage_config = CreateStorageConfig(*remote_config); auto const storage = Storage::Create(&storage_config); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - TestFlakyHelloWorldDetected( - storage_config, storage, &*auth_config, false /* not hermetic */); + TestFlakyHelloWorldDetected(storage_config, + storage, + &*auth_config, + &*remote_config, + false /* not hermetic */); } |