Fix flappers

- TestResponsePermissions: ensure subscription for service is
registered by server before sending requests.
- TestReloadDoesNotWipeAccountsWithOperatorMode: wait for subject
propagation.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2020-05-28 12:00:37 -06:00
parent f859edaf4f
commit b0e43b6aa9
4 changed files with 36 additions and 0 deletions

View File

@@ -381,6 +381,7 @@ func TestReloadDoesNotWipeAccountsWithOperatorMode(t *testing.T) {
// Use this to check for message.
checkForMsg := func() {
t.Helper()
select {
case <-ch:
case <-time.After(2 * time.Second):
@@ -388,6 +389,9 @@ func TestReloadDoesNotWipeAccountsWithOperatorMode(t *testing.T) {
}
}
// Wait for "foo" interest to be propagated to s2's account `accPub`
checkSubInterest(t, s2, accPub, "foo", 2*time.Second)
// Create second client and send message from this one. Interest should be here.
url2 := fmt.Sprintf("nats://%s:%d/", opts2.Host, opts2.Port)
nc2, err := nats.Connect(url2, createUserCreds(t, s2, accKP))
@@ -423,6 +427,8 @@ func TestReloadDoesNotWipeAccountsWithOperatorMode(t *testing.T) {
checkClusterFormed(t, s, s2)
checkSubInterest(t, s2, accPub, "foo", 2*time.Second)
// Reconnect and make sure this works. If accounts blown away this will fail.
url2 = fmt.Sprintf("nats://%s:%d/", opts2.Host, opts2.Port)
nc2, err = nats.Connect(url2, createUserCreds(t, s2, accKP))