Merge pull request #13080 from Budibase/fix-flaky-backup-test
Ensure a backup is complete before attempting to import it.
This commit is contained in:
commit
cbb7acbddb
|
@ -8,7 +8,6 @@ import { mocks } from "@budibase/backend-core/tests"
|
||||||
mocks.licenses.useBackups()
|
mocks.licenses.useBackups()
|
||||||
|
|
||||||
describe("/backups", () => {
|
describe("/backups", () => {
|
||||||
let request = setup.getRequest()
|
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
|
|
||||||
afterAll(setup.afterAll)
|
afterAll(setup.afterAll)
|
||||||
|
@ -59,10 +58,8 @@ describe("/backups", () => {
|
||||||
await config.createScreen()
|
await config.createScreen()
|
||||||
const exportRes = await config.api.backup.createBackup(appId)
|
const exportRes = await config.api.backup.createBackup(appId)
|
||||||
expect(exportRes.backupId).toBeDefined()
|
expect(exportRes.backupId).toBeDefined()
|
||||||
const importRes = await config.api.backup.importBackup(
|
await config.api.backup.waitForBackupToComplete(appId, exportRes.backupId)
|
||||||
appId,
|
await config.api.backup.importBackup(appId, exportRes.backupId)
|
||||||
exportRes.backupId
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,19 @@ export class BackupAPI extends TestAPI {
|
||||||
return result.body as CreateAppBackupResponse
|
return result.body as CreateAppBackupResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitForBackupToComplete = async (appId: string, backupId: string) => {
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
|
const result = await this.request
|
||||||
|
.get(`/api/apps/${appId}/backups/${backupId}/file`)
|
||||||
|
.set(this.config.defaultHeaders())
|
||||||
|
if (result.status === 200) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Backup did not complete")
|
||||||
|
}
|
||||||
|
|
||||||
importBackup = async (
|
importBackup = async (
|
||||||
appId: string,
|
appId: string,
|
||||||
backupId: string
|
backupId: string
|
||||||
|
|
Loading…
Reference in New Issue