A start writes the pipeline's key (watched branch, source revision, module) only when it is absent and says pipeline-started; a second start of the same revision and module writes nothing. A package-published asks the catalog's outdated for that package on that branch, a kept call, and starts a pipeline for each dependent behind by kind 1, keyed by the publication's branch and source revision. The start on take-in.taken, and a gathered group's one pipeline per branch, wait for take-in.taken's body (design 47 G §476, in review). Builds: design 47 G §54, §103, §334, §53, §75 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
89 lines
3.6 KiB
Go
89 lines
3.6 KiB
Go
package pipeline_test
|
|
|
|
import (
|
|
"os"
|
|
"slices"
|
|
"testing"
|
|
|
|
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshpipelinerunner"
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// TestManifest holds the runner's manifest to its design lines, row by row.
|
|
func TestManifest(t *testing.T) {
|
|
raw, err := os.ReadFile("module.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, err := catalogue.Decode(raw)
|
|
if err != nil {
|
|
t.Fatalf("the manifest does not read: %v", err)
|
|
}
|
|
var states, streams, objects []string
|
|
for _, s := range m.State {
|
|
states = append(states, s.Name)
|
|
}
|
|
for _, s := range m.Streams {
|
|
streams = append(streams, s.Name)
|
|
}
|
|
for _, o := range m.Objects {
|
|
objects = append(objects, o.Name)
|
|
}
|
|
var program catalogue.Artifact
|
|
if m.Build == nil {
|
|
t.Fatal("the manifest builds nothing")
|
|
}
|
|
for _, a := range m.Build.Artifacts {
|
|
if a.Name == "program" {
|
|
program = a
|
|
}
|
|
}
|
|
rows := []struct {
|
|
name string
|
|
ok bool
|
|
}{
|
|
// RN1/AC1 (§21): a foundation part asks no template; its kept data are in old sections.
|
|
{"no requires", len(m.Requires) == 0},
|
|
{"claims the seat serving every verb of its definition", len(m.Claims) == 1 && m.Claims[0].Name == seat.Seat &&
|
|
equalSets(m.Claims[0].Serves, seat.Verbs())},
|
|
// §27, §85, §330, §355, §77: the old state sections.
|
|
{"old state sections", equalSets(states, []string{seat.StatePipelines, seat.StateKept, "aged", "findings", "first-views"})},
|
|
// §27, §85: the step log on an old stream, its outputs in an old objects section.
|
|
// RN24 (§383, §387): beside it, the finding stream its findings are said on.
|
|
{"old streams section", equalSets(streams, []string{seat.StateStepLog, "mesh-delivery-pipeline-findings"})},
|
|
{"step-log 128 MiB", len(m.Streams) == 2 && m.Streams[0].MaxMiB == 128},
|
|
{"finding stream 7 days 16 MiB", len(m.Streams) == 2 && m.Streams[1].MaxAgeDays == 7 && m.Streams[1].MaxMiB == 16 &&
|
|
equalSets(m.Streams[1].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"})},
|
|
// RN24 (§368): the version as MAJOR.MINOR, 0.1 with none published.
|
|
{"version 0.1", m.Version == "0.1"},
|
|
{"old objects section", equalSets(objects, []string{seat.StateStepOutputs})},
|
|
{"step-outputs 1 GiB", len(m.Objects) == 1 && m.Objects[0].MaxMiB == 1024},
|
|
// §333, §54, §44, §53, §376, §24, §37, §4, §77: what the runner hears.
|
|
{"consumes", equalSets(m.Consumes, []string{
|
|
"mesh-delivery-indexer.take-in.taken", "mesh-builds.package-published", "mesh-builds.toolchain-agreed",
|
|
"operator-channel.decided", "node-build-go.step-ended", "node-build-node.step-ended",
|
|
"node-build-image.step-ended", "mesh-wants.step-ended", "mesh-catalog.registration-changed",
|
|
"mesh-catalog.catalog-revision", "mesh-conditions.findings-asked"})},
|
|
// RN2 (§21, §195, §200, §77): the registrations and the catalog half asked by their verbs, the first views read and
|
|
// asked again by hand (a hand act).
|
|
{"invokes", equalSets(m.Invokes, []string{"seat:mesh-catalog.registrations", "seat:mesh-catalog.revision", "seat:mesh-hand-acts.hand-act",
|
|
// RN3 (§53, §334): a publication's dependents behind.
|
|
"seat:mesh-catalog.outdated"})},
|
|
{"first-view tools", equalSets(m.Tools, []string{"pipeline_first_views", "pipeline_first_view_again"})},
|
|
// RN1/AC5 (§95, §130): the new assigner is delivered before the runner.
|
|
{"program needs the assigner's program", slices.Equal(program.Needs, []string{"mesh-delivery-assigner:program"})},
|
|
}
|
|
for _, r := range rows {
|
|
if !r.ok {
|
|
t.Errorf("%s: not as the design says", r.name)
|
|
}
|
|
}
|
|
}
|
|
|
|
func equalSets(a, b []string) bool {
|
|
x, y := slices.Clone(a), slices.Clone(b)
|
|
slices.Sort(x)
|
|
slices.Sort(y)
|
|
return slices.Equal(x, y)
|
|
}
|