Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/etcd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func Test_configureCMD(t *testing.T) {
t.Run("default", func(t *testing.T) {
got := configureCMD(options{})
want := []string{"etcd", "--name=default"}
want := []string{"etcd", "--name=default", "--listen-client-urls=http://0.0.0.0:2379", "--advertise-client-urls=http://0.0.0.0:2379"}
require.Equal(t, want, got)
})

Expand Down
5 changes: 4 additions & 1 deletion modules/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ func configureCMD(settings options) []string {
cmds := []string{"etcd"}

if len(settings.nodeNames) == 0 {
cmds = append(cmds, "--name=default")
cmds = append(cmds, "--name=default",
"--listen-client-urls="+scheme+"://0.0.0.0:"+clientPort,
"--advertise-client-urls="+scheme+"://0.0.0.0:"+clientPort,
)
} else {
clusterCmds := []string{
"--name=" + settings.nodeNames[settings.currentNode],
Expand Down
23 changes: 19 additions & 4 deletions modules/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,26 @@ func TestRun(t *testing.T) {
require.Contains(t, string(output), "default")
}

func TestRun_PutGet(t *testing.T) {
ctx := context.Background()
func TestPutGet(t *testing.T) {
t.Run("single_node", func(t *testing.T) {
ctr, err := etcd.Run(context.Background(), "gcr.io/etcd-development/etcd:v3.5.14")
testPutGet(t, ctr, err)
})
t.Run("multiple_nodes", func(t *testing.T) {
ctr, err := etcd.Run(context.Background(), "gcr.io/etcd-development/etcd:v3.5.14", etcd.WithNodes("etcd-1", "etcd-2", "etcd-3"))
testPutGet(t, ctr, err)
})
}

func testPutGet(t *testing.T, ctr *etcd.EtcdContainer, err error) {
t.Helper()

ctr, err := etcd.Run(ctx, "gcr.io/etcd-development/etcd:v3.5.14", etcd.WithNodes("etcd-1", "etcd-2", "etcd-3"))
testcontainers.CleanupContainer(t, ctr)

require.NoError(t, err)

ctx := context.Background()

clientEndpoints, err := ctr.ClientEndpoints(ctx)
require.NoError(t, err)

Expand All @@ -45,7 +58,9 @@ func TestRun_PutGet(t *testing.T) {
DialTimeout: 5 * time.Second,
})
require.NoError(t, err)
defer cli.Close()
defer func() {
require.NoError(t, cli.Close())
}()

ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()
Expand Down
Loading