test(landscape): make node-failure test deterministic under sibling cancellation
Scope the stub publisher failure to node 00's output; when every stage-0 publish failed, the first failing sibling cancelled node 00 and its recorded error was "context canceled" instead of the publish error. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -332,11 +332,15 @@ type stubPublisher struct {
|
|||||||
created []CreateRasterInput
|
created []CreateRasterInput
|
||||||
uploaded []UploadInput
|
uploaded []UploadInput
|
||||||
err error
|
err error
|
||||||
|
// errFilename, when set, scopes err to publishes of that output file only,
|
||||||
|
// so a test can fail exactly one node while its stage siblings succeed
|
||||||
|
// (a sibling failing first would cancel the node under test).
|
||||||
|
errFilename string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *stubPublisher) CreateRasterFromFile(ctx context.Context, in CreateRasterInput) (domain.Dataset, error) {
|
func (p *stubPublisher) CreateRasterFromFile(ctx context.Context, in CreateRasterInput) (domain.Dataset, error) {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
if p.err != nil {
|
if p.err != nil && (p.errFilename == "" || p.errFilename == in.Filename) {
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
return domain.Dataset{}, p.err
|
return domain.Dataset{}, p.err
|
||||||
}
|
}
|
||||||
@@ -1235,7 +1239,13 @@ func TestLandscapeService_Execute_NodeFailureFailsRunAndCleansUp(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "publishing the result fails",
|
name: "publishing the result fails",
|
||||||
arrange: func(f *lpFixture) { f.pub.err = errors.New("minio down") },
|
arrange: func(f *lpFixture) {
|
||||||
|
// Fail only node 00's output: if every stage-0 publish failed,
|
||||||
|
// whichever sibling failed first would cancel node 00 and its
|
||||||
|
// recorded error would be "context canceled" instead.
|
||||||
|
f.pub.err = errors.New("minio down")
|
||||||
|
f.pub.errFilename = landscape.OutZIntegrated + ".tif"
|
||||||
|
},
|
||||||
want: "minio down",
|
want: "minio down",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user