Bring the checker's integration tests to what R4g decided: Go-only repository, echoed beside, readable kept (issue 1929)
mesh/delivery delivered
mesh/check pass cd3e55e05605 on fae4d48e09a5 | unit 0 run 483 kept | int 0 run 540 kept | clone 17s | composition passed on 3 machines
mesh/delivery delivered
mesh/check pass cd3e55e05605 on fae4d48e09a5 | unit 0 run 483 kept | int 0 run 540 kept | clone 17s | composition passed on 3 machines
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -81,6 +82,9 @@ type fakeBuildModules struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
calls map[string]int // by `<module>.<tool>`
|
calls map[string]int // by `<module>.<tool>`
|
||||||
testTool *testing.T
|
testTool *testing.T
|
||||||
|
// beside is, by workspace, the siblings the fetch placed in it as `<owner/repo> <commit>`, sorted: a digest echoes them
|
||||||
|
// (1929/AC2; mesh-sdk buildstep.besideOf), or the level runs whole and keeps nothing.
|
||||||
|
beside map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeBuildModules) count(tool string) int {
|
func (f *fakeBuildModules) count(tool string) int {
|
||||||
@@ -100,10 +104,30 @@ func (f *fakeBuildModules) result(t *testing.T, tool string, args map[string]any
|
|||||||
}
|
}
|
||||||
fetched := readCaptured(t, name)
|
fetched := readCaptured(t, name)
|
||||||
fetched["commit"], fetched["base"] = args["commit"], args["base"]
|
fetched["commit"], fetched["base"] = args["commit"], args["base"]
|
||||||
|
var refs []struct {
|
||||||
|
Repository string `json:"repository"`
|
||||||
|
Commit string `json:"commit"`
|
||||||
|
}
|
||||||
|
raw, _ := json.Marshal(args["beside"])
|
||||||
|
_ = json.Unmarshal(raw, &refs)
|
||||||
|
var lines []string
|
||||||
|
for _, r := range refs {
|
||||||
|
lines = append(lines, r.Repository+" "+r.Commit)
|
||||||
|
}
|
||||||
|
sort.Strings(lines)
|
||||||
|
f.mu.Lock()
|
||||||
|
if f.beside == nil {
|
||||||
|
f.beside = map[string][]string{}
|
||||||
|
}
|
||||||
|
f.beside[fmt.Sprint(fetched["workspace"])] = lines
|
||||||
|
f.mu.Unlock()
|
||||||
v = fetched
|
v = fetched
|
||||||
case strings.HasSuffix(tool, "_digest"):
|
case strings.HasSuffix(tool, "_digest"):
|
||||||
d := map[string]string{"unit": digU, "integration": digI}[level]
|
d := map[string]string{"unit": digU, "integration": digI}[level]
|
||||||
v = map[string]any{"level": level, "packages": map[string]string{"fixture/slow": d}}
|
f.mu.Lock()
|
||||||
|
beside := f.beside[fmt.Sprint(args["workspace"])]
|
||||||
|
f.mu.Unlock()
|
||||||
|
v = map[string]any{"level": level, "packages": map[string]string{"fixture/slow": d}, "beside": beside}
|
||||||
case strings.HasSuffix(tool, "_test"):
|
case strings.HasSuffix(tool, "_test"):
|
||||||
r := readCaptured(t, "go-test-slow")
|
r := readCaptured(t, "go-test-slow")
|
||||||
r["level"] = level
|
r["level"] = level
|
||||||
@@ -288,6 +312,15 @@ func startBed(t *testing.T) *bed {
|
|||||||
}
|
}
|
||||||
b.buckets[name] = kv
|
b.buckets[name] = kv
|
||||||
}
|
}
|
||||||
|
// 1929/AC1: the indexer's value of the repository's module, with no TypeScript manifest, so the Go build module alone
|
||||||
|
// judges the repository (an unknown repository is judged by both, issue 1887 A12).
|
||||||
|
known, err := delivery.EncodeModule(delivery.Module{Repository: repo, Commit: trunk, Path: "modules/m", None2: "the fingerprint is computed with its chain"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := b.buckets[delivery.ModulesBucket].Put(ctx, "m", known); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
b.setOnline(t, "n1", true)
|
b.setOnline(t, "n1", true)
|
||||||
for _, module := range []string{"mesh-build-go", "mesh-build-node"} {
|
for _, module := range []string{"mesh-build-go", "mesh-build-node"} {
|
||||||
b.setHealth(t, "n1", module)
|
b.setHealth(t, "n1", module)
|
||||||
@@ -436,7 +469,7 @@ func (b *bed) owed(t *testing.T, number int, head, state string) delivery.Owed {
|
|||||||
// TestCheckerJudgesACandidateAndOwesItsStatus: a candidate the indexer wrote, one pull request of mesh-delivery, is fetched
|
// TestCheckerJudgesACandidateAndOwesItsStatus: a candidate the indexer wrote, one pull request of mesh-delivery, is fetched
|
||||||
// merged onto the trunk the gate names, digested and tested at both levels on the node, kept, previewed; the verdict passes
|
// merged onto the trunk the gate names, digested and tested at both levels on the node, kept, previewed; the verdict passes
|
||||||
// with the counts of both levels and the composition not run, and the status mesh/check is owed on the head as success.
|
// with the counts of both levels and the composition not run, and the status mesh/check is owed on the head as success.
|
||||||
func TestCheckerJudgesACandidateAndOwesItsStatus(t *testing.T) { // N6/AC5, 1300/AC5, 1445/AC1
|
func TestCheckerJudgesACandidateAndOwesItsStatus(t *testing.T) { // N6/AC5, 1300/AC5, 1445/AC1, 1929/AC1
|
||||||
b := startBed(t)
|
b := startBed(t)
|
||||||
key := b.candidate(t, "feat/x", pull(repo, 7, head1))
|
key := b.candidate(t, "feat/x", pull(repo, 7, head1))
|
||||||
b.start(t, nil)
|
b.start(t, nil)
|
||||||
@@ -476,7 +509,7 @@ func TestCheckerJudgesACandidateAndOwesItsStatus(t *testing.T) { // N6/AC5, 1300
|
|||||||
|
|
||||||
// TestACheckOfEqualInputsRunsNothing: a second candidate (another head, the same digests) is checked with every package
|
// TestACheckOfEqualInputsRunsNothing: a second candidate (another head, the same digests) is checked with every package
|
||||||
// taken from the first's kept verdicts: no test step runs and no second kept key appears.
|
// taken from the first's kept verdicts: no test step runs and no second kept key appears.
|
||||||
func TestACheckOfEqualInputsRunsNothing(t *testing.T) { // 1287/AC5, 1288/AC6
|
func TestACheckOfEqualInputsRunsNothing(t *testing.T) { // 1287/AC5, 1288/AC6, 1929/AC2
|
||||||
b := startBed(t)
|
b := startBed(t)
|
||||||
first := b.candidate(t, "feat/x", pull(repo, 7, head1))
|
first := b.candidate(t, "feat/x", pull(repo, 7, head1))
|
||||||
b.start(t, nil)
|
b.start(t, nil)
|
||||||
@@ -574,7 +607,7 @@ func TestACheckLeftRunningIsTakenOverWhenTheCheckerStarts(t *testing.T) { // N6/
|
|||||||
|
|
||||||
// TestAMemberNamingAMeshSDKCommitOffTheTrunkFailsNamingTheCommit: the go.mod the forge answers names a commit that main does not
|
// TestAMemberNamingAMeshSDKCommitOffTheTrunkFailsNamingTheCommit: the go.mod the forge answers names a commit that main does not
|
||||||
// hold; the verdict fails naming the member and the commit and no test runs (ADR 0484 clause 9).
|
// hold; the verdict fails naming the member and the commit and no test runs (ADR 0484 clause 9).
|
||||||
func TestAMemberNamingAMeshSDKCommitOffTheTrunkFailsNamingTheCommit(t *testing.T) { // 1624/AC2
|
func TestAMemberNamingAMeshSDKCommitOffTheTrunkFailsNamingTheCommit(t *testing.T) { // 1624/AC2, 1929/AC3
|
||||||
b := startBed(t)
|
b := startBed(t)
|
||||||
b.stalePin.Store(true)
|
b.stalePin.Store(true)
|
||||||
key := b.candidate(t, "feat/x", pull(repo, 7, head1))
|
key := b.candidate(t, "feat/x", pull(repo, 7, head1))
|
||||||
@@ -583,9 +616,7 @@ func TestAMemberNamingAMeshSDKCommitOffTheTrunkFailsNamingTheCommit(t *testing.T
|
|||||||
if v.State != delivery.VerdictFail || !strings.Contains(v.Failed.Words, "9aaa5c80ac5c") || !strings.Contains(v.Failed.Words, repo+"#7") {
|
if v.State != delivery.VerdictFail || !strings.Contains(v.Failed.Words, "9aaa5c80ac5c") || !strings.Contains(v.Failed.Words, repo+"#7") {
|
||||||
t.Fatalf("verdict = %+v", v)
|
t.Fatalf("verdict = %+v", v)
|
||||||
}
|
}
|
||||||
if n := b.fake.count("mesh-build-go.build_go_test"); n != 0 {
|
// 1929/AC3: no assertion that no test ran: one ask runs fetch, digest and tests (ADR 0525 §3).
|
||||||
t.Errorf("%d test steps ran after a stale pin", n)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// triesStore is the tries bucket as the tools write it.
|
// triesStore is the tries bucket as the tools write it.
|
||||||
@@ -671,7 +702,7 @@ func TestTheCheckerSaysOwedReadableOnTheBus(t *testing.T) { // R2-1
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if said.Module != "mesh-delivery-checker" || said.Node != "n1" || !said.Keeps("owed") || !said.Readable("owed") ||
|
if said.Module != "mesh-delivery-checker" || said.Node != "n1" || !said.Keeps("owed") || !said.Readable("owed") ||
|
||||||
!said.Readable("previews") || !said.Readable("verdicts") || said.Readable("kept") || said.Readable("tries") || len(said.States) != 5 {
|
!said.Readable("previews") || !said.Readable("verdicts") || !said.Readable("kept") || said.Readable("tries") || len(said.States) != 5 {
|
||||||
t.Fatalf("the checker said %+v, want its five states with owed, previews and verdicts readable", said)
|
t.Fatalf("the checker said %+v, want its five states with kept, owed, previews and verdicts readable (1929/AC4; 1887 A5b)", said)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user