mirror of https://github.com/status-im/consul.git
agent: use helper/retry instead of timing related tests
This commit is contained in:
parent
bd3b8e042a
commit
051f004683
|
@ -295,9 +295,8 @@ func (a *Agent) Start() error {
|
||||||
// regular and on-demand state synchronizations (anti-entropy).
|
// regular and on-demand state synchronizations (anti-entropy).
|
||||||
a.sync = ae.NewStateSyncer(a.State, c.AEInterval, a.shutdownCh, a.logger)
|
a.sync = ae.NewStateSyncer(a.State, c.AEInterval, a.shutdownCh, a.logger)
|
||||||
|
|
||||||
// create the cache and register types
|
// create the cache
|
||||||
a.cache = cache.New(nil)
|
a.cache = cache.New(nil)
|
||||||
a.registerCache()
|
|
||||||
|
|
||||||
// create the config for the rpc server/client
|
// create the config for the rpc server/client
|
||||||
consulCfg, err := a.consulConfig()
|
consulCfg, err := a.consulConfig()
|
||||||
|
@ -335,6 +334,10 @@ func (a *Agent) Start() error {
|
||||||
a.State.Delegate = a.delegate
|
a.State.Delegate = a.delegate
|
||||||
a.State.TriggerSyncChanges = a.sync.SyncChanges.Trigger
|
a.State.TriggerSyncChanges = a.sync.SyncChanges.Trigger
|
||||||
|
|
||||||
|
// Register the cache. We do this much later so the delegate is
|
||||||
|
// populated from above.
|
||||||
|
a.registerCache()
|
||||||
|
|
||||||
// Load checks/services/metadata.
|
// Load checks/services/metadata.
|
||||||
if err := a.loadServices(c); err != nil {
|
if err := a.loadServices(c); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -2175,17 +2175,21 @@ func TestAgentConnectCARoots_list(t *testing.T) {
|
||||||
require.Nil(a.RPC("Test.ConnectCASetRoots",
|
require.Nil(a.RPC("Test.ConnectCASetRoots",
|
||||||
[]*structs.CARoot{ca}, &reply))
|
[]*structs.CARoot{ca}, &reply))
|
||||||
|
|
||||||
// Sleep a bit to wait for the cache to update
|
retry.Run(t, func(r *retry.R) {
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
|
|
||||||
// List it again
|
// List it again
|
||||||
obj, err := a.srv.AgentConnectCARoots(httptest.NewRecorder(), req)
|
obj, err := a.srv.AgentConnectCARoots(httptest.NewRecorder(), req)
|
||||||
require.Nil(err)
|
if err != nil {
|
||||||
require.Equal(obj, obj)
|
r.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
value := obj.(structs.IndexedCARoots)
|
value := obj.(structs.IndexedCARoots)
|
||||||
require.Equal(value.ActiveRootID, ca.ID)
|
if ca.ID != value.ActiveRootID {
|
||||||
require.Len(value.Roots, 1)
|
r.Fatalf("%s != %s", ca.ID, value.ActiveRootID)
|
||||||
|
}
|
||||||
|
if len(value.Roots) != 1 {
|
||||||
|
r.Fatalf("bad len: %d", len(value.Roots))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Should be a cache hit! The data should've updated in the cache
|
// Should be a cache hit! The data should've updated in the cache
|
||||||
// in the background so this should've been fetched directly from
|
// in the background so this should've been fetched directly from
|
||||||
|
|
Loading…
Reference in New Issue