Skip to content

Commit 6ca3cbf

Browse files
committed
Fix remote protocol unit tests
1 parent cfdcca6 commit 6ca3cbf

File tree

14 files changed

+177
-55
lines changed

14 files changed

+177
-55
lines changed

src/libstore-test-support/include/nix/store/tests/protocol.hh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,20 @@ public:
6969
}
7070
};
7171

72-
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
73-
TEST_F(FIXTURE, NAME##_read) \
74-
{ \
75-
readProtoTest(STEM, VERSION, VALUE); \
76-
} \
77-
TEST_F(FIXTURE, NAME##_write) \
78-
{ \
79-
writeProtoTest(STEM, VERSION, VALUE); \
72+
#define VERSIONED_READ_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
73+
TEST_F(FIXTURE, NAME##_read) \
74+
{ \
75+
readProtoTest(STEM, VERSION, VALUE); \
8076
}
8177

78+
#define VERSIONED_WRITE_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
79+
TEST_F(FIXTURE, NAME##_write) \
80+
{ \
81+
writeProtoTest(STEM, VERSION, VALUE); \
82+
}
83+
84+
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
85+
VERSIONED_READ_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
86+
VERSIONED_WRITE_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE)
87+
8288
} // namespace nix
360 Bytes
Binary file not shown.
160 Bytes
Binary file not shown.
176 Bytes
Binary file not shown.
96 Bytes
Binary file not shown.
424 Bytes
Binary file not shown.
160 Bytes
Binary file not shown.
176 Bytes
Binary file not shown.
96 Bytes
Binary file not shown.

src/libstore-tests/serve-protocol.cc

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ VERSIONED_CHARACTERIZATION_TEST(
7272

7373
VERSIONED_CHARACTERIZATION_TEST(
7474
ServeProtoTest,
75-
drvOutput,
75+
drvOutput_2_8,
7676
"drv-output-2.8",
7777
2 << 8 | 8,
7878
(std::tuple<DrvOutput, DrvOutput>{
@@ -90,7 +90,7 @@ VERSIONED_CHARACTERIZATION_TEST(
9090

9191
VERSIONED_CHARACTERIZATION_TEST(
9292
ServeProtoTest,
93-
unkeyedRealisation,
93+
unkeyedRealisation_2_8,
9494
"unkeyed-realisation-2.8",
9595
2 << 8 | 8,
9696
(UnkeyedRealisation{
@@ -100,7 +100,7 @@ VERSIONED_CHARACTERIZATION_TEST(
100100

101101
VERSIONED_CHARACTERIZATION_TEST(
102102
ServeProtoTest,
103-
realisation,
103+
realisation_2_8,
104104
"realisation-2.8",
105105
2 << 8 | 8,
106106
(Realisation{
@@ -156,8 +156,59 @@ VERSIONED_CHARACTERIZATION_TEST(ServeProtoTest, buildResult_2_3, "build-result-2
156156
t;
157157
}))
158158

159+
/* We now do a lossy read which does not allow us to faithfully right
160+
back, since we changed the data type. We still however want to test
161+
that this read works, and so for that we have a one-way test. */
162+
VERSIONED_READ_CHARACTERIZATION_TEST(
163+
ServeProtoTest, buildResult_2_6, "build-result-2.6", 2 << 8 | 6, ({
164+
using namespace std::literals::chrono_literals;
165+
std::tuple<BuildResult, BuildResult, BuildResult> t{
166+
BuildResult{
167+
.status = BuildResult::OutputRejected,
168+
.errorMsg = "no idea why",
169+
},
170+
BuildResult{
171+
.status = BuildResult::NotDeterministic,
172+
.errorMsg = "no idea why",
173+
.timesBuilt = 3,
174+
.isNonDeterministic = true,
175+
.startTime = 30,
176+
.stopTime = 50,
177+
},
178+
BuildResult{
179+
.status = BuildResult::Built,
180+
.timesBuilt = 1,
181+
.builtOutputs =
182+
{
183+
{
184+
"foo",
185+
{
186+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
187+
},
188+
},
189+
{
190+
"bar",
191+
{
192+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
193+
},
194+
},
195+
},
196+
.startTime = 30,
197+
.stopTime = 50,
198+
#if 0
199+
// These fields are not yet serialized.
200+
// FIXME Include in next version of protocol or document
201+
// why they are skipped.
202+
.cpuUser = std::chrono::milliseconds(500s),
203+
.cpuSystem = std::chrono::milliseconds(604s),
204+
#endif
205+
},
206+
};
207+
t;
208+
}))
209+
159210
VERSIONED_CHARACTERIZATION_TEST(
160-
ServeProtoTest, buildResult_2_6, "build-result-2.8", 2 << 8 | 8, ({
211+
ServeProtoTest, buildResult_2_8, "build-result-2.8", 2 << 8 | 8, ({
161212
using namespace std::literals::chrono_literals;
162213
std::tuple<BuildResult, BuildResult, BuildResult> t{
163214
BuildResult{

0 commit comments

Comments
 (0)