From ec37bb7753f9e2ec6ccf844340ca83c30caf96ca Mon Sep 17 00:00:00 2001 From: Salah Al Saleh Date: Fri, 15 Dec 2023 11:11:18 -0800 Subject: [PATCH] Use kotsadm/rqlite image in migrations test (#4227) * Use kotsadm/rqlite image in migrations test --- integration/database/rqlite_migration_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/integration/database/rqlite_migration_test.go b/integration/database/rqlite_migration_test.go index 78765e0032..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,19 +64,27 @@ 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) rqliteRunOptions := &dockertest.RunOptions{ Name: "rqlite", - Repository: "rqlite/rqlite", + Repository: "kotsadm/rqlite", Tag: rqliteTag, Mounts: []string{ + fmt.Sprintf("%s:/rqlite/file", t.TempDir()), fmt.Sprintf("%s:/auth/config.json", rqliteAuthConfigPath), }, + ExposedPorts: []string{ + "4001/tcp", + "4002/tcp", + }, PortBindings: map[docker.Port][]docker.PortBinding{ "4001/tcp": { { @@ -88,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