Say what a node's bucket holds when a served composition test waits in vain (issue 1945)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -225,10 +226,41 @@ func (m *servedMesh) waitFor(t *testing.T, done chan error, node, key string, af
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
t.Fatalf("%s in %s was not written within a minute", key, bucket)
|
||||
t.Fatalf("%s in %s was not written within a minute; %s", key, bucket, m.whatIsThere(t, node))
|
||||
return 0
|
||||
}
|
||||
|
||||
// whatIsThere says, for a failure, what the node's bucket holds, the ids its own composition carries and the
|
||||
// fingerprints the controller has registered.
|
||||
func (m *servedMesh) whatIsThere(t *testing.T, node string) string {
|
||||
t.Helper()
|
||||
bucket, _ := sdkdelivery.ComposedBucketFor(node)
|
||||
out := "keys:"
|
||||
kv, err := m.controller.KeyValue(context.Background(), bucket)
|
||||
if err != nil {
|
||||
return out + " " + err.Error()
|
||||
}
|
||||
lister, err := kv.ListKeys(context.Background())
|
||||
if err == nil {
|
||||
for k := range lister.Keys() {
|
||||
out += " " + k
|
||||
}
|
||||
}
|
||||
own, _ := sdkdelivery.ComposedNodeKey(node)
|
||||
if e, err := kv.Get(context.Background(), own); err == nil {
|
||||
if c, err := sdkdelivery.DecodeComposed(e.Value()); err == nil {
|
||||
out += "; its own carries:"
|
||||
for _, r := range c.Resources {
|
||||
var head struct{ ID string }
|
||||
_ = json.Unmarshal(r, &head)
|
||||
out += " " + head.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
fps, err := currentFingerprints(context.Background(), m.open.inventory)
|
||||
return out + fmt.Sprintf("; fingerprints registered: %v (%v)", fps, err)
|
||||
}
|
||||
|
||||
// revisions are a node's composition keys and their revisions.
|
||||
func (m *servedMesh) revisions(t *testing.T, node string) map[string]uint64 {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user