Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/conformance-fake-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
reindex-forgets reindex drops the ledger
silent nothing is ever answered

One value is not a defect of the server. It is a clock that was set back, and a run with
it must pass:

clock-back the wall clock reads an hour ahead at the first write, and is right at the next

Not part of the product: it exists to be imperfect on request.
"""

Expand Down Expand Up @@ -121,8 +126,11 @@ def __init__(self):

# ---- entries
def entries(self, kind=None):
"""The entries, newest first: the record grows only at its end, so that is the
order of the writes, last first. Not the order of `created`: a wall clock that
steps back (WSL2's does when it resyncs) dates a later write before an earlier one."""
es = [e for e in self.state["entries"] if kind is None or e["type"] == kind]
return sorted(es, key=lambda e: e["created"], reverse=True)
return es[::-1]

def hit(self, e, body=False):
h = {k: e[k] for k in ("id", "domain", "type", "title", "summary", "classification")}
Expand Down Expand Up @@ -167,6 +175,7 @@ def write(self, a):
if "body" not in a:
raise Refused("body is required")
self.state["seq"] += 1
ahead = 3600 if FLAW == "clock-back" and self.state["seq"] == 1 else 0
body = a["body"]
first = next((l for l in body.splitlines() if l.strip()), "")
e = {
Expand All @@ -177,7 +186,7 @@ def write(self, a):
"summary": a.get("summary") or first,
"body": body,
"author": "human:fake:owner",
"created": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) + f"{self.state['seq']:04d}",
"created": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(time.time() + ahead)),
"classification": "internal" if FLAW == "write-ignores-label" else a.get("classification") or "internal",
}
self.state["entries"].append(e)
Expand Down
4 changes: 4 additions & 0 deletions scripts/conformance.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ run() {

run whole '' --operator "python3 $fake operator" --drop-index "python3 $fake operator drop-index"
run surface ''
run clock-back clock-back --operator "python3 $fake operator" --drop-index "python3 $fake operator drop-index"
run missing-tool missing-tool --operator "python3 $fake operator"
run write-ignores-label write-ignores-label
run t0-forgets t0-forgets --operator "python3 $fake operator"
Expand Down Expand Up @@ -82,6 +83,9 @@ expect() {
# a conformant server passes, whole and surface-only
expect whole 0 '7 of 7 steps passed'
expect surface 0 '5 of 7 steps passed; not run: 6, 7'
# and so does one whose wall clock was set back between two writes: a list is in the order
# of the writes, whatever times the entries carry
expect clock-back 0 '7 of 7 steps passed'
# and each defect is reported at the step whose claim it breaks, the rest still running
expect missing-tool 1 '6 of 7 steps passed; FAILED: 1' 'tools/list lacks heartbeat'
expect write-ignores-label 1 '1 of 7 steps passed; not run: 6, 7; could not run: 3, 4, 5; FAILED: 2' "write at public came back 'internal'"
Expand Down
Loading