From 99c2a51f41dc93bfebf3c4381ccea1a27c91b79e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 26 Jan 2024 16:48:56 +0000 Subject: [PATCH] Updating back to use our own home-rolled version which allows us to specify the image version correctly, but using the testcontainers option to wait for two logs. --- packages/server/package.json | 4 ++-- .../integrations/postgres/docker-compose.yml | 2 +- .../src/integrations/tests/utils/postgres.ts | 23 ++++++++++--------- yarn.lock | 7 ------ 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 53aa6268a8..15ffcbe4c6 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -114,8 +114,7 @@ "@babel/preset-env": "7.16.11", "@swc/core": "1.3.71", "@swc/jest": "0.2.27", - "@testcontainers/postgresql": "10.6.0", - "@trendyol/jest-testcontainers": "2.1.1", + "@trendyol/jest-estcontainers": "2.1.1", "@types/global-agent": "2.1.1", "@types/google-spreadsheet": "3.1.5", "@types/jest": "29.5.5", @@ -143,6 +142,7 @@ "rimraf": "3.0.2", "supertest": "6.3.3", "swagger-jsdoc": "6.1.0", + "testcontainers": "10.6.0", "timekeeper": "2.2.0", "ts-node": "10.8.1", "tsconfig-paths": "4.0.0", diff --git a/packages/server/scripts/integrations/postgres/docker-compose.yml b/packages/server/scripts/integrations/postgres/docker-compose.yml index 53e1a1812d..fe71542826 100644 --- a/packages/server/scripts/integrations/postgres/docker-compose.yml +++ b/packages/server/scripts/integrations/postgres/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: db: container_name: postgres - image: postgres:latest + image: postgres:16.1-bullseye restart: unless-stopped environment: POSTGRES_USER: root diff --git a/packages/server/src/integrations/tests/utils/postgres.ts b/packages/server/src/integrations/tests/utils/postgres.ts index c24f13d133..8e66ef02d6 100644 --- a/packages/server/src/integrations/tests/utils/postgres.ts +++ b/packages/server/src/integrations/tests/utils/postgres.ts @@ -1,23 +1,24 @@ import { Datasource, SourceName } from "@budibase/types" -import { - PostgreSqlContainer, - StartedPostgreSqlContainer, -} from "@testcontainers/postgresql" +import { GenericContainer, Wait, StartedTestContainer } from "testcontainers" -let container: StartedPostgreSqlContainer | undefined +let container: StartedTestContainer | undefined export async function getDsConfig(): Promise { try { if (!container) { - const pgContainer = new PostgreSqlContainer() - container = await pgContainer - .withUsername("postgres") - .withPassword("password") + container = await new GenericContainer("postgres:16.1-bullseye") .withExposedPorts(5432) + .withEnvironment({ POSTGRES_PASSWORD: "password" }) + .withWaitStrategy( + Wait.forLogMessage( + "database system is ready to accept connections", + 2 + ) + ) .start() } - const host = container!.getHost() - const port = container!.getMappedPort(5432) + const host = container.getHost() + const port = container.getMappedPort(5432) return { type: "datasource_plus", diff --git a/yarn.lock b/yarn.lock index 9362c3815c..9d42f2b219 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4977,13 +4977,6 @@ resolved "https://registry.yarnpkg.com/@tediousjs/connection-string/-/connection-string-0.5.0.tgz#9b3d858c040aac6bdf5584bf45370cef5b6522b4" integrity sha512-7qSgZbincDDDFyRweCIEvZULFAw5iz/DeunhvuxpL31nfntX3P4Yd4HkHBRg9H8CdqY1e5WFN1PZIz/REL9MVQ== -"@testcontainers/postgresql@10.6.0": - version "10.6.0" - resolved "https://registry.yarnpkg.com/@testcontainers/postgresql/-/postgresql-10.6.0.tgz#dfeff325130ab0ed4fd0dbd5dbe5847cddb435d9" - integrity sha512-gHYpsXkVLpCkJ0jg7xE5n8pogTNvw2LyhkXeJm04raH1yz020jcHAB2a1tRW1J2D8mM8WhFH+xH6pzH2ZggFdg== - dependencies: - testcontainers "^10.6.0" - "@testing-library/dom@^8.1.0": version "8.20.0" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.20.0.tgz#914aa862cef0f5e89b98cc48e3445c4c921010f6"