Skip to content

Commit 71ba830

Browse files
authored
add testrpc.WaitForServiceIntentions to help unflake tests that manipulate intentions (hashicorp#8867)
1 parent 0c9177f commit 71ba830

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

testrpc/wait.go

+21
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,27 @@ func WaitForActiveCARoot(t *testing.T, rpc rpcFn, dc string, expect *structs.CAR
168168
})
169169
}
170170

171+
// WaitForServiceIntentions waits until the server can accept config entry
172+
// kinds of service-intentions meaning any migration bootstrapping from pre-1.9
173+
// intentions has completed.
174+
func WaitForServiceIntentions(t *testing.T, rpc rpcFn, dc string) {
175+
const fakeConfigName = "Sa4ohw5raith4si0Ohwuqu3lowiethoh"
176+
retry.Run(t, func(r *retry.R) {
177+
args := &structs.ConfigEntryRequest{
178+
Op: structs.ConfigEntryDelete,
179+
Datacenter: dc,
180+
Entry: &structs.ServiceIntentionsConfigEntry{
181+
Kind: structs.ServiceIntentions,
182+
Name: fakeConfigName,
183+
},
184+
}
185+
var ignored struct{}
186+
if err := rpc("ConfigEntry.Delete", args, &ignored); err != nil {
187+
r.Fatalf("err: %v", err)
188+
}
189+
})
190+
}
191+
171192
func WaitForACLReplication(t *testing.T, rpc rpcFn, dc string, expectedReplicationType structs.ACLReplicationType, minPolicyIndex, minTokenIndex, minRoleIndex uint64) {
172193
retry.Run(t, func(r *retry.R) {
173194
args := structs.DCSpecificRequest{

0 commit comments

Comments
 (0)