Skip to content

Commit

Permalink
Debug ut
Browse files Browse the repository at this point in the history
  • Loading branch information
ganglyu committed Jan 27, 2025
1 parent 65ac8dd commit 4c693b9
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions gnmi_server/transl_sub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ func TestTranslSubscribe(t *testing.T) {

sub := doSubscribe(t, req, codes.OK)
sub.Verify(
Updated(acl1Path+"/name", "ONE"),
Updated(acl1Path+"/type", "ACL_IPV4"),
Updated(acl1Path+"/config/name", "ONE"),
Updated(acl1Path+"/config/type", "ACL_IPV4"),
Updated(acl1Path+"/state/name", "ONE"),
Updated(acl1Path+"/state/type", "ACL_IPV4"),
Updated("/openconfig"+acl1Path+"/name", "ONE"),
Updated("/openconfig"+acl1Path+"/type", "ACL_IPV4"),
Updated("/openconfig"+acl1Path+"/config/name", "ONE"),
Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl1Path+"/state/name", "ONE"),
Updated("/openconfig"+acl1Path+"/state/type", "ACL_IPV4"),
client.Sync{},
)
})
Expand All @@ -160,8 +160,8 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify poll updates include ACL1 data")
sub.Poll()
sub.Verify(
Updated(acl1Path+"/config/name", "ONE"),
Updated(acl1Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl1Path+"/config/name", "ONE"),
Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"),
client.Sync{},
)

Expand All @@ -172,11 +172,11 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify poll updates include both ACL1 and ACL2 data")
sub.Poll()
sub.Verify(
Updated(acl1Path+"/config/name", "ONE"),
Updated(acl1Path+"/config/type", "ACL_IPV4"),
Updated(acl2Path+"/config/name", "TWO"),
Updated(acl2Path+"/config/type", "ACL_IPV4"),
Updated(acl2Path+"/config/description", "foo"),
Updated("/openconfig"+acl1Path+"/config/name", "ONE"),
Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/config/name", "TWO"),
Updated("/openconfig"+acl2Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/config/description", "foo"),
client.Sync{},
)

Expand All @@ -187,8 +187,8 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify poll updates now include ACL1 data only")
sub.Poll()
sub.Verify(
Updated(acl1Path+"/config/name", "ONE"),
Updated(acl1Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl1Path+"/config/name", "ONE"),
Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"),
client.Sync{},
)
})
Expand All @@ -213,28 +213,28 @@ func TestTranslSubscribe(t *testing.T) {

t.Logf("Verify update notifications for ACL2 data")
sub.Verify(
Updated(acl2Path+"/config/name", "TWO"),
Updated(acl2Path+"/config/type", "ACL_IPV4"),
Updated(acl2Path+"/config/description", "foo"),
Updated("/openconfig"+acl2Path+"/config/name", "TWO"),
Updated("/openconfig"+acl2Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/config/description", "foo"),
)

t.Logf("Create ACL1 and delete description of ACL2")
doSet(t, acl1CreatePb, acl2DescDeletePb)

t.Logf("Verify delete notification for ACL2 description and updates for ACL1 data")
sub.Verify(
Updated(acl1Path+"/config/name", "ONE"),
Updated(acl1Path+"/config/type", "ACL_IPV4"),
Deleted(acl2Path+"/config/description"),
Updated("/openconfig"+acl1Path+"/config/name", "ONE"),
Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"),
Deleted("/openconfig"+acl2Path+"/config/description"),
)

t.Logf("Delete ACL1 and set description for ACL2")
doSet(t, acl2DescUpdatePb, acl1DeletePb)

t.Logf("Verify delete for ACL1 and update for ACL2 description")
sub.Verify(
Deleted(acl1Path+"/config"),
Updated(acl2Path+"/config/description", "new"),
Deleted("/openconfig"+acl1Path+"/config"),
Updated("/openconfig"+acl2Path+"/config/description", "new"),
)
})

Expand Down Expand Up @@ -272,8 +272,8 @@ func TestTranslSubscribe(t *testing.T) {

t.Logf("Verify initial updates include ACL1 data only")
sub.Verify(
Updated(acl1Path+"/state/name", "ONE"),
Updated(acl1Path+"/state/type", "ACL_IPV4"),
Updated("/openconfig"+acl1Path+"/state/name", "ONE"),
Updated("/openconfig"+acl1Path+"/state/type", "ACL_IPV4"),
client.Sync{},
)

Expand All @@ -285,11 +285,11 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("interval %d", i)
sub.VerifyT(sampleInterval - 3*time.Second) // check no notifications before the interval
sub.Verify(
Updated(acl1Path+"/state/name", "ONE"),
Updated(acl1Path+"/state/type", "ACL_IPV4"),
Updated(acl2Path+"/state/name", "TWO"),
Updated(acl2Path+"/state/type", "ACL_IPV4"),
Updated(acl2Path+"/state/description", "foo"),
Updated("/openconfig"+acl1Path+"/state/name", "ONE"),
Updated("/openconfig"+acl1Path+"/state/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/state/name", "TWO"),
Updated("/openconfig"+acl2Path+"/state/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/state/description", "foo"),
)
}

Expand All @@ -299,17 +299,17 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify next iteration includes deletes and updates (for remaining ACL2 data)")
sub.VerifyT(sampleInterval - 3*time.Second)
sub.Verify(
Deleted(acl1Path+"/state"),
Deleted(acl2Path+"/state/description"),
Updated(acl2Path+"/state/name", "TWO"),
Updated(acl2Path+"/state/type", "ACL_IPV4"),
Deleted("/openconfig"+acl1Path+"/state"),
Deleted("/openconfig"+acl2Path+"/state/description"),
Updated("/openconfig"+acl2Path+"/state/name", "TWO"),
Updated("/openconfig"+acl2Path+"/state/type", "ACL_IPV4"),
)

t.Logf("Verify next iteration has updates only")
sub.VerifyT(sampleInterval - 3*time.Second)
sub.Verify(
Updated(acl2Path+"/state/name", "TWO"),
Updated(acl2Path+"/state/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/state/name", "TWO"),
Updated("/openconfig"+acl2Path+"/state/type", "ACL_IPV4"),
)
})

Expand All @@ -334,11 +334,11 @@ func TestTranslSubscribe(t *testing.T) {

t.Logf("Verify initial updates")
sub.Verify(
Updated(acl1Path+"/config/name", "ONE"),
Updated(acl1Path+"/config/type", "ACL_IPV4"),
Updated(acl2Path+"/config/name", "TWO"),
Updated(acl2Path+"/config/type", "ACL_IPV4"),
Updated(acl2Path+"/config/description", "foo"),
Updated("/openconfig"+acl1Path+"/config/name", "ONE"),
Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/config/name", "TWO"),
Updated("/openconfig"+acl2Path+"/config/type", "ACL_IPV4"),
Updated("/openconfig"+acl2Path+"/config/description", "foo"),
client.Sync{},
)

Expand All @@ -351,8 +351,8 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify next iteration includes deletes and updates for modified paths only")
sub.VerifyT(
sampleInterval+3*time.Second,
Deleted(acl1Path+"/config"),
Updated(acl2Path+"/config/description", "new"),
Deleted("/openconfig"+acl1Path+"/config"),
Updated("/openconfig"+acl2Path+"/config/description", "new"),
)

t.Logf("Delete ACL2 description")
Expand All @@ -361,7 +361,7 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify next iteration includes description delete only")
sub.VerifyT(
sampleInterval+3*time.Second,
Deleted(acl2Path+"/config/description"),
Deleted("/openconfig"+acl2Path+"/config/description"),
)

t.Logf("Verify next iteration has no data")
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify next iteration has the description value")
sub.VerifyT(sampleInterval - 3*time.Second) // check no notifications before the interval
sub.Verify(
Updated(acl2Path+"/state/description", "foo"),
Updated("/openconfig"+acl2Path+"/state/description", "foo"),
)

t.Logf("Update ACL2 description")
Expand All @@ -402,7 +402,7 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify next iteration has the updated description")
sub.VerifyT(sampleInterval - 3*time.Second)
sub.Verify(
Updated(acl2Path+"/state/description", "new"),
Updated("/openconfig"+acl2Path+"/state/description", "new"),
)

t.Logf("Delete ACL2")
Expand All @@ -411,7 +411,7 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify next iteration has delete notification")
sub.VerifyT(sampleInterval - 3*time.Second)
sub.Verify(
Deleted(acl2Path + "/state/description"),
Deleted("/openconfig"+acl2Path + "/state/description"),
)

t.Logf("Verify next iteration has no notifications")
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestTranslSubscribe(t *testing.T) {
t.Logf("Verify updates are received after default interval")
sub.VerifyT(
(translib.MinSubscribeInterval+2)*time.Second,
Updated(acl2Path+"/state/description", "foo"),
Updated("/openconfig"+acl2Path+"/state/description", "foo"),
)
})

Expand Down

0 comments on commit 4c693b9

Please sign in to comment.