mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
ci: use neutral public model names in trace examples
This commit is contained in:
1 parent
aedd3002bd
commit
81526e5525
3 files changed
+30
-24
No files matched your search
+7
-1
@@ -8,12 +8,18 @@ path and `Module.Action`. Repeat a path to list alternative actions that
|
||||
cover it. Paths are case-sensitive; directories and glob patterns are not
|
||||
expanded. Missing, empty or malformed mappings refuse the check.
|
||||
|
||||
The reviewed map uses the neutral public module names: `SnapshotRemoval`,
|
||||
`RestoreTarget`, `EngineAdapter`, `StopAndRestart` and `MoveAdmission`.
|
||||
Actions name top-level definitions used by the corresponding model's `Next`.
|
||||
The mapping is the source of accepted citations; private model names and
|
||||
storage locations do not belong in the public map or PR description.
|
||||
|
||||
For every changed mapped path, including deletions, the PR's `Model:` line
|
||||
must contain a listed action or `NONE (pure function of Module)` for that
|
||||
module. Separate multiple citations with semicolons, for example:
|
||||
|
||||
```text
|
||||
Model: Snapshot.Begin; Lease.Renew; NONE (pure function of Codec)
|
||||
Model: EngineAdapter.Begin; MoveAdmission.Revoke; NONE (pure function of RestoreTarget)
|
||||
```
|
||||
|
||||
Unmapped paths keep the existing spec-trace policy. The pure-function
|
||||
|
||||
+15
-15
@@ -13,24 +13,24 @@ spec.loader.exec_module(checker)
|
||||
|
||||
|
||||
class ModelTraceTests(unittest.TestCase):
|
||||
mapping = {"core/a.go": {"Kernel.Begin", "Kernel.Commit"}, "core/b.go": {"Lease.Renew"}}
|
||||
mapping = {"core/a.go": {"EngineAdapter.Begin", "EngineAdapter.NoOpCut"}, "core/b.go": {"MoveAdmission.Revoke"}}
|
||||
|
||||
def test_each_mapped_file_needs_its_own_citation(self):
|
||||
problems = checker.check("Kernel.Begin", ["core/a.go", "core/b.go"], self.mapping)
|
||||
problems = checker.check("EngineAdapter.Begin", ["core/a.go", "core/b.go"], self.mapping)
|
||||
self.assertEqual(len(problems), 1)
|
||||
self.assertIn("core/b.go", problems[0])
|
||||
self.assertEqual(checker.check("Kernel.Begin; Lease.Renew", list(self.mapping), self.mapping), [])
|
||||
self.assertEqual(checker.check("EngineAdapter.Begin; MoveAdmission.Revoke", list(self.mapping), self.mapping), [])
|
||||
|
||||
def test_mapped_file_refuses_free_text_wrong_actions_and_lookalikes(self):
|
||||
for model in ("exhausted", "Kernel.Unknown", "Other.Begin", "Kernel.BeginExtra",
|
||||
"docs/Kernel.Begin", "example: Kernel.Begin", "NONE: no state changes",
|
||||
"NONE (pure function of Other)", "NONE (pure function of Kernel) extra"):
|
||||
for model in ("exhausted", "EngineAdapter.Unknown", "Other.Begin", "EngineAdapter.BeginExtra",
|
||||
"docs/EngineAdapter.Begin", "example: EngineAdapter.Begin", "NONE: no state changes",
|
||||
"NONE (pure function of Other)", "NONE (pure function of EngineAdapter) extra"):
|
||||
with self.subTest(model=model):
|
||||
self.assertEqual(len(checker.check(model, ["core/a.go"], self.mapping)), 1)
|
||||
|
||||
def test_pure_function_exception_is_module_specific(self):
|
||||
self.assertEqual(checker.check("NONE (pure function of Kernel)", ["core/a.go"], self.mapping), [])
|
||||
self.assertEqual(len(checker.check("NONE (pure function of Kernel)", ["core/b.go"], self.mapping)), 1)
|
||||
self.assertEqual(checker.check("NONE (pure function of EngineAdapter)", ["core/a.go"], self.mapping), [])
|
||||
self.assertEqual(len(checker.check("NONE (pure function of EngineAdapter)", ["core/b.go"], self.mapping)), 1)
|
||||
|
||||
def test_unmapped_files_keep_existing_policy(self):
|
||||
self.assertEqual(checker.check("existing prose", ["docs/a.md", "core/a.go.bak"], self.mapping), [])
|
||||
@@ -38,23 +38,23 @@ class ModelTraceTests(unittest.TestCase):
|
||||
def test_cli_checks_nul_paths_and_model_citations(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
mapping = Path(tmp) / "map.tsv"
|
||||
mapping.write_text("# exact paths\ncore/a.go\tKernel.Begin\n", encoding="utf-8")
|
||||
mapping.write_text("# exact paths\ncore/a.go\tEngineAdapter.Begin\n", encoding="utf-8")
|
||||
def run(model, paths):
|
||||
return subprocess.run([sys.executable, str(SCRIPT), str(mapping), model],
|
||||
input=paths, capture_output=True).returncode
|
||||
self.assertEqual(run("Kernel.Begin", b"core/a.go\0"), 0)
|
||||
self.assertEqual(run("EngineAdapter.Begin", b"core/a.go\0"), 0)
|
||||
self.assertEqual(run("unstructured prose", b"core/a.go\0"), 1)
|
||||
self.assertEqual(run("Kernel.Begin", b"core/a.go"), 2)
|
||||
self.assertEqual(run("Kernel.Begin", b"\0"), 2)
|
||||
self.assertEqual(run("EngineAdapter.Begin", b"core/a.go"), 2)
|
||||
self.assertEqual(run("EngineAdapter.Begin", b"\0"), 2)
|
||||
|
||||
def test_mapping_refuses_missing_empty_and_malformed_data(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
mapping = Path(tmp) / "map.tsv"
|
||||
with self.assertRaises(OSError):
|
||||
checker.read_mapping(mapping)
|
||||
for content in ("# not populated\n", "core/a.go Kernel.Begin\n",
|
||||
"../core/a.go\tKernel.Begin\n", "core//a.go\tKernel.Begin\n",
|
||||
"core/a.go\tKernel\n", "core/a.go\tKernel.Begin extra\n"):
|
||||
for content in ("# not populated\n", "core/a.go EngineAdapter.Begin\n",
|
||||
"../core/a.go\tEngineAdapter.Begin\n", "core//a.go\tEngineAdapter.Begin\n",
|
||||
"core/a.go\tKernel\n", "core/a.go\tEngineAdapter.Begin extra\n"):
|
||||
with self.subTest(content=content):
|
||||
mapping.write_text(content, encoding="utf-8")
|
||||
with self.assertRaises(ValueError):
|
||||
|
||||
+8
-8
@@ -136,16 +136,16 @@ expect_map() {
|
||||
fail=1
|
||||
fi
|
||||
}
|
||||
printf 'core/x/s.go\tKernel.Begin\ncore/y/s.go\tLease.Renew\n' >"$tmp/map.tsv"
|
||||
expect_map 0 "mapped action" "Kernel.Begin" M core/x/s.go
|
||||
expect_map 0 "mapped pure function" "NONE (pure function of Kernel)" M core/x/s.go
|
||||
expect_map 0 "all mapped modules cited" "Kernel.Begin; Lease.Renew" M core/x/s.go M core/y/s.go
|
||||
expect_map 1 "mapped file rejects old prose" "docs/spec/Kernel.tla, exhausted" M core/x/s.go
|
||||
printf 'core/x/s.go\tEngineAdapter.Begin\ncore/y/s.go\tMoveAdmission.Revoke\n' >"$tmp/map.tsv"
|
||||
expect_map 0 "mapped action" "EngineAdapter.Begin" M core/x/s.go
|
||||
expect_map 0 "mapped pure function" "NONE (pure function of EngineAdapter)" M core/x/s.go
|
||||
expect_map 0 "all mapped modules cited" "EngineAdapter.Begin; MoveAdmission.Revoke" M core/x/s.go M core/y/s.go
|
||||
expect_map 1 "mapped file rejects old prose" "docs/spec/EngineAdapter.tla, exhausted" M core/x/s.go
|
||||
expect_map 1 "deleted mapped file still needs model" "NONE: deletion has no new code" D core/x/s.go
|
||||
expect_map 1 "one citation cannot cover another module" "Kernel.Begin" M core/x/s.go M core/y/s.go
|
||||
expect_map 0 "unmapped file keeps old policy" "docs/spec/Kernel.tla, exhausted" M core/z/s.go
|
||||
expect_map 1 "one citation cannot cover another module" "EngineAdapter.Begin" M core/x/s.go M core/y/s.go
|
||||
expect_map 0 "unmapped file keeps old policy" "docs/spec/EngineAdapter.tla, exhausted" M core/z/s.go
|
||||
printf '# no canonical rows yet\n' >"$tmp/map.tsv"
|
||||
expect_map 2 "empty map is not silently disabled" "Kernel.Begin" M core/x/s.go
|
||||
expect_map 2 "empty map is not silently disabled" "EngineAdapter.Begin" M core/x/s.go
|
||||
|
||||
[[ $fail == 0 ]] && echo "spec-trace self-test: ok"
|
||||
exit $fail
|
||||
Reference in new issue
Block a user