From e933fed00ec25049e741a922d3e8a9a6e76f3fb9 Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Fri, 15 Dec 2023 15:23:52 +0000 Subject: [PATCH 1/3] Use kotsadm/rqlite image in migrations test --- integration/database/rqlite_migration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/database/rqlite_migration_test.go b/integration/database/rqlite_migration_test.go index 78765e0032..6b071b9adc 100644 --- a/integration/database/rqlite_migration_test.go +++ b/integration/database/rqlite_migration_test.go @@ -71,7 +71,7 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) { rqliteTag, _ := image.GetTag(image.Rqlite) rqliteRunOptions := &dockertest.RunOptions{ Name: "rqlite", - Repository: "rqlite/rqlite", + Repository: "kotsadm/rqlite", Tag: rqliteTag, Mounts: []string{ fmt.Sprintf("%s:/auth/config.json", rqliteAuthConfigPath), From d8160847b0d622d60ef356597be197678dfe004e Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Fri, 15 Dec 2023 16:52:49 +0000 Subject: [PATCH 2/3] expose ports --- integration/database/rqlite_migration_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration/database/rqlite_migration_test.go b/integration/database/rqlite_migration_test.go index 6b071b9adc..de55e992da 100644 --- a/integration/database/rqlite_migration_test.go +++ b/integration/database/rqlite_migration_test.go @@ -76,6 +76,10 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) { Mounts: []string{ fmt.Sprintf("%s:/auth/config.json", rqliteAuthConfigPath), }, + ExposedPorts: []string{ + "4001/tcp", + "4002/tcp", + }, PortBindings: map[docker.Port][]docker.PortBinding{ "4001/tcp": { { From 686e55fb96b1bdd4a18715953e2d981c48f555b6 Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Fri, 15 Dec 2023 18:34:25 +0000 Subject: [PATCH 3/3] run as current user --- integration/database/rqlite_migration_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/integration/database/rqlite_migration_test.go b/integration/database/rqlite_migration_test.go index de55e992da..7f3a986367 100644 --- a/integration/database/rqlite_migration_test.go +++ b/integration/database/rqlite_migration_test.go @@ -4,9 +4,10 @@ import ( "database/sql" _ "embed" "fmt" - "io/ioutil" "log" "net/http" + "os" + "os/user" "path" "testing" @@ -63,9 +64,12 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) { } // start rqlite db - rqliteAuthConfigPath := path.Join(t.TempDir(), "rqlite-auth-config.json") - err = ioutil.WriteFile(rqliteAuthConfigPath, []byte(RQLITE_AUTH_CONFIG), 0644) + currentUser, err := user.Current() if err != nil { + log.Fatalf("Failed to get current user: %s", err) + } + rqliteAuthConfigPath := path.Join(t.TempDir(), "rqlite-auth-config.json") + if err := os.WriteFile(rqliteAuthConfigPath, []byte(RQLITE_AUTH_CONFIG), 0644); err != nil { t.Fatalf("Failed to write to file %s", rqliteAuthConfigPath) } rqliteTag, _ := image.GetTag(image.Rqlite) @@ -74,6 +78,7 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) { Repository: "kotsadm/rqlite", Tag: rqliteTag, Mounts: []string{ + fmt.Sprintf("%s:/rqlite/file", t.TempDir()), fmt.Sprintf("%s:/auth/config.json", rqliteAuthConfigPath), }, ExposedPorts: []string{ @@ -92,6 +97,7 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) { "-http-adv-addr=localhost:14001", "-auth=/auth/config.json", }, + User: currentUser.Uid, } rqliteHostConfig := func(config *docker.HostConfig) { config.AutoRemove = true