mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
Merge note (batch b2r; pull_request_target spec-trace workflow has a startup_failure, so its checks run locally): - One Test run (47177109517) succeeded (go test (linux), process-level tests (real binaries)) on the integration tree f57965f8 = main f2bc730b + #1004 #1000 #995 #1001 in this order; these squash merges reproduce that tree, verified after the last one. - spec-trace-check.sh and public-text-check.sh, run with main's scripts against this head and body: both exit 0. - Code review ACCEPT on 0950de0d: the unit tests run in three parallel groups inside one job on one runner, any failing or hanging group fails the job, and cancellation is escalated per process group whether or not the group leader has exited.
53 lines
2.7 KiB
Python
53 lines
2.7 KiB
Python
"""Exact coverage before scope selection; old heavy-package rules afterward."""
|
|
import importlib.util
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
spec = importlib.util.spec_from_file_location("planner", Path(__file__).with_name("unit-test-shards.py"))
|
|
planner = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(planner)
|
|
MODULE = "example.invalid/product"
|
|
HEAVY = ("core/storage", "core/frontend/durable", "core/host/master", "core/authority")
|
|
|
|
|
|
class UnitShardTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.packages = [MODULE + "/" + p for p in (*HEAVY, "cmd/sw-block", "core/frontend/chunkstore", "internal/newpackage", "core/storage/child")]
|
|
self.groups = planner.partition(MODULE, self.packages)
|
|
|
|
def test_exact_cover_and_stable_order(self):
|
|
flat = [p for group in self.groups.values() for p in group]
|
|
self.assertCountEqual(flat, self.packages)
|
|
self.assertEqual(len(flat), len(set(flat)))
|
|
self.assertEqual(self.groups, planner.partition(MODULE, list(reversed(self.packages))))
|
|
self.assertEqual(self.groups["g1"], [MODULE + "/core/storage"])
|
|
self.assertEqual(self.groups["g2"], [MODULE + "/" + p for p in HEAVY[1:]])
|
|
self.assertIn(MODULE + "/internal/newpackage", self.groups["g3"])
|
|
self.assertIn(MODULE + "/core/storage/child", self.groups["g3"])
|
|
|
|
def test_existing_heavy_scope_on_main_train_and_prs(self):
|
|
all_changed = [p + "/changed.go" for p in HEAVY]
|
|
for event, ref in (("push", ""), ("pull_request", "train/next")):
|
|
selected = planner.select(MODULE, self.groups, event, ref, all_changed)
|
|
self.assertEqual(selected["g1"], [])
|
|
self.assertEqual(selected["g2"], [])
|
|
self.assertEqual(selected["g3"], self.groups["g3"])
|
|
self.assertEqual(planner.select(MODULE, self.groups, "pull_request", "fix/x", all_changed), self.groups)
|
|
for path in HEAVY:
|
|
selected = planner.select(MODULE, self.groups, "pull_request", "fix/x", [path + "/x.go"])
|
|
heavy = selected["g1"] + selected["g2"]
|
|
self.assertEqual(heavy, [MODULE + "/" + path])
|
|
nested = planner.select(MODULE, self.groups, "pull_request", "fix/x", ["core/storage/child/x.go", "core/storage/"])
|
|
self.assertEqual(nested["g1"], [])
|
|
self.assertEqual(nested["g2"], [])
|
|
self.assertEqual(nested["g3"], self.groups["g3"])
|
|
|
|
def test_invalid_inventory_is_refused(self):
|
|
for packages in ([], self.packages + [self.packages[0]], self.packages[1:], self.packages + ["other/pkg"]):
|
|
with self.subTest(packages=packages), self.assertRaises(ValueError):
|
|
planner.partition(MODULE, packages)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|