feat(docker): restore failed Compose updates and retain recent releases
This commit is contained in:
1 parent
fe1ee8a6fe
commit
745d0b7247
4 files changed
+159
-16
No files matched your search
@@ -29,6 +29,11 @@ function simulate(scenario: string) {
|
||||
const dir = mkdtempSync(join(tmpdir(), "cms-compose-test-"));
|
||||
try {
|
||||
mkdirSync(join(dir, "scripts"));
|
||||
mkdirSync(join(dir, "logs"));
|
||||
writeFileSync(
|
||||
join(dir, "logs/docker-release-history.log"),
|
||||
`${"b".repeat(40)}\n${"c".repeat(40)}\n`,
|
||||
);
|
||||
copyFileSync(
|
||||
resolve(root, "scripts/docker-update.sh"),
|
||||
join(dir, "scripts/docker-update.sh"),
|
||||
@@ -50,6 +55,7 @@ function simulate(scenario: string) {
|
||||
if (result.error) throw result.error;
|
||||
return {
|
||||
status: result.status,
|
||||
restored: existsSync(join(dir, "restored")),
|
||||
output: result.stdout + result.stderr,
|
||||
calls: existsSync(join(dir, "calls"))
|
||||
? readFileSync(join(dir, "calls"), "utf8")
|
||||
@@ -60,6 +66,32 @@ function simulate(scenario: string) {
|
||||
}
|
||||
}
|
||||
describe("Docker clone updates", () => {
|
||||
it("removes only historical release tags beyond the current and previous", () => {
|
||||
const r = simulate("success");
|
||||
expect(r.calls).toContain(`docker image rm epicnext-cms:${"c".repeat(40)}`);
|
||||
expect(r.calls).not.toContain(
|
||||
`docker image rm epicnext-cms:${"b".repeat(40)}`,
|
||||
);
|
||||
});
|
||||
it("preserves older images used by another container", () => {
|
||||
const r = simulate("retained-in-use");
|
||||
expect(r.status, r.output).toBe(0);
|
||||
expect(r.calls).not.toContain(
|
||||
`docker image rm epicnext-cms:${"c".repeat(40)}`,
|
||||
);
|
||||
});
|
||||
it("reports an unsuccessful rollback and retains the recovery image", () => {
|
||||
const r = simulate("rollback-failure");
|
||||
expect(r.status).not.toBe(0);
|
||||
expect(r.output).toContain("rollback could not recreate CMS");
|
||||
expect(r.calls).not.toContain("docker image rm epicnext-cms:rollback-");
|
||||
});
|
||||
it("handles first installation failures without claiming rollback", () => {
|
||||
const r = simulate("first-failure");
|
||||
expect(r.status).not.toBe(0);
|
||||
expect(r.restored).toBe(false);
|
||||
expect(r.output).toContain("no previous image exists");
|
||||
});
|
||||
it("builds the pulled commit, migrates before recreation and verifies local/public HTTP", () => {
|
||||
const r = simulate("success");
|
||||
expect(r.status, r.output).toBe(0);
|
||||
@@ -91,6 +123,8 @@ describe("Docker clone updates", () => {
|
||||
const r = simulate(scenario);
|
||||
expect(r.status, r.output).not.toBe(0);
|
||||
expect(r.output).not.toContain("Verified release");
|
||||
expect(r.restored).toBe(true);
|
||||
expect(r.output).toContain("Rollback verified locally");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user