mirror of https://github.com/status-im/consul.git
test: fix flaky test TestAPI_CatalogNodes (#13779)
This commit is contained in:
parent
bb4d4040fb
commit
0678bf91a7
|
@ -36,19 +36,19 @@ func TestAPI_CatalogNodes(t *testing.T) {
|
|||
|
||||
s.WaitForSerfCheck(t)
|
||||
catalog := c.Catalog()
|
||||
|
||||
retry.Run(t, func(r *retry.R) {
|
||||
nodes, meta, err := catalog.Nodes(nil)
|
||||
// We're not concerned about the createIndex of an agent
|
||||
// Hence we're setting it to the default value
|
||||
nodes[0].CreateIndex = 0
|
||||
if err != nil {
|
||||
r.Fatal(err)
|
||||
}
|
||||
if meta.LastIndex < 2 {
|
||||
r.Fatal("Last index must be greater than 1")
|
||||
}
|
||||
want := []*Node{
|
||||
{
|
||||
require.NoError(r, err)
|
||||
require.Len(r, nodes, 1)
|
||||
require.True(r, meta.LastIndex >= 1, "Last index must be greater than 1")
|
||||
|
||||
// The raft indexes are not relevant for this test.
|
||||
got := nodes[0]
|
||||
got.CreateIndex = 0
|
||||
got.ModifyIndex = 0
|
||||
|
||||
want := &Node{
|
||||
ID: s.Config.NodeID,
|
||||
Node: s.Config.NodeName,
|
||||
Partition: splitDefaultPartition,
|
||||
|
@ -63,16 +63,8 @@ func TestAPI_CatalogNodes(t *testing.T) {
|
|||
Meta: map[string]string{
|
||||
"consul-network-segment": "",
|
||||
},
|
||||
// CreateIndex will never always be meta.LastIndex - 1
|
||||
// The purpose of this test is not to test CreateIndex value of an agent
|
||||
// rather to check if the client agent can get the correct number
|
||||
// of agents with a particular service, KV pair, etc...
|
||||
// Hence reverting this to the default value here.
|
||||
CreateIndex: 0,
|
||||
ModifyIndex: meta.LastIndex,
|
||||
},
|
||||
}
|
||||
require.Equal(r, want, nodes)
|
||||
require.Equal(r, want, got)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue