Skip to content

Commit

Permalink
fix(scyllaclient_test): make TestClientStatusIntegration more robust
Browse files Browse the repository at this point in the history
This test used to be failing with Scylla 5.4 and IPV6 because of different IPV6 string representations.
  • Loading branch information
Michal-Leszczynski authored and karol-kokoszka committed Feb 22, 2024
1 parent 2481b41 commit 78dee7d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pkg/scyllaclient/client_scylla_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package scyllaclient_test

import (
"context"
"net"
"net/http"
"strings"
"testing"
Expand All @@ -15,7 +16,6 @@ import (
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/testconfig"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/scylladb/go-log"
"github.com/scylladb/go-set/i64set"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
Expand Down Expand Up @@ -48,16 +48,25 @@ func TestClientStatusIntegration(t *testing.T) {
t.Fatal("Status() error", err)
}

ipCmp := cmp.Comparer(func(n1, n2 scyllaclient.NodeStatusInfo) bool {
out := true
out = out && n1.Datacenter == n2.Datacenter
out = out && n1.State == n2.State
out = out && n1.Status == n2.Status
out = out && net.ParseIP(n1.Addr).Equal(net.ParseIP(n2.Addr))
return out
})

golden := scyllaclient.NodeStatusInfoSlice{
{Datacenter: "dc1", Addr: ExpandIP(ToCanonicalIP(IPFromTestNet("11"))), State: "", Status: true},
{Datacenter: "dc1", Addr: ExpandIP(ToCanonicalIP(IPFromTestNet("12"))), State: "", Status: true},
{Datacenter: "dc1", Addr: ExpandIP(ToCanonicalIP(IPFromTestNet("13"))), State: "", Status: true},
{Datacenter: "dc2", Addr: ExpandIP(ToCanonicalIP(IPFromTestNet("21"))), State: "", Status: true},
{Datacenter: "dc2", Addr: ExpandIP(ToCanonicalIP(IPFromTestNet("22"))), State: "", Status: true},
{Datacenter: "dc2", Addr: ExpandIP(ToCanonicalIP(IPFromTestNet("23"))), State: "", Status: true},
{Datacenter: "dc1", Addr: IPFromTestNet("11"), State: "", Status: true},
{Datacenter: "dc1", Addr: IPFromTestNet("12"), State: "", Status: true},
{Datacenter: "dc1", Addr: IPFromTestNet("13"), State: "", Status: true},
{Datacenter: "dc2", Addr: IPFromTestNet("21"), State: "", Status: true},
{Datacenter: "dc2", Addr: IPFromTestNet("22"), State: "", Status: true},
{Datacenter: "dc2", Addr: IPFromTestNet("23"), State: "", Status: true},
}

if diff := cmp.Diff(golden, status, cmpopts.IgnoreFields(scyllaclient.NodeStatusInfo{}, "HostID")); diff != "" {
if diff := cmp.Diff(golden, status, ipCmp); diff != "" {
t.Fatalf("Status() = %#+v, diff %s", status, diff)
}
}
Expand Down

0 comments on commit 78dee7d

Please sign in to comment.