Skip to content

Commit

Permalink
test: scylla no ipv6 (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
fracasula authored Sep 26, 2024
1 parent 4f65bca commit d8083ae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions testhelper/docker/resource/scylla/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scylla

import "github.com/ory/dockertest/v3/docker"

type Option func(*config)

func WithTag(tag string) Option {
Expand All @@ -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
}
29 changes: 24 additions & 5 deletions testhelper/docker/resource/scylla/scylla.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scylla
import (
"bytes"
"fmt"
"time"

"github.com/gocql/gocql"
"github.com/ory/dockertest/v3"
Expand All @@ -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 {
Expand All @@ -19,20 +21,34 @@ 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)
}

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,
Env: []string{},
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
Expand Down Expand Up @@ -96,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
}
Expand Down

0 comments on commit d8083ae

Please sign in to comment.