From 01cd5c86e8602aa9babc54b07e51ef7b8445e0b6 Mon Sep 17 00:00:00 2001 From: Emilia Date: Thu, 6 Aug 2026 12:09:06 -0400 Subject: [PATCH] chore(tests): bump the postgres version used in CI (#6763) * bump the postgress version used in CI and fix the tests that broke * sort Grants by raw grant string rather than GrantStrings * trigger ci --- .../controller/handlers/roles/role_service_test.go | 8 +++++++- .../db/schema/migrations/oss/postgres_46_01_test.go | 2 +- .../db/schema/migrations/oss/postgres_97_03_test.go | 10 +++++----- testing/dbtest/docker/Dockerfile.17-alpine | 7 +++++++ testing/dbtest/docker/Dockerfile.18-alpine | 7 +++++++ testing/dbtest/docker/Makefile | 2 +- 6 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 testing/dbtest/docker/Dockerfile.17-alpine create mode 100644 testing/dbtest/docker/Dockerfile.18-alpine diff --git a/internal/daemon/controller/handlers/roles/role_service_test.go b/internal/daemon/controller/handlers/roles/role_service_test.go index 5995a3a8e..60b60e371 100644 --- a/internal/daemon/controller/handlers/roles/role_service_test.go +++ b/internal/daemon/controller/handlers/roles/role_service_test.go @@ -2120,8 +2120,12 @@ func checkEqualGrants(t *testing.T, expected []string, got *pb.Role) { require.Equal(len(expected), len(got.GrantStrings)) require.Equal(len(expected), len(got.Grants)) - // sort expected and got to ensure they are in the same order + // expected, got.Grants and got.GrantStrings need to be in the same order sort.Strings(expected) + sort.Slice(got.Grants, func(i, j int) bool { + return got.Grants[i].GetRaw() < got.Grants[j].GetRaw() + }) + sort.Slice(got.GrantStrings, func(i, j int) bool { return got.GrantStrings[i] < got.GrantStrings[j] }) @@ -2134,6 +2138,8 @@ func checkEqualGrants(t *testing.T, expected []string, got *pb.Role) { j := got.Grants[i].GetJson() require.NotNil(j) assert.Equal(parsed.Id(), j.GetId()) + sort.Strings(parsed.Ids()) + sort.Strings(j.Ids) assert.Equal(parsed.Ids(), j.GetIds()) assert.Equal(parsed.Type().String(), j.GetType()) _, acts := parsed.Actions() diff --git a/internal/db/schema/migrations/oss/postgres_46_01_test.go b/internal/db/schema/migrations/oss/postgres_46_01_test.go index a521050e8..8fb16ebb9 100644 --- a/internal/db/schema/migrations/oss/postgres_46_01_test.go +++ b/internal/db/schema/migrations/oss/postgres_46_01_test.go @@ -372,7 +372,7 @@ func validateRepairFunc(t *testing.T, rw *db.Db, repairReport migration.Repairs) }) } require.NoError(rows.Err()) - require.Equal([]targetAssociation{ + require.ElementsMatch([]targetAssociation{ { targetId: "ttcp_PRJA___65001", resourceId: "clvlt_PRJA___65001", diff --git a/internal/db/schema/migrations/oss/postgres_97_03_test.go b/internal/db/schema/migrations/oss/postgres_97_03_test.go index d3677b834..01d1c90e0 100644 --- a/internal/db/schema/migrations/oss/postgres_97_03_test.go +++ b/internal/db/schema/migrations/oss/postgres_97_03_test.go @@ -286,7 +286,7 @@ func Test_IamRoleAndGrantScopeMigration(t *testing.T) { require.NoError(rows.Err()) require.NoError(rows.Close()) require.Len(globalRoles, 10) - require.Equal([]testRole{ + require.ElementsMatch([]testRole{ { role_id: "r_go____name", scope_id: "global", @@ -400,7 +400,7 @@ func Test_IamRoleAndGrantScopeMigration(t *testing.T) { require.NoError(rows.Err()) require.NoError(rows.Close()) require.Len(orgRoles, 6) - require.Equal([]testRole{ + require.ElementsMatch([]testRole{ { role_id: "r_op_bc__art", scope_id: "o_____colors", @@ -477,7 +477,7 @@ func Test_IamRoleAndGrantScopeMigration(t *testing.T) { require.NoError(rows.Err()) require.NoError(rows.Close()) require.Len(projRoles, 5) - require.Equal([]testRole{ + require.ElementsMatch([]testRole{ { role_id: "r_prjaa____test", scope_id: "p_pA____test", @@ -562,7 +562,7 @@ func Test_IamRoleAndGrantScopeMigration(t *testing.T) { require.NoError(rows.Err()) require.NoError(rows.Close()) require.Len(individualProjRoles, 2) - require.Equal([]testRole{ + require.ElementsMatch([]testRole{ { role_id: "r_gp____spec", scope_id: "p____bcolors", @@ -592,7 +592,7 @@ func Test_IamRoleAndGrantScopeMigration(t *testing.T) { require.NoError(rows.Err()) require.NoError(rows.Close()) require.Len(individualOrgRoles, 2) - require.Equal([]testRole{ + require.ElementsMatch([]testRole{ { role_id: "r_op_rc__art", scope_id: "p____rcolors", diff --git a/testing/dbtest/docker/Dockerfile.17-alpine b/testing/dbtest/docker/Dockerfile.17-alpine new file mode 100644 index 000000000..e949cd288 --- /dev/null +++ b/testing/dbtest/docker/Dockerfile.17-alpine @@ -0,0 +1,7 @@ +FROM postgres:17-alpine + +ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh +ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh +ADD postgresql.conf /etc/postgresql/postgresql.conf + +CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"] diff --git a/testing/dbtest/docker/Dockerfile.18-alpine b/testing/dbtest/docker/Dockerfile.18-alpine new file mode 100644 index 000000000..e5c3133cc --- /dev/null +++ b/testing/dbtest/docker/Dockerfile.18-alpine @@ -0,0 +1,7 @@ +FROM postgres:18-alpine + +ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh +ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh +ADD postgresql.conf /etc/postgresql/postgresql.conf + +CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"] diff --git a/testing/dbtest/docker/Makefile b/testing/dbtest/docker/Makefile index 88f0ae72b..4252a2305 100644 --- a/testing/dbtest/docker/Makefile +++ b/testing/dbtest/docker/Makefile @@ -6,7 +6,7 @@ DOCKER_ARGS ?= -d DOCKER_MIRROR?=docker.io REGISTRY_NAME?=hashicorpboundary TEST_IMAGE_NAME=postgres -TEST_IMAGE_TAG ?= $(DOCKER_MIRROR)/$(REGISTRY_NAME)/$(TEST_IMAGE_NAME):12-alpine +TEST_IMAGE_TAG ?= $(DOCKER_MIRROR)/$(REGISTRY_NAME)/$(TEST_IMAGE_NAME):16-alpine PG_OPTS ?= TEST_DB_PORT ?= 5432 TEST_CONTAINER_NAME ?= boundary-sql-tests