mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-28 13:44:03 +00:00
ci: enforce recovery object counts and require WAL samples in crash scrapes
A restart cell may set min_objects; it records the objects indexed at the kill and fails with exit 7 after its measurement when fewer were left. A crash scrape counts only when it holds the WAL sample its phase needs, and request totals keep only the S3 scheme. The store's comments name the constants as defaults of the configured limits. Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
@@ -74,9 +74,13 @@ scrape_metrics() {
|
||||
}
|
||||
|
||||
# A crash cycle cannot repeat a scrape once its server is killed, so it retries.
|
||||
# The named WAL sample must be in the scrape, or it does not count.
|
||||
scrape_retry() {
|
||||
local attempt
|
||||
for attempt in 1 2 3; do scrape_metrics && return 0; sleep 1; done
|
||||
local required=$1 attempt
|
||||
for attempt in 1 2 3; do
|
||||
scrape_metrics && grep -q "^greptime_logstore_object_store_wal_$required " "$dir/metrics$phase.prom" && return 0
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -121,6 +125,8 @@ restart() {
|
||||
local table count started deadline
|
||||
table=$(jq -er .table "$dir/greptimedb-1/load-result.json")
|
||||
scrape_metrics || { echo "$id: metrics scrape failed" >&2; exit 4; }
|
||||
# The objects recovery has to read are those still indexed at the kill.
|
||||
indexed_before_kill=$(awk '/^greptime_logstore_object_store_wal_indexed_objects / {print $2}' "$dir/metrics.prom")
|
||||
stop_server kill
|
||||
phase=-restart started=$(now)
|
||||
start_server
|
||||
@@ -134,6 +140,9 @@ restart() {
|
||||
done
|
||||
restart_query_seconds=$(elapsed "$started") restart_count=$count
|
||||
[[ "$count" == "$(jq .rows <<< "$spec")" ]] || { echo "$id: $count rows after restart" >&2; exit 5; }
|
||||
# The restart was measured, but on fewer objects than the cell asked for.
|
||||
awk -v n="${indexed_before_kill:-0}" -v min="$(jq -r '.min_objects // 0' <<< "$spec")" 'BEGIN {exit !(n >= min)}' \
|
||||
|| { echo "$id: ${indexed_before_kill:-no} objects indexed at the kill, fewer than min_objects" >&2; exit 7; }
|
||||
}
|
||||
|
||||
# Pins the WAL with one row in a second table before the writers start, if asked,
|
||||
@@ -172,7 +181,7 @@ crash_cycles() {
|
||||
for ((cycle = 1; cycle <= cycles; cycle++)); do
|
||||
cdir="$dir/cycle-$cycle" complete=true; mkdir -p "$cdir"
|
||||
# The counters of this server process before its writers start are the cycle's baseline.
|
||||
phase=-start-$cycle; scrape_retry || complete=false
|
||||
phase=-start-$cycle; scrape_retry indexed_objects || complete=false
|
||||
load_start=$(now_ns)
|
||||
python3 "$here/oswal-s3-bench-crash.py" write --dir "$cdir" --url "$sql_url" \
|
||||
--writers "$writers" --first-seq "$next" --rows "$rows" &
|
||||
@@ -180,7 +189,7 @@ crash_cycles() {
|
||||
if jq -e .pin <<< "$spec" >/dev/null; then sample_objects & spid=$!; fi
|
||||
delay=$(awk -v a="$kill_min" -v b="$kill_max" 'BEGIN {srand(); printf "%.3f", a + rand() * (b - a)}')
|
||||
sleep "$delay"
|
||||
phase=-cycle-$cycle; scrape_retry || complete=false
|
||||
phase=-cycle-$cycle; scrape_retry indexed_objects || complete=false
|
||||
before=$(now_ns); docker kill --signal KILL "$cid" >/dev/null; after=$(now_ns)
|
||||
wait "$wpid"
|
||||
if [[ -n "$spid" ]]; then kill "$spid" 2>/dev/null || true; wait "$spid" 2>/dev/null || true; spid=; fi
|
||||
@@ -193,7 +202,7 @@ crash_cycles() {
|
||||
sleep 0.2
|
||||
done
|
||||
query_s=$(elapsed "$started")
|
||||
scrape_retry || complete=false
|
||||
scrape_retry recovery_seconds_count || complete=false
|
||||
pin_count=null
|
||||
if jq -e .pin <<< "$spec" >/dev/null; then
|
||||
pin_count=$(sql "SELECT count(*) FROM pin" | jq -er '.output[0].records.rows[0][0]')
|
||||
@@ -230,6 +239,7 @@ finish() {
|
||||
--arg load_seconds "$load_seconds" --argjson exit_code "$rc" --argjson scraped "$metrics_scraped" \
|
||||
--argjson restart_scraped "$restart_scraped" --arg restart_seconds "$restart_seconds" \
|
||||
--arg restart_query_seconds "$restart_query_seconds" --arg restart_count "$restart_count" \
|
||||
--arg indexed_before_kill "$indexed_before_kill" \
|
||||
--arg server_cpu_seconds "$server_cpu_seconds" --arg host_cpu_busy "$host_cpu_busy" --arg host_cpus "$(nproc 2>/dev/null)" \
|
||||
'$spec + {wal_device: $device, version: $version, exit_code: $exit_code, metrics_scraped: $scraped,
|
||||
load_wall_seconds: ($load_seconds | tonumber? // null),
|
||||
@@ -237,7 +247,8 @@ finish() {
|
||||
host_cpu_busy: ($host_cpu_busy | tonumber? // null), host_cpus: ($host_cpus | tonumber? // null),
|
||||
restart_scraped: $restart_scraped, restart_seconds: ($restart_seconds | tonumber? // null),
|
||||
restart_query_seconds: ($restart_query_seconds | tonumber? // null),
|
||||
restart_count: ($restart_count | tonumber? // null)}' > "$dir/cell.json"
|
||||
restart_count: ($restart_count | tonumber? // null),
|
||||
indexed_before_kill: ($indexed_before_kill | tonumber? // null)}' > "$dir/cell.json"
|
||||
exit "$rc"
|
||||
}
|
||||
|
||||
@@ -248,6 +259,7 @@ cell() {
|
||||
: "${RUN_PREFIX:?}" "${WAL_ROOT:?}" "${S3_BUCKET:?}" "${S3_REGION:?}" "${AWS_ACCESS_KEY_ID:?}" "${AWS_SECRET_ACCESS_KEY:?}"
|
||||
spec=$1 cid= wal_dir= home_dir= version= load_seconds= metrics_scraped=false id= phase=
|
||||
restart_scraped=false restart_seconds= restart_query_seconds= restart_count= server_cpu_seconds= host_cpu_busy=
|
||||
indexed_before_kill=
|
||||
local concurrency setting started cpu_before host_before host_after
|
||||
id=$(jq -r .id <<< "$spec"); concurrency=$(jq -r .concurrency <<< "$spec")
|
||||
dir="$RESULTS/cells/$id" name="$OWNER-$id"
|
||||
|
||||
@@ -32,14 +32,15 @@ SAMPLE = re.compile(r'([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{([^}]*)\})?\s+(\S+)')
|
||||
|
||||
|
||||
def parse_metrics(text: str) -> dict:
|
||||
"""Map each unlabeled sample to its value, each histogram to its buckets, and the
|
||||
object store requests (data files and WAL together) to their count per operation."""
|
||||
"""Map each unlabeled sample to its value, each histogram to its buckets, and the S3
|
||||
requests (data files and WAL together) to their count per operation; the local cache
|
||||
stores report through the same layer under another scheme and are left out."""
|
||||
samples, buckets, requests = {}, {}, {}
|
||||
for line in text.splitlines():
|
||||
match = SAMPLE.fullmatch(line.strip())
|
||||
if match and match.group(1) == "opendal_operation_duration_seconds_count":
|
||||
operation = re.search(r'operation="([^"]+)"', match.group(2) or "")
|
||||
if operation:
|
||||
if operation and re.search(r'scheme="s3"', match.group(2) or ""):
|
||||
requests[operation.group(1)] = requests.get(operation.group(1), 0) + float(match.group(3))
|
||||
continue
|
||||
if not match or not match.group(1).startswith(PREFIX):
|
||||
@@ -153,6 +154,7 @@ def load_cell(path: Path, spec: dict | None = None) -> dict:
|
||||
"recovery_seconds": restarted["samples"].get("recovery_seconds_sum") if count == 1 else None,
|
||||
"recovered_objects": restarted["samples"].get("recovered_objects_total")
|
||||
if cell.get("restart_scraped") else None,
|
||||
"indexed_before_kill": cell.get("indexed_before_kill"), "min_objects": cell.get("min_objects", 0),
|
||||
}
|
||||
# The counters register on their first event, so a scrape of an object store WAL
|
||||
# that created objects omits the ones that never moved: those are zero, not unknown.
|
||||
@@ -296,13 +298,16 @@ def render(run: dict, rows: list, pairs: list) -> str:
|
||||
f"| {sum(s[1] is None for s in samples)} | {fmt(last[2])} | {fmt(last[3])} |")
|
||||
restarts = [r for r in rows if "restart" in r]
|
||||
if restarts:
|
||||
lines += ["", "| Cell | Overrides | Objects created | Restart to /health s | Restart to count s "
|
||||
lines += ["", "| Cell | Overrides | Objects created | Indexed at kill | Restart to /health s | Restart to count s "
|
||||
"| Recovery s | Recovered objects | Rows after restart |",
|
||||
"| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: |"]
|
||||
"| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |"]
|
||||
for r in restarts:
|
||||
x = r["restart"]
|
||||
short = x["min_objects"] and (x["indexed_before_kill"] or 0) < x["min_objects"]
|
||||
lines.append(" | ".join([
|
||||
f"| {r['id']}", overrides(r["env"]), fmt(r["created_objects_total"]), fmt(x["wall_seconds"], 2),
|
||||
f"| {label(r)}", overrides(r["env"]), fmt(r["created_objects_total"]),
|
||||
fmt(x["indexed_before_kill"]) + (f" (under {x['min_objects']:,})" if short else ""),
|
||||
fmt(x["wall_seconds"], 2),
|
||||
fmt(x["query_seconds"], 2), fmt(x["recovery_seconds"], 3), fmt(x["recovered_objects"]),
|
||||
f"{fmt(x['rows'])} |"]))
|
||||
lines += ["", "| Group | Concurrency | Ratio | Swept value | Per round | Geometric mean |",
|
||||
|
||||
@@ -168,7 +168,12 @@ def group_cells(group: dict, smoke: bool) -> list:
|
||||
if mode == "load":
|
||||
if not 0 <= idle <= 600:
|
||||
raise ValueError(f"group {name!r}: idle_seconds must be in 0..600")
|
||||
common |= {"rows": rows, "data_profile": DATA_PROFILES.get(rows, "custom")}
|
||||
# The objects a restart cell must leave indexed at its kill; a smoke run is too small for any.
|
||||
min_objects = int(group.get("min_objects", 0))
|
||||
if min_objects < 0 or (min_objects and not restart):
|
||||
raise ValueError(f"group {name!r}: min_objects needs restart and must not be negative")
|
||||
common |= {"rows": rows, "data_profile": DATA_PROFILES.get(rows, "custom"),
|
||||
"min_objects": 0 if smoke else min_objects}
|
||||
else:
|
||||
cycles = int(group.get("cycles", 5))
|
||||
kill_after = [int(v) for v in group.get("kill_after", [3, 10])]
|
||||
@@ -207,7 +212,7 @@ def parse_groups(text: str, defaults: dict) -> list:
|
||||
groups = json.loads(text)
|
||||
if not isinstance(groups, list) or not groups or not all(isinstance(g, dict) for g in groups):
|
||||
raise ValueError("groups must be a non-empty JSON list of objects")
|
||||
known = set(defaults) | {"name", "mode", "idle_seconds", "cycles", "kill_after", "pin"}
|
||||
known = set(defaults) | {"name", "mode", "idle_seconds", "cycles", "kill_after", "pin", "min_objects"}
|
||||
names = [g.get("name") for g in groups]
|
||||
for group, name in zip(groups, names):
|
||||
if not isinstance(name, str) or not GROUP_NAME.fullmatch(name):
|
||||
|
||||
@@ -175,13 +175,15 @@ impl Depths {
|
||||
/// Appends are admitted into an open batch. A background actor seals the batch
|
||||
/// when it reaches the size limit or the flush interval elapses and creates
|
||||
/// the object under the next sequence while it keeps admitting entries into
|
||||
/// the next batch; up to [`MAX_IN_FLIGHT_CREATES`] creates run at a time.
|
||||
/// the next batch; up to the store's create limit, [`MAX_IN_FLIGHT_CREATES`]
|
||||
/// by default, run at a time.
|
||||
/// Objects are indexed in the catalog in sequence order. In the `durable`
|
||||
/// acknowledgement mode an append returns once its object is durable and
|
||||
/// indexed, so an acknowledged entry never has a missing predecessor; in the
|
||||
/// `enqueued` mode it returns on admission and the object is created in the
|
||||
/// background. While [`MAX_SEALED_BATCHES`] batches
|
||||
/// wait to become durable no append is admitted. A segment that a read cannot
|
||||
/// background. While the store's sealed batch limit, [`MAX_SEALED_BATCHES`]
|
||||
/// by default, leaves room for fewer than two more batches no append is
|
||||
/// admitted. A segment that a read cannot
|
||||
/// decode is handled as `on_corrupted_segment` says. Objects below the reclaim
|
||||
/// boundary of the last indexed object are deleted in the background.
|
||||
pub struct ObjectStoreLogStore {
|
||||
@@ -1120,7 +1122,8 @@ type CreateOutcome = (u64, Result<PutResult>);
|
||||
/// durable.
|
||||
///
|
||||
/// Sealed batches form a pipeline in sequence order. A batch is created under
|
||||
/// its sequence as soon as one of [`MAX_IN_FLIGHT_CREATES`] slots is free, but
|
||||
/// its sequence as soon as one of the store's create slots, [`MAX_IN_FLIGHT_CREATES`]
|
||||
/// by default, is free, but
|
||||
/// it is indexed and acknowledged only once every earlier batch is, so the
|
||||
/// acknowledged history of a region never has a missing predecessor. Every
|
||||
/// batch links to its pipeline predecessor, the batch sealed before it, or to
|
||||
@@ -1144,7 +1147,8 @@ type CreateOutcome = (u64, Result<PutResult>);
|
||||
/// if they succeed.
|
||||
///
|
||||
/// Appends arrive on their own channel, which the actor does not read while
|
||||
/// [`MAX_SEALED_BATCHES`] batches wait or an append is held back at a backlog
|
||||
/// the sealed batch limit, [`MAX_SEALED_BATCHES`] by default, leaves room for
|
||||
/// fewer than two more batches or an append is held back at a backlog
|
||||
/// threshold of the `enqueued` mode, so commands such as `stop` are handled
|
||||
/// while admission is held back.
|
||||
///
|
||||
@@ -1504,7 +1508,7 @@ impl Actor {
|
||||
}
|
||||
|
||||
/// Starts the creates of pending batches in sequence order while fewer
|
||||
/// than [`MAX_IN_FLIGHT_CREATES`] are in flight, counting the creates of
|
||||
/// than the store's create limit are in flight, counting the creates of
|
||||
/// batches that already failed. Nothing starts once stop began, except
|
||||
/// the backlog of the `enqueued` mode.
|
||||
fn start_creates(&mut self) {
|
||||
@@ -2320,7 +2324,7 @@ struct FetchedObject {
|
||||
/// Rebuilds the catalog from object headers and footers,
|
||||
/// so recovery costs a few small reads per object however large the objects
|
||||
/// are. Segments are not read; a segment checksum is verified by the read that
|
||||
/// decodes it. Footers are fetched for up to [`RECOVERY_CONCURRENCY`] objects
|
||||
/// decodes it. Footers are fetched for up to `concurrency` objects
|
||||
/// at a time and indexed in sequence order, so the catalog checks the entry
|
||||
/// ranges of every object against its predecessors like a sequential replay.
|
||||
/// Only the objects on the chain [`select_chain`] picks are indexed.
|
||||
|
||||
@@ -160,6 +160,11 @@ class PlanTest(unittest.TestCase):
|
||||
pin = next(c for c in smoke["cells"] if c["group"] == "pin")
|
||||
self.assertEqual((pin["cycles"], pin["kill_after"]), (1, [60, 60]))
|
||||
self.assertEqual([c["rows"] for c in smoke["corpora"]], [50_000])
|
||||
recovery = [{"name": "rec", "configs": "D", "restart": True, "min_objects": 6000}]
|
||||
self.assertEqual(bench.build_plan("8", "4000000", "1000", "1", smoke=False,
|
||||
groups=json.dumps(recovery))["cells"][0]["min_objects"], 6000)
|
||||
self.assertEqual(bench.build_plan("8", "4000000", "1000", "1", smoke=True,
|
||||
groups=json.dumps(recovery))["cells"][0]["min_objects"], 0)
|
||||
|
||||
def test_the_workflow_passes_groups_through_bash_unchanged(self):
|
||||
workflow = (SCRIPTS.parent / "workflows" / "oswal-s3-bench.yml").read_text()
|
||||
@@ -178,7 +183,9 @@ class PlanTest(unittest.TestCase):
|
||||
[{"name": "a", "colour": "red"}], [{"name": "a", "mode": "crash", "configs": "R"}],
|
||||
[{"name": "a", "mode": "crash", "configs": "D", "restart": True}],
|
||||
[{"name": "a", "mode": "crash", "configs": "D", "kill_after": [9, 5]}],
|
||||
[{"name": "a", "mode": "soak"}], [{"name": "a", "idle_seconds": 601}]):
|
||||
[{"name": "a", "mode": "soak"}], [{"name": "a", "idle_seconds": 601}],
|
||||
[{"name": "a", "configs": "D", "min_objects": 6000}],
|
||||
[{"name": "a", "configs": "D", "restart": True, "min_objects": -1}]):
|
||||
with self.subTest(groups=groups), self.assertRaises(ValueError):
|
||||
bench.build_plan("8", "6000", "1000", "1", smoke=False, groups=json.dumps(groups))
|
||||
|
||||
@@ -371,7 +378,8 @@ class SummaryTest(unittest.TestCase):
|
||||
def test_sweep_ratios_cover_both_controls_and_restart_cells_report_recovery(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
restart = {"restart": True, "restart_scraped": True, "restart_seconds": 3.5,
|
||||
restart = {"restart": True, "restart_scraped": True, "restart_seconds": 3.5, "indexed_before_kill": 117,
|
||||
"min_objects": 6000,
|
||||
"restart_query_seconds": 4.25, "restart_count": 6000,
|
||||
"server_cpu_seconds": 122.0, "host_cpu_busy": 0.5, "host_cpus": 8}
|
||||
self.write_cell(root, "1-8-R", 100.0)
|
||||
@@ -387,10 +395,12 @@ class SummaryTest(unittest.TestCase):
|
||||
self.assertEqual(pairs, {("D/R", 2): 0.5, ("D/R0", 2): 0.4, ("D/R", 16): 0.75, ("D/R0", 16): 0.6})
|
||||
cell = next(r for r in rows if r["id"] == "1-8-D-2")
|
||||
self.assertEqual(cell["restart"], {"wall_seconds": 3.5, "query_seconds": 4.25, "rows": 6000,
|
||||
"recovery_seconds": 1.5, "recovered_objects": 118})
|
||||
"recovery_seconds": 1.5, "recovered_objects": 118,
|
||||
"indexed_before_kill": 117, "min_objects": 6000})
|
||||
self.assertEqual(cell["server_cpu_cores"], 2.0)
|
||||
output = summary.render({}, rows, summary.ratios(rows))
|
||||
self.assertIn("| 1-8-D-2 | MAX_IN_FLIGHT_CREATES=2 | 120 | 3.50 | 4.25 | 1.500 | 118 | 6,000 |", output)
|
||||
self.assertIn("| 1-8-D-2 | MAX_IN_FLIGHT_CREATES=2 | 120 | 117 (under 6,000) | 3.50 | 4.25 | 1.500 | 118 "
|
||||
"| 6,000 |", output)
|
||||
self.assertIn("| 2.00 | 50% of 8 |", output)
|
||||
self.assertIn("| 8 | D/R0 | 16 | 0.600 | 0.600 |", output)
|
||||
|
||||
@@ -429,7 +439,8 @@ class SummaryTest(unittest.TestCase):
|
||||
"greptime_logstore_object_store_wal_created_objects_total 5401\n"
|
||||
"greptime_logstore_object_store_wal_object_bytes_sum 10800000000\n"
|
||||
"greptime_logstore_object_store_wal_object_bytes_count 5400\n"
|
||||
'opendal_operation_duration_seconds_count{operation="write"} 9000\n')
|
||||
'opendal_operation_duration_seconds_count{scheme="s3",operation="write"} 9000\n'
|
||||
'opendal_operation_duration_seconds_count{scheme="fs",operation="write"} 70\n')
|
||||
(path / "metrics-restart-1.prom").write_text(
|
||||
"greptime_logstore_object_store_wal_recovery_seconds_sum 2.5\n"
|
||||
"greptime_logstore_object_store_wal_recovery_seconds_count 1\n"
|
||||
@@ -516,7 +527,11 @@ for arg in "$@"; do
|
||||
[[ "$arg" != */v1/sql* ]] || { echo "{\"output\": [{\"records\": {\"rows\": [[${FAKE_COUNT:-6000}]]}}]}"; exit 0; }
|
||||
[[ "$arg" != */metrics ]] || {
|
||||
[[ "$FAKE_METRICS_RC" == 0 ]] || exit "$FAKE_METRICS_RC"
|
||||
printf '%s\n' 'greptime_logstore_object_store_wal_poisoned_total 1' 'other_total 2'; exit 0;
|
||||
printf '%s\n' 'greptime_logstore_object_store_wal_poisoned_total 1' 'other_total 2'
|
||||
[[ -z "${FAKE_FULL_METRICS:-}" ]] || printf '%s\n' \
|
||||
"greptime_logstore_object_store_wal_indexed_objects $FAKE_FULL_METRICS" \
|
||||
'greptime_logstore_object_store_wal_recovery_seconds_count 1'
|
||||
exit 0;
|
||||
}
|
||||
done
|
||||
"""
|
||||
@@ -648,7 +663,7 @@ class CellLifecycleTest(unittest.TestCase): # the run script against fake docke
|
||||
self.assertEqual(log.count("/metrics"), 2)
|
||||
self.assertIn(f"type=bind,src={root}/corpus/corpus-6000,dst=/work/corpus,readonly", log)
|
||||
|
||||
def run_crash(self, root, metrics_rc=0, pin=False, sample_rc=0):
|
||||
def run_crash(self, root, metrics_rc=0, pin=False, sample_rc=0, full_metrics="5"):
|
||||
"""A crash cell against fake docker and a stub SQL endpoint that the fake kill takes down."""
|
||||
import http.server
|
||||
import threading
|
||||
@@ -682,7 +697,8 @@ class CellLifecycleTest(unittest.TestCase): # the run script against fake docke
|
||||
old = os.environ.copy()
|
||||
os.environ.update({"OSWAL_SQL_URL": f"http://127.0.0.1:{server.server_port}/v1/sql",
|
||||
"FAKE_KILL_FLAG": str(flag), "FAKE_FOUND": str(found), "FAKE_BATCH_ROWS": "1000",
|
||||
"OSWAL_SAMPLE_SECONDS": "0.2", "FAKE_SAMPLE_RC": str(sample_rc)})
|
||||
"OSWAL_SAMPLE_SECONDS": "0.2", "FAKE_SAMPLE_RC": str(sample_rc),
|
||||
"FAKE_FULL_METRICS": full_metrics})
|
||||
try:
|
||||
return self.run_cells(root, load_rc=0, metrics_rc=metrics_rc, groups=groups)
|
||||
finally:
|
||||
@@ -720,6 +736,32 @@ class CellLifecycleTest(unittest.TestCase): # the run script against fake docke
|
||||
self.assertIn("sql=INSERT INTO pin VALUES (1, 0)", log)
|
||||
self.assertEqual(len((cell / "cycles.jsonl").read_text().splitlines()), 2)
|
||||
|
||||
def test_a_scrape_without_the_wal_samples_is_incomplete(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
cells, _, _, _ = self.run_crash(root, full_metrics="")
|
||||
self.assertNotEqual(cells.returncode, 0)
|
||||
cell = root / "results" / "cells" / "crash-1-8-D"
|
||||
cycle = json.loads((cell / "cycles.jsonl").read_text().splitlines()[0])
|
||||
self.assertEqual((cycle["passed"], cycle["metrics_complete"]), (True, False))
|
||||
self.assertEqual(json.loads((cell / "cell.json").read_text())["exit_code"], 4)
|
||||
|
||||
def test_a_restart_cell_must_leave_its_minimum_objects_indexed(self):
|
||||
for minimum, exit_code in ((5, 0), (6, 7)):
|
||||
with self.subTest(minimum=minimum), tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
groups = json.dumps([{"name": "rec", "configs": "D", "restart": True, "min_objects": minimum}])
|
||||
old = os.environ.copy()
|
||||
os.environ["FAKE_FULL_METRICS"] = "5"
|
||||
try:
|
||||
cells, _, _, _ = self.run_cells(root, load_rc=0, groups=groups)
|
||||
finally:
|
||||
os.environ.clear()
|
||||
os.environ.update(old)
|
||||
recorded = json.loads((root / "results" / "cells" / "rec-1-8-D" / "cell.json").read_text())
|
||||
self.assertEqual((recorded["exit_code"], recorded["indexed_before_kill"], recorded["restart_count"]),
|
||||
(exit_code, 5, 6000))
|
||||
|
||||
def test_a_crash_cycle_without_its_scrapes_fails_the_cell(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
||||
Reference in New Issue
Block a user