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).
|
||||
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.registerCache()
|
||||
|
||||
// create the config for the rpc server/client
|
||||
consulCfg, err := a.consulConfig()
|
||||
|
@ -335,6 +334,10 @@ func (a *Agent) Start() error {
|
|||
a.State.Delegate = a.delegate
|
||||
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.
|
||||
if err := a.loadServices(c); err != nil {
|
||||
return err
|
||||
|
|
|
@ -2175,17 +2175,21 @@ func TestAgentConnectCARoots_list(t *testing.T) {
|
|||
require.Nil(a.RPC("Test.ConnectCASetRoots",
|
||||
[]*structs.CARoot{ca}, &reply))
|
||||
|
||||
// Sleep a bit to wait for the cache to update
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
retry.Run(t, func(r *retry.R) {
|
||||
// List it again
|
||||
obj, err := a.srv.AgentConnectCARoots(httptest.NewRecorder(), req)
|
||||
if err != nil {
|
||||
r.Fatal(err)
|
||||
}
|
||||
|
||||
// List it again
|
||||
obj, err := a.srv.AgentConnectCARoots(httptest.NewRecorder(), req)
|
||||
require.Nil(err)
|
||||
require.Equal(obj, obj)
|
||||
|
||||
value := obj.(structs.IndexedCARoots)
|
||||
require.Equal(value.ActiveRootID, ca.ID)
|
||||
require.Len(value.Roots, 1)
|
||||
value := obj.(structs.IndexedCARoots)
|
||||
if ca.ID != value.ActiveRootID {
|
||||
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
|
||||
// in the background so this should've been fetched directly from
|
||||
|
|
Loading…
Reference in New Issue