Skip to content

Commit a9e7e8a

Browse files
committed
test:connect all nodes
1 parent 737f415 commit a9e7e8a

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

go.mod

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ module github.com/gocql/gocql
2020
go 1.23
2121

2222
require (
23-
github.com/bitly/go-hostpool v0.1.0 // indirect
24-
github.com/docker/docker v27.1.1+incompatible // indirect
2523
github.com/golang/snappy v0.0.4
2624
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed
25+
github.com/stretchr/testify v1.9.0
2726
github.com/testcontainers/testcontainers-go v0.33.0
2827
gopkg.in/inf.v0 v0.9.1
2928
)
@@ -32,13 +31,16 @@ require (
3231
dario.cat/mergo v1.0.0 // indirect
3332
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
3433
github.com/Microsoft/go-winio v0.6.2 // indirect
34+
github.com/bitly/go-hostpool v0.1.0 // indirect
3535
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
3636
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
3737
github.com/containerd/containerd v1.7.18 // indirect
3838
github.com/containerd/log v0.1.0 // indirect
3939
github.com/containerd/platforms v0.2.1 // indirect
4040
github.com/cpuguy83/dockercfg v0.3.1 // indirect
41+
github.com/davecgh/go-spew v1.1.1 // indirect
4142
github.com/distribution/reference v0.6.0 // indirect
43+
github.com/docker/docker v27.1.1+incompatible // indirect
4244
github.com/docker/go-connections v0.5.0 // indirect
4345
github.com/docker/go-units v0.5.0 // indirect
4446
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -60,6 +62,7 @@ require (
6062
github.com/opencontainers/go-digest v1.0.0 // indirect
6163
github.com/opencontainers/image-spec v1.1.0 // indirect
6264
github.com/pkg/errors v0.9.1 // indirect
65+
github.com/pmezard/go-difflib v1.0.0 // indirect
6366
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
6467
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
6568
github.com/shoenig/go-m1cpu v0.1.6 // indirect
@@ -73,4 +76,5 @@ require (
7376
go.opentelemetry.io/otel/trace v1.24.0 // indirect
7477
golang.org/x/crypto v0.22.0 // indirect
7578
golang.org/x/sys v0.21.0 // indirect
79+
gopkg.in/yaml.v3 v3.0.1 // indirect
7680
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvy
191191
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
192192
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
193193
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
194+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
195+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
194196
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
195197
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
196198
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

integration_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
"reflect"
3434
"testing"
3535
"time"
36+
37+
"github.com/stretchr/testify/assert"
3638
)
3739

3840
// TestAuthentication verifies that gocql will work with a host configured to only accept authenticated connections
@@ -272,3 +274,26 @@ func TestUDF(t *testing.T) {
272274
t.Fatal(err)
273275
}
274276
}
277+
278+
func TestAllNodesConnected(t *testing.T) {
279+
cluster := createCluster()
280+
cluster.PoolConfig.HostSelectionPolicy = RoundRobinHostPolicy()
281+
282+
session := createSessionFromCluster(cluster, t)
283+
defer session.Close()
284+
285+
ids := make(map[string]bool)
286+
287+
// Loop to query system.local multiple times. If there is a cluster with more than 10 nodes add to the loop more iterations
288+
for i := 0; i < 10; i++ {
289+
var hostID string
290+
err := session.Query("SELECT host_id FROM system.local").Scan(&hostID)
291+
if err != nil {
292+
t.Fatal(err)
293+
}
294+
295+
ids[hostID] = true
296+
}
297+
298+
assert.Equalf(t, *clusterSize, len(ids), "Expected to connect to %s unique nodes", *clusterSize)
299+
}

0 commit comments

Comments
 (0)