Fix tests

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2022-11-27 14:08:58 -08:00
parent d2f1b04d34
commit baf9f42d9f
6 changed files with 68 additions and 59 deletions

View File

@@ -1319,7 +1319,7 @@ func TestLeafNodePermissions(t *testing.T) {
// Create a sub on ">" on LN1
subAll := natsSubSync(t, nc1, ">")
// this should be registered in LN2 (there is 1 sub for LN1 $LDS subject) + SYS IMPORTS
checkSubs(ln2.globalAccount(), 10)
checkSubs(ln2.globalAccount(), 12)
// Check deny export clause from messages published from LN2
for _, test := range []struct {
@@ -1346,7 +1346,7 @@ func TestLeafNodePermissions(t *testing.T) {
subAll.Unsubscribe()
// Goes down by 1.
checkSubs(ln2.globalAccount(), 9)
checkSubs(ln2.globalAccount(), 11)
// We used to make sure we would not do subscriptions however that
// was incorrect. We need to check publishes, not the subscriptions.
@@ -1371,7 +1371,7 @@ func TestLeafNodePermissions(t *testing.T) {
} {
t.Run(test.name, func(t *testing.T) {
sub := natsSubSync(t, nc2, test.subSubject)
checkSubs(ln2.globalAccount(), 10)
checkSubs(ln2.globalAccount(), 12)
if !test.ok {
nc1.Publish(test.pubSubject, []byte("msg"))
@@ -1379,12 +1379,12 @@ func TestLeafNodePermissions(t *testing.T) {
t.Fatalf("Did not expect to get the message")
}
} else {
checkSubs(ln1.globalAccount(), 9)
checkSubs(ln1.globalAccount(), 11)
nc1.Publish(test.pubSubject, []byte("msg"))
natsNexMsg(t, sub, time.Second)
}
sub.Unsubscribe()
checkSubs(ln1.globalAccount(), 8)
checkSubs(ln1.globalAccount(), 10)
})
}
}
@@ -1505,8 +1505,8 @@ func TestLeafNodeExportPermissionsNotForSpecialSubs(t *testing.T) {
// The deny is totally restrictive, but make sure that we still accept the $LDS, $GR and _GR_ go from LN1.
checkFor(t, time.Second, 15*time.Millisecond, func() error {
// We should have registered the 3 subs from the accepting leafnode.
if n := ln2.globalAccount().TotalSubs(); n != 8 {
return fmt.Errorf("Expected %d subs, got %v", 8, n)
if n := ln2.globalAccount().TotalSubs(); n != 9 {
return fmt.Errorf("Expected %d subs, got %v", 9, n)
}
return nil
})
@@ -3474,8 +3474,8 @@ func TestLeafNodeRouteSubWithOrigin(t *testing.T) {
r1.Shutdown()
checkFor(t, time.Second, 15*time.Millisecond, func() error {
acc := l2.GlobalAccount()
if n := acc.TotalSubs(); n != 4 {
return fmt.Errorf("Account %q should have 3 subs, got %v", acc.GetName(), n)
if n := acc.TotalSubs(); n != 5 {
return fmt.Errorf("Account %q should have 5 subs, got %v", acc.GetName(), n)
}
return nil
})