Skip to content

Commit

Permalink
fix go tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HammadB committed Jan 4, 2025
1 parent 7779924 commit dc2ccd4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions go/pkg/memberlist_manager/memberlist_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestNodeWatcher(t *testing.T) {
t.Fatalf("Error getting node status: %v", err)
}

return reflect.DeepEqual(memberlist, Memberlist{Member{id: "test-pod-0"}})
return reflect.DeepEqual(memberlist, Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}})
}, 10, 1*time.Second)
if !ok {
t.Fatalf("Node status did not update after adding a pod")
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestNodeWatcher(t *testing.T) {
if err != nil {
t.Fatalf("Error getting node status: %v", err)
}
return reflect.DeepEqual(memberlist, Memberlist{Member{id: "test-pod-0"}})
return reflect.DeepEqual(memberlist, Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}})
}, 10, 1*time.Second)
if !ok {
t.Fatalf("Node status did not update after adding a not ready pod")
Expand All @@ -108,13 +108,13 @@ func TestMemberlistStore(t *testing.T) {
assert.Equal(t, Memberlist{}, memberlist)

// Add a member to the memberlist
memberlist_store.UpdateMemberlist(context.Background(), Memberlist{Member{id: "test-pod-0"}, Member{id: "test-pod-1"}}, "0")
memberlist_store.UpdateMemberlist(context.Background(), Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}, Member{id: "test-pod-1", ip: "10.0.0.2"}}, "0")
memberlist, _, err = memberlist_store.GetMemberlist(context.Background())
if err != nil {
t.Fatalf("Error getting memberlist: %v", err)
}
// assert the memberlist has the correct members
if !memberlistSame(memberlist, Memberlist{Member{id: "test-pod-0"}, Member{id: "test-pod-1"}}) {
if !memberlistSame(memberlist, Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}, Member{id: "test-pod-1", ip: "10.0.0.2"}}) {
t.Fatalf("Memberlist did not update after adding a member")
}
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestMemberlistManager(t *testing.T) {

// Get the memberlist
ok := retryUntilCondition(func() bool {
return getMemberlistAndCompare(t, memberlistStore, Memberlist{Member{id: "test-pod-0"}})
return getMemberlistAndCompare(t, memberlistStore, Memberlist{Member{id: "test-pod-0", ip: "10.0.0.49"}})
}, 30, 1*time.Second)
if !ok {
t.Fatalf("Memberlist did not update after adding a pod")
Expand All @@ -195,7 +195,7 @@ func TestMemberlistManager(t *testing.T) {

// Get the memberlist
ok = retryUntilCondition(func() bool {
return getMemberlistAndCompare(t, memberlistStore, Memberlist{Member{id: "test-pod-0"}, Member{id: "test-pod-1"}})
return getMemberlistAndCompare(t, memberlistStore, Memberlist{Member{id: "test-pod-0", ip: "10.0.0.49"}, Member{id: "test-pod-1", ip: "10.0.0.50"}})
}, 30, 1*time.Second)
if !ok {
t.Fatalf("Memberlist did not update after adding a pod")
Expand All @@ -206,7 +206,7 @@ func TestMemberlistManager(t *testing.T) {

// Get the memberlist
ok = retryUntilCondition(func() bool {
return getMemberlistAndCompare(t, memberlistStore, Memberlist{Member{id: "test-pod-1"}})
return getMemberlistAndCompare(t, memberlistStore, Memberlist{Member{id: "test-pod-1", ip: "10.0.0.50"}})
}, 30, 1*time.Second)
if !ok {
t.Fatalf("Memberlist did not update after deleting a pod")
Expand All @@ -217,23 +217,23 @@ func TestMemberlistSame(t *testing.T) {
memberlist := Memberlist{}
assert.True(t, memberlistSame(memberlist, memberlist))

newMemberlist := Memberlist{Member{id: "test-pod-0"}}
newMemberlist := Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}}
assert.False(t, memberlistSame(memberlist, newMemberlist))
assert.False(t, memberlistSame(newMemberlist, memberlist))
assert.True(t, memberlistSame(newMemberlist, newMemberlist))

memberlist = Memberlist{Member{id: "test-pod-1"}}
memberlist = Memberlist{Member{id: "test-pod-1", ip: "10.0.0.2"}}
assert.False(t, memberlistSame(newMemberlist, memberlist))
assert.False(t, memberlistSame(memberlist, newMemberlist))
assert.True(t, memberlistSame(memberlist, memberlist))

memberlist = Memberlist{Member{id: "test-pod-0"}, Member{id: "test-pod-1"}}
newMemberlist = Memberlist{Member{id: "test-pod-0"}, Member{id: "test-pod-1"}}
memberlist = Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}, Member{id: "test-pod-1", ip: "10.0.0.2"}}
newMemberlist = Memberlist{Member{id: "test-pod-0", ip: "10.0.0.1"}, Member{id: "test-pod-1", ip: "10.0.0.2"}}
assert.True(t, memberlistSame(memberlist, newMemberlist))
assert.True(t, memberlistSame(newMemberlist, memberlist))

memberlist = Memberlist{Member{id: "test-pod-0"}, Member{id: "test-pod-1"}}
newMemberlist = Memberlist{Member{id: "test-pod-1"}, Member{id: "test-pod-0"}}
memberlist = Memberlist{Member{id: "test-pod-0", id: "10.0.0.1"}, Member{id: "test-pod-1", ip: "10.0.0.2"}}
newMemberlist = Memberlist{Member{id: "test-pod-1", ip: "10.0.0.2"}, Member{id: "test-pod-0", ip: "10.0.0.1"}}
assert.True(t, memberlistSame(memberlist, newMemberlist))
assert.True(t, memberlistSame(newMemberlist, memberlist))
}
Expand Down

0 comments on commit dc2ccd4

Please sign in to comment.