feat(registry,daemon): ETag downloads; report pending changes
This commit is contained in:
1 parent
fdfab9277b
commit
85ff7a8c75
8 files changed
+65
-3
No files matched your search
@@ -162,6 +162,7 @@ VOID_TEST(Daemon, lifecycle_ping_status_gc_shutdown_and_unknown_op) {
|
||||
Void::Testing::expect(int_field(*status_object, "pid") > 0);
|
||||
Void::Testing::expect(int_field(*status_object, "watched_directories") >= 1);
|
||||
Void::Testing::expect(int_field(*status_object, "sequence") >= 0);
|
||||
Void::Testing::expect(int_field(*status_object, "pending_changes") >= 0);
|
||||
|
||||
auto gc = Void::Build::Daemon::request(socket, R"({"op":"gc","max_bytes":0})");
|
||||
Void::Testing::require(gc.has_value());
|
||||
@@ -690,11 +691,17 @@ VOID_TEST(Daemon, watch_poll_reports_changed_paths) {
|
||||
std::jthread worker{[&] { run_result = server->run(); }};
|
||||
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
|
||||
|
||||
auto initial_status = request_object(socket, R"({"op":"status"})");
|
||||
Void::Testing::require(initial_status.has_value());
|
||||
Void::Testing::expect_eq(int_field(*initial_status, "pending_changes"), std::int64_t{0});
|
||||
|
||||
{
|
||||
std::ofstream probe{options.project_root / "probe.txt"};
|
||||
probe << "changed\n";
|
||||
Void::Testing::require(probe.good());
|
||||
}
|
||||
// Let every inotify event from the write queue up so one poll drains them all.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{50});
|
||||
|
||||
bool saw_probe = false;
|
||||
for (int attempt = 0; attempt < 100 && !saw_probe; ++attempt) {
|
||||
@@ -711,6 +718,10 @@ VOID_TEST(Daemon, watch_poll_reports_changed_paths) {
|
||||
}
|
||||
Void::Testing::expect(saw_probe);
|
||||
|
||||
auto drained_status = request_object(socket, R"({"op":"status"})");
|
||||
Void::Testing::require(drained_status.has_value());
|
||||
Void::Testing::expect_eq(int_field(*drained_status, "pending_changes"), std::int64_t{0});
|
||||
|
||||
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(shutdown.has_value());
|
||||
worker.join();
|
||||
|
||||
+16
-2
@@ -871,8 +871,22 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
|
||||
if (downloaded) {
|
||||
Void::Testing::expect(downloaded->body == artifact);
|
||||
}
|
||||
auto ranged =
|
||||
send_loopback_http(port, "GET", binary_path + "/download", {{"Range", "bytes=0-3"}});
|
||||
auto etag_head = send_loopback_http(port, "GET", binary_path + "/download");
|
||||
Void::Testing::expect(etag_head.has_value() && etag_head->status == 200);
|
||||
if (etag_head) {
|
||||
const auto etag_it = etag_head->headers.find("etag");
|
||||
Void::Testing::expect(etag_it != etag_head->headers.end());
|
||||
if (etag_it != etag_head->headers.end()) {
|
||||
auto cached = send_loopback_http(port, "GET", binary_path + "/download",
|
||||
{{"If-None-Match", etag_it->second}});
|
||||
Void::Testing::expect(cached.has_value() && cached->status == 304);
|
||||
if (cached) {
|
||||
Void::Testing::expect(cached->body.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
auto ranged = send_loopback_http(port, "GET", binary_path + "/download",
|
||||
{{"Range", "bytes=0-3"}});
|
||||
Void::Testing::expect(ranged.has_value() && ranged->status == 206);
|
||||
if (ranged) {
|
||||
Void::Testing::expect_eq(ranged->body, artifact.substr(0, 4));
|
||||
|
||||
Reference in new issue
Block a user