aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/libstore/worker-protocol.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 04:59:31 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 04:59:31 +0100
commit7f590ea7096d1e1bbbe73697358fef962d0fb494 (patch)
tree379ef50da30c3ff0b49df6ac1c28d3cfac7e0f69 /tests/unit/libstore/worker-protocol.cc
parent4d9dde15efbc05af471acb3efc5b04c087ceeef0 (diff)
Merge pull request #6223 from obsidiansystems/worker-proto-with-version
Give `nix daemon` and `nix-store --serve` protocols separate serializers with version info (cherry picked from commit 8b68bbb77745fda0d14939b6c23d31cc89da41ce) Change-Id: Ia3d3b9fbaf9f0ae62ab225020b7d14790e793655
Diffstat (limited to 'tests/unit/libstore/worker-protocol.cc')
-rw-r--r--tests/unit/libstore/worker-protocol.cc273
1 files changed, 263 insertions, 10 deletions
diff --git a/tests/unit/libstore/worker-protocol.cc b/tests/unit/libstore/worker-protocol.cc
index 6e7f47168..1389e2bac 100644
--- a/tests/unit/libstore/worker-protocol.cc
+++ b/tests/unit/libstore/worker-protocol.cc
@@ -69,10 +69,10 @@ VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
- derivedPath,
- "derived-path",
- defaultVersion,
- (std::tuple<DerivedPath, DerivedPath> {
+ derivedPath_1_29,
+ "derived-path-1.29",
+ 1 << 8 | 29,
+ (std::tuple<DerivedPath, DerivedPath, DerivedPath> {
DerivedPath::Opaque {
.path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
},
@@ -80,6 +80,38 @@ VERSIONED_CHARACTERIZATION_TEST(
.drvPath = makeConstantStorePathRef(StorePath {
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
}),
+ .outputs = OutputsSpec::All { },
+ },
+ DerivedPath::Built {
+ .drvPath = makeConstantStorePathRef(StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
+ }),
+ .outputs = OutputsSpec::Names { "x", "y" },
+ },
+ }))
+
+VERSIONED_CHARACTERIZATION_TEST(
+ WorkerProtoTest,
+ derivedPath_1_30,
+ "derived-path-1.30",
+ 1 << 8 | 30,
+ (std::tuple<DerivedPath, DerivedPath, DerivedPath, DerivedPath> {
+ DerivedPath::Opaque {
+ .path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
+ },
+ DerivedPath::Opaque {
+ .path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv" },
+ },
+ DerivedPath::Built {
+ .drvPath = makeConstantStorePathRef(StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
+ }),
+ .outputs = OutputsSpec::All { },
+ },
+ DerivedPath::Built {
+ .drvPath = makeConstantStorePathRef(StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
+ }),
.outputs = OutputsSpec::Names { "x", "y" },
},
}))
@@ -135,9 +167,77 @@ VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
- buildResult,
- "build-result",
- defaultVersion,
+ buildResult_1_27,
+ "build-result-1.27",
+ 1 << 8 | 27,
+ ({
+ using namespace std::literals::chrono_literals;
+ std::tuple<BuildResult, BuildResult, BuildResult> t {
+ BuildResult {
+ .status = BuildResult::OutputRejected,
+ .errorMsg = "no idea why",
+ },
+ BuildResult {
+ .status = BuildResult::NotDeterministic,
+ .errorMsg = "no idea why",
+ },
+ BuildResult {
+ .status = BuildResult::Built,
+ },
+ };
+ t;
+ }))
+
+VERSIONED_CHARACTERIZATION_TEST(
+ WorkerProtoTest,
+ buildResult_1_28,
+ "build-result-1.28",
+ 1 << 8 | 28,
+ ({
+ using namespace std::literals::chrono_literals;
+ std::tuple<BuildResult, BuildResult, BuildResult> t {
+ BuildResult {
+ .status = BuildResult::OutputRejected,
+ .errorMsg = "no idea why",
+ },
+ BuildResult {
+ .status = BuildResult::NotDeterministic,
+ .errorMsg = "no idea why",
+ },
+ BuildResult {
+ .status = BuildResult::Built,
+ .builtOutputs = {
+ {
+ "foo",
+ {
+ .id = DrvOutput {
+ .drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
+ .outputName = "foo",
+ },
+ .outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
+ },
+ },
+ {
+ "bar",
+ {
+ .id = DrvOutput {
+ .drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
+ .outputName = "bar",
+ },
+ .outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar" },
+ },
+ },
+ },
+ },
+ };
+ t;
+ }))
+
+VERSIONED_CHARACTERIZATION_TEST(
+ WorkerProtoTest,
+ buildResult_1_29,
+ "build-result-1.29",
+ 1 << 8 | 29,
({
using namespace std::literals::chrono_literals;
std::tuple<BuildResult, BuildResult, BuildResult> t {
@@ -194,9 +294,9 @@ VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
- keyedBuildResult,
- "keyed-build-result",
- defaultVersion,
+ keyedBuildResult_1_29,
+ "keyed-build-result-1.29",
+ 1 << 8 | 29,
({
using namespace std::literals::chrono_literals;
std::tuple<KeyedBuildResult, KeyedBuildResult/*, KeyedBuildResult*/> t {
@@ -231,6 +331,159 @@ VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
+ unkeyedValidPathInfo_1_15,
+ "unkeyed-valid-path-info-1.15",
+ 1 << 8 | 15,
+ (std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo> {
+ ({
+ UnkeyedValidPathInfo info {
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info;
+ }),
+ ({
+ UnkeyedValidPathInfo info {
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ };
+ info.deriver = StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
+ };
+ info.references = {
+ StorePath {
+ "g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv",
+ },
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info;
+ }),
+ }))
+
+VERSIONED_CHARACTERIZATION_TEST(
+ WorkerProtoTest,
+ validPathInfo_1_15,
+ "valid-path-info-1.15",
+ 1 << 8 | 15,
+ (std::tuple<ValidPathInfo, ValidPathInfo> {
+ ({
+ ValidPathInfo info {
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ UnkeyedValidPathInfo {
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ },
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info;
+ }),
+ ({
+ ValidPathInfo info {
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ UnkeyedValidPathInfo {
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ },
+ };
+ info.deriver = StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
+ };
+ info.references = {
+ // other reference
+ StorePath {
+ "g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo",
+ },
+ // self reference
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info;
+ }),
+ }))
+
+VERSIONED_CHARACTERIZATION_TEST(
+ WorkerProtoTest,
+ validPathInfo_1_16,
+ "valid-path-info-1.16",
+ 1 << 8 | 16,
+ (std::tuple<ValidPathInfo, ValidPathInfo, ValidPathInfo> {
+ ({
+ ValidPathInfo info {
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ UnkeyedValidPathInfo {
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ },
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info.ultimate = true;
+ info;
+ }),
+ ({
+ ValidPathInfo info {
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ UnkeyedValidPathInfo {
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ },
+ };
+ info.deriver = StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
+ };
+ info.references = {
+ // other reference
+ StorePath {
+ "g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo",
+ },
+ // self reference
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info.sigs = {
+ "fake-sig-1",
+ "fake-sig-2",
+ },
+ info;
+ }),
+ ({
+ ValidPathInfo info {
+ *LibStoreTest::store,
+ "foo",
+ FixedOutputInfo {
+ .method = FileIngestionMethod::Recursive,
+ .hash = hashString(HashType::htSHA256, "(...)"),
+ .references = {
+ .others = {
+ StorePath {
+ "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
+ },
+ },
+ .self = true,
+ },
+ },
+ Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
+ };
+ info.registrationTime = 23423;
+ info.narSize = 34878;
+ info;
+ }),
+ }))
+
+VERSIONED_CHARACTERIZATION_TEST(
+ WorkerProtoTest,
optionalTrustedFlag,
"optional-trusted-flag",
defaultVersion,