Index generated reference handoffs
This commit is contained in:
@@ -3,6 +3,7 @@ package pipeline
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -106,6 +107,29 @@ func TestBuildStepReferenceSetsCanonicalizesAndClonesFanout(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildStepReferenceSetsIndexesManyOutputsForFanout(t *testing.T) {
|
||||
input, step, producerOutput := handoffFixture(t, codecNotes{Items: []string{"first"}})
|
||||
outputs := make([]contracts.SerializedOutput, 0, 65)
|
||||
for index := range 64 {
|
||||
outputs = append(outputs, contracts.SerializedOutput{StepID: fmt.Sprintf("unrelated-step-%d", index), LaneID: "unrelated-lane"})
|
||||
}
|
||||
outputs = append(outputs, producerOutput)
|
||||
|
||||
sets, provenance, err := buildStepReferenceSets(input, step, outputs)
|
||||
if err != nil {
|
||||
t.Fatalf("buildStepReferenceSets() error = %v", err)
|
||||
}
|
||||
if len(sets) != 3 || len(provenance) != 3 {
|
||||
t.Fatalf("reference sets/provenance = %d/%d, want 3/3", len(sets), len(provenance))
|
||||
}
|
||||
for target, set := range sets {
|
||||
item := set.Slots["producer-output"].Items[0]
|
||||
if item.Producer.StepID != "step-1" || item.Producer.LaneID != "notes" || string(item.Content) == "" {
|
||||
t.Fatalf("target %v item = %#v, want canonical producer artifact", target, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGeneratedReferenceAcceptsTypedEmptyCollection(t *testing.T) {
|
||||
input, step, producerOutput := handoffFixture(t, codecNotes{})
|
||||
sets, _, err := buildStepReferenceSets(input, step, []contracts.SerializedOutput{producerOutput})
|
||||
@@ -128,6 +152,12 @@ func TestGeneratedReferenceRejectsInvalidProducerOutputsDeterministically(t *tes
|
||||
{name: "multiple", outputs: func(output contracts.SerializedOutput) []contracts.SerializedOutput {
|
||||
return []contracts.SerializedOutput{output, output}
|
||||
}, want: "exactly one is required"},
|
||||
{name: "multiple after identifier normalization", outputs: func(output contracts.SerializedOutput) []contracts.SerializedOutput {
|
||||
duplicate := contracts.CloneSerializedOutput(output)
|
||||
duplicate.StepID = " step-1 "
|
||||
duplicate.LaneID = " notes "
|
||||
return []contracts.SerializedOutput{output, duplicate}
|
||||
}, want: "producer has 2 accepted normalized outputs; exactly one is required"},
|
||||
{name: "kind mismatch", outputs: func(output contracts.SerializedOutput) []contracts.SerializedOutput {
|
||||
return []contracts.SerializedOutput{output}
|
||||
}, mutate: func(target *ResolvedReferenceTarget, _ *contracts.SerializedOutput) {
|
||||
@@ -167,6 +197,17 @@ func TestGeneratedReferenceRejectsInvalidProducerOutputsDeterministically(t *tes
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexGeneratedOutputs(b *testing.B) {
|
||||
outputs := make([]contracts.SerializedOutput, 0, 1024)
|
||||
for index := range 1024 {
|
||||
outputs = append(outputs, contracts.SerializedOutput{StepID: fmt.Sprintf("step-%d", index), LaneID: fmt.Sprintf("lane-%d", index)})
|
||||
}
|
||||
b.ResetTimer()
|
||||
for range b.N {
|
||||
_ = indexGeneratedOutputs(outputs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGeneratedReferenceFingerprintChangesWithCanonicalContent(t *testing.T) {
|
||||
input, step, first := handoffFixture(t, codecNotes{Items: []string{"first"}})
|
||||
firstSets, _, err := buildStepReferenceSets(input, step, []contracts.SerializedOutput{first})
|
||||
|
||||
Reference in New Issue
Block a user