Merge branch 'master' of github.com:budibase/budibase into fix-arm-image-with-isolated-vm
This commit is contained in:
commit
67a4d88d27
|
@ -6,6 +6,7 @@ import * as context from "./context"
|
||||||
import semver from "semver"
|
import semver from "semver"
|
||||||
import { bustCache, withCache, TTL, CacheKey } from "./cache/generic"
|
import { bustCache, withCache, TTL, CacheKey } from "./cache/generic"
|
||||||
import environment from "./environment"
|
import environment from "./environment"
|
||||||
|
import { logAlert } from "./logging"
|
||||||
|
|
||||||
export const getInstall = async (): Promise<Installation> => {
|
export const getInstall = async (): Promise<Installation> => {
|
||||||
return withCache(CacheKey.INSTALLATION, TTL.ONE_DAY, getInstallFromDB, {
|
return withCache(CacheKey.INSTALLATION, TTL.ONE_DAY, getInstallFromDB, {
|
||||||
|
@ -80,6 +81,7 @@ export const checkInstallVersion = async (): Promise<void> => {
|
||||||
const currentVersion = install.version
|
const currentVersion = install.version
|
||||||
const newVersion = environment.VERSION
|
const newVersion = environment.VERSION
|
||||||
|
|
||||||
|
try {
|
||||||
if (currentVersion !== newVersion) {
|
if (currentVersion !== newVersion) {
|
||||||
const isUpgrade = semver.gt(newVersion, currentVersion)
|
const isUpgrade = semver.gt(newVersion, currentVersion)
|
||||||
const isDowngrade = semver.lt(newVersion, currentVersion)
|
const isDowngrade = semver.lt(newVersion, currentVersion)
|
||||||
|
@ -103,4 +105,11 @@ export const checkInstallVersion = async (): Promise<void> => {
|
||||||
await events.identification.identifyInstallationGroup(install.installId)
|
await events.identification.identifyInstallationGroup(install.installId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
if (err?.message?.includes("Invalid Version")) {
|
||||||
|
logAlert(`Invalid version "${newVersion}" - is it semver?`)
|
||||||
|
} else {
|
||||||
|
logAlert("Failed to retrieve version", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,9 @@ export async function start(): Promise<StartedTestContainer> {
|
||||||
MONGO_INITDB_ROOT_PASSWORD: "password",
|
MONGO_INITDB_ROOT_PASSWORD: "password",
|
||||||
})
|
})
|
||||||
.withWaitStrategy(
|
.withWaitStrategy(
|
||||||
Wait.forSuccessfulCommand(`mongosh --eval "db.version()"`)
|
Wait.forSuccessfulCommand(
|
||||||
|
`mongosh --eval "db.version()"`
|
||||||
|
).withStartupTimeout(10000)
|
||||||
)
|
)
|
||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,34 @@
|
||||||
import { Datasource, SourceName } from "@budibase/types"
|
import { Datasource, SourceName } from "@budibase/types"
|
||||||
import { GenericContainer, Wait, StartedTestContainer } from "testcontainers"
|
import { GenericContainer, Wait, StartedTestContainer } from "testcontainers"
|
||||||
|
import { AbstractWaitStrategy } from "testcontainers/build/wait-strategies/wait-strategy"
|
||||||
|
|
||||||
let container: StartedTestContainer | undefined
|
let container: StartedTestContainer | undefined
|
||||||
|
|
||||||
|
class MySQLWaitStrategy extends AbstractWaitStrategy {
|
||||||
|
async waitUntilReady(container: any, boundPorts: any, startTime?: Date) {
|
||||||
|
// Because MySQL first starts itself up, runs an init script, then restarts,
|
||||||
|
// it's possible for the mysqladmin ping to succeed early and then tests to
|
||||||
|
// run against a MySQL that's mid-restart and fail. To get around this, we
|
||||||
|
// wait for logs and then do a ping check.
|
||||||
|
|
||||||
|
const logs = Wait.forLogMessage(
|
||||||
|
"/usr/sbin/mysqld: ready for connections",
|
||||||
|
2
|
||||||
|
)
|
||||||
|
await logs.waitUntilReady(container, boundPorts, startTime)
|
||||||
|
|
||||||
|
const command = Wait.forSuccessfulCommand(
|
||||||
|
`mysqladmin ping -h localhost -P 3306 -u root -ppassword`
|
||||||
|
)
|
||||||
|
await command.waitUntilReady(container)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function start(): Promise<StartedTestContainer> {
|
export async function start(): Promise<StartedTestContainer> {
|
||||||
return await new GenericContainer("mysql:8.3")
|
return await new GenericContainer("mysql:8.3")
|
||||||
.withExposedPorts(3306)
|
.withExposedPorts(3306)
|
||||||
.withEnvironment({ MYSQL_ROOT_PASSWORD: "password" })
|
.withEnvironment({ MYSQL_ROOT_PASSWORD: "password" })
|
||||||
.withWaitStrategy(
|
.withWaitStrategy(new MySQLWaitStrategy().withStartupTimeout(10000))
|
||||||
Wait.forSuccessfulCommand(
|
|
||||||
// Because MySQL first starts itself up, runs an init script, then restarts,
|
|
||||||
// it's possible for the mysqladmin ping to succeed early and then tests to
|
|
||||||
// run against a MySQL that's mid-restart and fail. To avoid this, we run
|
|
||||||
// the ping command three times with a small delay between each.
|
|
||||||
`
|
|
||||||
mysqladmin ping -h localhost -P 3306 -u root -ppassword && sleep 1 &&
|
|
||||||
mysqladmin ping -h localhost -P 3306 -u root -ppassword && sleep 1 &&
|
|
||||||
mysqladmin ping -h localhost -P 3306 -u root -ppassword && sleep 1 &&
|
|
||||||
mysqladmin ping -h localhost -P 3306 -u root -ppassword
|
|
||||||
`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,9 @@ export async function start(): Promise<StartedTestContainer> {
|
||||||
.withExposedPorts(5432)
|
.withExposedPorts(5432)
|
||||||
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
.withEnvironment({ POSTGRES_PASSWORD: "password" })
|
||||||
.withWaitStrategy(
|
.withWaitStrategy(
|
||||||
Wait.forSuccessfulCommand("pg_isready -h localhost -p 5432")
|
Wait.forSuccessfulCommand(
|
||||||
|
"pg_isready -h localhost -p 5432"
|
||||||
|
).withStartupTimeout(10000)
|
||||||
)
|
)
|
||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue