mirror of https://github.com/status-im/consul.git
ca: remove duplicate WaitFor function
This commit is contained in:
parent
1dec6bb815
commit
305655a8b1
|
@ -697,8 +697,8 @@ func TestConnectCAConfig_UpdateSecondary(t *testing.T) {
|
||||||
require.Len(rootList.Roots, 1)
|
require.Len(rootList.Roots, 1)
|
||||||
rootCert := activeRoot
|
rootCert := activeRoot
|
||||||
|
|
||||||
waitForActiveCARoot(t, s1, rootCert)
|
testrpc.WaitForActiveCARoot(t, s1.RPC, "primary", rootCert)
|
||||||
waitForActiveCARoot(t, s2, rootCert)
|
testrpc.WaitForActiveCARoot(t, s2.RPC, "secondary", rootCert)
|
||||||
|
|
||||||
// Capture the current intermediate
|
// Capture the current intermediate
|
||||||
rootList, activeRoot, err = getTestRoots(s2, "secondary")
|
rootList, activeRoot, err = getTestRoots(s2, "secondary")
|
||||||
|
|
|
@ -314,18 +314,6 @@ func TestCAManager_Initialize_Secondary(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForActiveCARoot(t *testing.T, srv *Server, expect *structs.CARoot) {
|
|
||||||
retry.Run(t, func(r *retry.R) {
|
|
||||||
_, root := getCAProviderWithLock(srv)
|
|
||||||
if root == nil {
|
|
||||||
r.Fatal("no root")
|
|
||||||
}
|
|
||||||
if root.ID != expect.ID {
|
|
||||||
r.Fatalf("current active root is %s; waiting for %s", root.ID, expect.ID)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCAProviderWithLock(s *Server) (ca.Provider, *structs.CARoot) {
|
func getCAProviderWithLock(s *Server) (ca.Provider, *structs.CARoot) {
|
||||||
return s.caManager.getCAProvider()
|
return s.caManager.getCAProvider()
|
||||||
}
|
}
|
||||||
|
@ -381,7 +369,6 @@ func TestCAManager_RenewIntermediate_Vault_Primary(t *testing.T) {
|
||||||
t.Log("original SigningKeyID", originalRoot.SigningKeyID)
|
t.Log("original SigningKeyID", originalRoot.SigningKeyID)
|
||||||
|
|
||||||
// Get the original intermediate.
|
// Get the original intermediate.
|
||||||
waitForActiveCARoot(t, s1, originalRoot)
|
|
||||||
provider, _ := getCAProviderWithLock(s1)
|
provider, _ := getCAProviderWithLock(s1)
|
||||||
intermediatePEM, err := provider.ActiveIntermediate()
|
intermediatePEM, err := provider.ActiveIntermediate()
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
@ -523,8 +510,8 @@ func TestCAManager_RenewIntermediate_Secondary(t *testing.T) {
|
||||||
}
|
}
|
||||||
t.Log("original SigningKeyID", originalRoot.SigningKeyID)
|
t.Log("original SigningKeyID", originalRoot.SigningKeyID)
|
||||||
|
|
||||||
waitForActiveCARoot(t, s1, originalRoot)
|
testrpc.WaitForActiveCARoot(t, s1.RPC, "dc1", originalRoot)
|
||||||
waitForActiveCARoot(t, s2, originalRoot)
|
testrpc.WaitForActiveCARoot(t, s2.RPC, "dc2", originalRoot)
|
||||||
|
|
||||||
store := s2.fsm.State()
|
store := s2.fsm.State()
|
||||||
_, activeRoot, err := store.CARootActive(nil)
|
_, activeRoot, err := store.CARootActive(nil)
|
||||||
|
|
|
@ -3,9 +3,10 @@ package testrpc
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/consul/sdk/testutil/retry"
|
"github.com/hashicorp/consul/sdk/testutil/retry"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type rpcFn func(string, interface{}, interface{}) error
|
type rpcFn func(string, interface{}, interface{}) error
|
||||||
|
@ -152,13 +153,7 @@ func WaitForActiveCARoot(t *testing.T, rpc rpcFn, dc string, expect *structs.CAR
|
||||||
r.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var root *structs.CARoot
|
root := reply.Active()
|
||||||
for _, r := range reply.Roots {
|
|
||||||
if r.ID == reply.ActiveRootID {
|
|
||||||
root = r
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if root == nil {
|
if root == nil {
|
||||||
r.Fatal("no active root")
|
r.Fatal("no active root")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue