feat: add CI deployment and live progress
This commit is contained in:
@@ -14,7 +14,10 @@ import {
|
||||
KubernetesWorkspacePersistence,
|
||||
type LeaseObjects,
|
||||
} from "../../server/kubernetes-state";
|
||||
import type { Operation } from "../../server/operation-store";
|
||||
import {
|
||||
PersistentOperationStore,
|
||||
type Operation,
|
||||
} from "../../server/operation-store";
|
||||
import type {
|
||||
Workspace,
|
||||
WorkspaceRevision,
|
||||
@@ -183,6 +186,42 @@ describe("Kubernetes state persistence", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("keeps operation progress in the Kubernetes-backed operation record", async () => {
|
||||
const fake = new FakeObjects();
|
||||
const store = new PersistentOperationStore(
|
||||
new KubernetesOperationPersistence(
|
||||
fake as unknown as KubernetesObjectApi,
|
||||
),
|
||||
() => new Date(timestamp),
|
||||
() => "event-id",
|
||||
);
|
||||
const created = await store.create({
|
||||
workspaceId: "demo",
|
||||
action: "resources.apply",
|
||||
idempotencyKey: "events",
|
||||
});
|
||||
await store.emit(created.metadata.name, {
|
||||
resource: { apiVersion: "v1", kind: "ConfigMap", name: "settings" },
|
||||
phase: "apply",
|
||||
state: "succeeded",
|
||||
});
|
||||
const reloaded = new PersistentOperationStore(
|
||||
new KubernetesOperationPersistence(
|
||||
fake as unknown as KubernetesObjectApi,
|
||||
),
|
||||
);
|
||||
expect(await reloaded.events(created.metadata.name)).toMatchObject({
|
||||
items: [
|
||||
expect.objectContaining({
|
||||
sequence: 1,
|
||||
data: expect.objectContaining({ phase: "apply" }),
|
||||
}),
|
||||
],
|
||||
retainedFirstSequence: 1,
|
||||
cursorGap: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("recovers replacement from a matching precreated revision", async () => {
|
||||
const fake = new FakeObjects();
|
||||
const persistence = new KubernetesWorkspacePersistence(
|
||||
@@ -365,7 +404,11 @@ class FakeLeaseStore implements LeaseObjects {
|
||||
return structuredClone(stored);
|
||||
}
|
||||
|
||||
async delete(name: string, namespace: string, expectedResourceVersion?: string) {
|
||||
async delete(
|
||||
name: string,
|
||||
namespace: string,
|
||||
expectedResourceVersion?: string,
|
||||
) {
|
||||
this.beforeDelete?.();
|
||||
this.beforeDelete = undefined;
|
||||
const key = this.key(name, namespace);
|
||||
|
||||
Reference in New Issue
Block a user