From e22f6f5cd335208b47389e31e3f113996c7c721e Mon Sep 17 00:00:00 2001 From: Francesco Casula Date: Wed, 25 Sep 2024 18:15:42 +0200 Subject: [PATCH 1/2] test: scylla ipv6 --- .github/workflows/tests.yaml | 4 ++++ testhelper/docker/resource/scylla/config.go | 9 +++++++++ testhelper/docker/resource/scylla/scylla.go | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e38ea686..7a12e784 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -32,6 +32,10 @@ jobs: - kafkaclient - testhelper steps: + - name: Disable IPv6 + run: | + sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 + sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: diff --git a/testhelper/docker/resource/scylla/config.go b/testhelper/docker/resource/scylla/config.go index 1e9834d6..ba6fb4ed 100644 --- a/testhelper/docker/resource/scylla/config.go +++ b/testhelper/docker/resource/scylla/config.go @@ -1,5 +1,7 @@ package scylla +import "github.com/ory/dockertest/v3/docker" + type Option func(*config) func WithTag(tag string) Option { @@ -14,7 +16,14 @@ func WithKeyspace(keyspace string) Option { } } +func WithDockerNetwork(network *docker.Network) Option { + return func(c *config) { + c.network = network + } +} + type config struct { tag string keyspace string + network *docker.Network } diff --git a/testhelper/docker/resource/scylla/scylla.go b/testhelper/docker/resource/scylla/scylla.go index 3023558c..ead60433 100644 --- a/testhelper/docker/resource/scylla/scylla.go +++ b/testhelper/docker/resource/scylla/scylla.go @@ -3,6 +3,7 @@ package scylla import ( "bytes" "fmt" + "time" "github.com/gocql/gocql" "github.com/ory/dockertest/v3" @@ -11,6 +12,7 @@ import ( "github.com/rudderlabs/rudder-go-kit/bytesize" "github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource" "github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/internal" + "github.com/rudderlabs/rudder-go-kit/testhelper/rand" ) type Resource struct { @@ -26,6 +28,22 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...Option) (*Resource opt(c) } + if c.network == nil { + var err error + c.network, err = pool.Client.CreateNetwork(docker.CreateNetworkOptions{ + Name: "scylla_network_test_" + time.Now().Format("YY-MM-DD-") + rand.UniqueString(6), + EnableIPv6: false, + }) + if err != nil { + return nil, err + } + d.Cleanup(func() { + if err := pool.Client.RemoveNetwork(c.network.ID); err != nil { + d.Logf("Error while removing Docker network: %v", err) + } + }) + } + container, err := pool.RunWithOptions(&dockertest.RunOptions{ Repository: "scylladb/scylla", Tag: c.tag, @@ -33,6 +51,7 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...Option) (*Resource ExposedPorts: []string{"9042/tcp"}, PortBindings: internal.IPv4PortBindings([]string{"9042"}), Cmd: []string{"--smp 1"}, + NetworkID: c.network.ID, }, internal.DefaultHostConfig, func(hc *docker.HostConfig) { hc.CPUCount = 1 hc.Memory = 128 * bytesize.MB From 87fb975f4a58713239e8f5880e01ef373ab04286 Mon Sep 17 00:00:00 2001 From: Francesco Casula Date: Wed, 25 Sep 2024 18:27:37 +0200 Subject: [PATCH 2/2] chore: scylla image update --- testhelper/docker/resource/scylla/scylla.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testhelper/docker/resource/scylla/scylla.go b/testhelper/docker/resource/scylla/scylla.go index ead60433..329cf3a4 100644 --- a/testhelper/docker/resource/scylla/scylla.go +++ b/testhelper/docker/resource/scylla/scylla.go @@ -21,9 +21,7 @@ type Resource struct { } func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...Option) (*Resource, error) { - c := &config{ - tag: "5.4.9", - } + c := &config{tag: "6.1"} for _, opt := range opts { opt(c) } @@ -47,7 +45,6 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...Option) (*Resource container, err := pool.RunWithOptions(&dockertest.RunOptions{ Repository: "scylladb/scylla", Tag: c.tag, - Env: []string{}, ExposedPorts: []string{"9042/tcp"}, PortBindings: internal.IPv4PortBindings([]string{"9042"}), Cmd: []string{"--smp 1"}, @@ -115,7 +112,10 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...Option) (*Resource return nil, err } defer session.Close() - err = session.Query(fmt.Sprintf("CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", c.keyspace)).Exec() + err = session.Query(fmt.Sprintf( + "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", + c.keyspace, + )).Exec() if err != nil { return nil, err }