Make container reuse optional, disabled by default.
This commit is contained in:
parent
3ad3f29861
commit
eb33dac9b1
|
@ -1,9 +1,7 @@
|
||||||
import { GenericContainer, Wait } from "testcontainers"
|
import { GenericContainer, Wait } from "testcontainers"
|
||||||
|
|
||||||
export default async function setup() {
|
export default async function setup() {
|
||||||
await new GenericContainer("budibase/couchdb")
|
let couchdb = new GenericContainer("budibase/couchdb")
|
||||||
.withName("budibase-test-couchdb")
|
|
||||||
.withReuse()
|
|
||||||
.withExposedPorts(5984)
|
.withExposedPorts(5984)
|
||||||
.withEnvironment({
|
.withEnvironment({
|
||||||
COUCHDB_PASSWORD: "budibase",
|
COUCHDB_PASSWORD: "budibase",
|
||||||
|
@ -23,5 +21,10 @@ export default async function setup() {
|
||||||
"curl http://budibase:budibase@localhost:5984/_up"
|
"curl http://budibase:budibase@localhost:5984/_up"
|
||||||
).withStartupTimeout(20000)
|
).withStartupTimeout(20000)
|
||||||
)
|
)
|
||||||
.start()
|
|
||||||
|
if (process.env.REUSE_CONTAINERS) {
|
||||||
|
couchdb = couchdb.withReuse()
|
||||||
|
}
|
||||||
|
|
||||||
|
await couchdb.start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,16 +22,19 @@ class MariaDBWaitStrategy extends AbstractWaitStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDatasource(): Promise<Datasource> {
|
export async function getDatasource(): Promise<Datasource> {
|
||||||
const container = await new GenericContainer("mariadb:lts")
|
let container = new GenericContainer("mariadb:lts")
|
||||||
.withName("budibase-test-mariadb")
|
|
||||||
.withReuse()
|
|
||||||
.withExposedPorts(3306)
|
.withExposedPorts(3306)
|
||||||
.withEnvironment({ MARIADB_ROOT_PASSWORD: "password" })
|
.withEnvironment({ MARIADB_ROOT_PASSWORD: "password" })
|
||||||
.withWaitStrategy(new MariaDBWaitStrategy())
|
.withWaitStrategy(new MariaDBWaitStrategy())
|
||||||
.start()
|
|
||||||
|
|
||||||
const host = container.getHost()
|
if (process.env.REUSE_CONTAINERS) {
|
||||||
const port = container.getMappedPort(3306)
|
container = container.withReuse()
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedContainer = await container.start()
|
||||||
|
|
||||||
|
const host = startedContainer.getHost()
|
||||||
|
const port = startedContainer.getMappedPort(3306)
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
host,
|
host,
|
||||||
|
|
|
@ -2,9 +2,7 @@ import { Datasource, SourceName } from "@budibase/types"
|
||||||
import { GenericContainer, Wait } from "testcontainers"
|
import { GenericContainer, Wait } from "testcontainers"
|
||||||
|
|
||||||
export async function getDatasource(): Promise<Datasource> {
|
export async function getDatasource(): Promise<Datasource> {
|
||||||
const container = await new GenericContainer("mongo:7.0-jammy")
|
let container = new GenericContainer("mongo:7.0-jammy")
|
||||||
.withName("budibase-test-mongodb")
|
|
||||||
.withReuse()
|
|
||||||
.withExposedPorts(27017)
|
.withExposedPorts(27017)
|
||||||
.withEnvironment({
|
.withEnvironment({
|
||||||
MONGO_INITDB_ROOT_USERNAME: "mongo",
|
MONGO_INITDB_ROOT_USERNAME: "mongo",
|
||||||
|
@ -15,10 +13,15 @@ export async function getDatasource(): Promise<Datasource> {
|
||||||
`mongosh --eval "db.version()"`
|
`mongosh --eval "db.version()"`
|
||||||
).withStartupTimeout(10000)
|
).withStartupTimeout(10000)
|
||||||
)
|
)
|
||||||
.start()
|
|
||||||
|
|
||||||
const host = container.getHost()
|
if (process.env.REUSE_CONTAINERS) {
|
||||||
const port = container.getMappedPort(27017)
|
container = container.withReuse()
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedContainer = await container.start()
|
||||||
|
|
||||||
|
const host = startedContainer.getHost()
|
||||||
|
const port = startedContainer.getMappedPort(27017)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "datasource",
|
type: "datasource",
|
||||||
|
|
|
@ -4,11 +4,9 @@ import mssql from "mssql"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
|
|
||||||
export async function getDatasource(): Promise<Datasource> {
|
export async function getDatasource(): Promise<Datasource> {
|
||||||
const container = await new GenericContainer(
|
let container = new GenericContainer(
|
||||||
"mcr.microsoft.com/mssql/server:2022-latest"
|
"mcr.microsoft.com/mssql/server:2022-latest"
|
||||||
)
|
)
|
||||||
.withName("budibase-test-mssql")
|
|
||||||
.withReuse()
|
|
||||||
.withExposedPorts(1433)
|
.withExposedPorts(1433)
|
||||||
.withEnvironment({
|
.withEnvironment({
|
||||||
ACCEPT_EULA: "Y",
|
ACCEPT_EULA: "Y",
|
||||||
|
@ -24,10 +22,15 @@ export async function getDatasource(): Promise<Datasource> {
|
||||||
"/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password_123 -q 'SELECT 1'"
|
"/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password_123 -q 'SELECT 1'"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.start()
|
|
||||||
|
|
||||||
const host = container.getHost()
|
if (process.env.REUSE_CONTAINERS) {
|
||||||
const port = container.getMappedPort(1433)
|
container = container.withReuse()
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedContainer = await container.start()
|
||||||
|
|
||||||
|
const host = startedContainer.getHost()
|
||||||
|
const port = startedContainer.getMappedPort(1433)
|
||||||
|
|
||||||
const datasource: Datasource = {
|
const datasource: Datasource = {
|
||||||
type: "datasource_plus",
|
type: "datasource_plus",
|
||||||
|
|
|
@ -25,15 +25,19 @@ class MySQLWaitStrategy extends AbstractWaitStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDatasource(): Promise<Datasource> {
|
export async function getDatasource(): Promise<Datasource> {
|
||||||
const container = await new GenericContainer("mysql:8.3")
|
let container = new GenericContainer("mysql:8.3")
|
||||||
.withName("budibase-test-mysql")
|
|
||||||
.withReuse()
|
|
||||||
.withExposedPorts(3306)
|
.withExposedPorts(3306)
|
||||||
.withEnvironment({ MYSQL_ROOT_PASSWORD: "password" })
|
.withEnvironment({ MYSQL_ROOT_PASSWORD: "password" })
|
||||||
.withWaitStrategy(new MySQLWaitStrategy().withStartupTimeout(10000))
|
.withWaitStrategy(new MySQLWaitStrategy().withStartupTimeout(10000))
|
||||||
.start()
|
|
||||||
const host = container.getHost()
|
if (process.env.REUSE_CONTAINERS) {
|
||||||
const port = container.getMappedPort(3306)
|
container = container.withReuse()
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedContainer = await container.start()
|
||||||
|
|
||||||
|
const host = startedContainer.getHost()
|
||||||
|
const port = startedContainer.getMappedPort(3306)
|
||||||
|
|
||||||
const datasource: Datasource = {
|
const datasource: Datasource = {
|
||||||
type: "datasource_plus",
|
type: "datasource_plus",
|
||||||
|
|
|
@ -4,9 +4,7 @@ import pg from "pg"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
|
|
||||||
export async function getDatasource(): Promise<Datasource> {
|
export async function getDatasource(): Promise<Datasource> {
|
||||||
const container = await new GenericContainer("postgres:16.1-bullseye")
|
let container = new GenericContainer("postgres:16.1-bullseye")
|
||||||
.withName("budibase-test-postgres")
|
|
||||||
.withReuse()
|
|
||||||
.withExposedPorts(5432)
|
.withExposedPorts(5432)
|
||||||
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
||||||
.withWaitStrategy(
|
.withWaitStrategy(
|
||||||
|
@ -14,9 +12,15 @@ export async function getDatasource(): Promise<Datasource> {
|
||||||
"pg_isready -h localhost -p 5432"
|
"pg_isready -h localhost -p 5432"
|
||||||
).withStartupTimeout(10000)
|
).withStartupTimeout(10000)
|
||||||
)
|
)
|
||||||
.start()
|
|
||||||
const host = container.getHost()
|
if (process.env.REUSE_CONTAINERS) {
|
||||||
const port = container.getMappedPort(5432)
|
container = container.withReuse()
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedContainer = await container.start()
|
||||||
|
|
||||||
|
const host = startedContainer.getHost()
|
||||||
|
const port = startedContainer.getMappedPort(5432)
|
||||||
|
|
||||||
const datasource: Datasource = {
|
const datasource: Datasource = {
|
||||||
type: "datasource_plus",
|
type: "datasource_plus",
|
||||||
|
|
Loading…
Reference in New Issue