diff --git a/packages/backend-core/tests/core/utilities/testContainerUtils.ts b/packages/backend-core/tests/core/utilities/testContainerUtils.ts index 71d7fa32db..727b290183 100644 --- a/packages/backend-core/tests/core/utilities/testContainerUtils.ts +++ b/packages/backend-core/tests/core/utilities/testContainerUtils.ts @@ -25,7 +25,7 @@ function getTestcontainers(): ContainerInfo[] { // We use --format json to make sure the output is nice and machine-readable, // and we use --no-trunc so that the command returns full container IDs so we // can filter on them correctly. - return execSync("docker ps --format json --no-trunc") + return execSync("docker ps --all --format json --no-trunc") .toString() .split("\n") .filter(x => x.length > 0) @@ -37,6 +37,10 @@ function getTestcontainers(): ContainerInfo[] { ) } +function removeContainer(container: ContainerInfo) { + execSync(`docker rm ${container.ID}`) +} + export function getContainerByImage(image: string) { const containers = getTestcontainers().filter(x => x.Image.startsWith(image)) if (containers.length > 1) { @@ -49,6 +53,10 @@ export function getContainerByImage(image: string) { return containers[0] } +function getContainerByName(name: string) { + return getTestcontainers().find(x => x.Names === name) +} + export function getContainerById(id: string) { return getTestcontainers().find(x => x.ID === id) } @@ -116,6 +124,16 @@ export async function startContainer(container: GenericContainer) { key = imageName.split("@")[0] } key = key.replace(/\//g, "-").replace(/:/g, "-") + const name = `${key}_testcontainer` + + // If a container has died it hangs around and future attempts to start a + // container with the same name will fail. What we do here is if we find a + // matching container and it has exited, we remove it before carrying on. This + // removes the need to do this removal manually. + const existingContainer = getContainerByName(name) + if (existingContainer?.State === "exited") { + removeContainer(existingContainer) + } container = container .withReuse() diff --git a/packages/pro b/packages/pro index aa6517bfbc..abdfb720c5 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit aa6517bfbc463b3aac4ae53245dcce3d8bb130e4 +Subproject commit abdfb720c5583256e0334330ccbea1abcbe3d434 diff --git a/packages/server/src/api/routes/utils/validators.ts b/packages/server/src/api/routes/utils/validators.ts index 3bee4f88ce..a8fa12ec3d 100644 --- a/packages/server/src/api/routes/utils/validators.ts +++ b/packages/server/src/api/routes/utils/validators.ts @@ -1,5 +1,4 @@ import { auth, permissions } from "@budibase/backend-core" -import { DataSourceOperation } from "../../../constants" import { AutomationActionStepId, AutomationStep, @@ -231,30 +230,6 @@ export function externalSearchValidator() { ) } -export function datasourceQueryValidator() { - return auth.joiValidator.body( - Joi.object({ - endpoint: Joi.object({ - datasourceId: Joi.string().required(), - operation: Joi.string() - .required() - .valid(...Object.values(DataSourceOperation)), - entityId: Joi.string().required(), - }).required(), - resource: Joi.object({ - fields: Joi.array().items(Joi.string()).optional(), - }).optional(), - body: Joi.object().optional(), - sort: Joi.object().optional(), - filters: filterObject().optional(), - paginate: Joi.object({ - page: Joi.string().alphanum().optional(), - limit: Joi.number().optional(), - }).optional(), - }) - ) -} - export function webhookValidator() { return auth.joiValidator.body( Joi.object({ diff --git a/packages/server/src/constants/index.ts b/packages/server/src/constants/index.ts index bac838b53e..604a81cd9f 100644 --- a/packages/server/src/constants/index.ts +++ b/packages/server/src/constants/index.ts @@ -45,17 +45,6 @@ export enum AuthTypes { EXTERNAL = "external", } -export enum DataSourceOperation { - CREATE = "CREATE", - READ = "READ", - UPDATE = "UPDATE", - DELETE = "DELETE", - BULK_CREATE = "BULK_CREATE", - CREATE_TABLE = "CREATE_TABLE", - UPDATE_TABLE = "UPDATE_TABLE", - DELETE_TABLE = "DELETE_TABLE", -} - export enum DatasourceAuthTypes { GOOGLE = "google", }