Skip to content

Commit 57fab75

Browse files
authored
e2e tests: Extend the existing tests to cover tag actor. (agent-substrate#3511)
`TestActorSnapshotLifecycle` created a `Tag` and resumed a clone from it, but did not verify in e2e that the tag's snapshot copy survives deleting the source actor or that the clone's own snapshot survives `DeleteTag`. Delete `sourceName` before creating the clone from `tagRef`, and after the clone runs, suspend it, wait for background detach, delete `tagRef`, and resume the clone to verify its counters continue at `(3, 3)`. AI use: AI-assisted, I reviewed and tested it - [x] Tests pass - [ ] Docs updated --------- Signed-off-by: Nayana Bidari <[email protected]>
1 parent 30a0dea commit 57fab75

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

‎internal/e2e/suites/demo/demo_test.go‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ func TestActorSnapshotLifecycle(t *testing.T) {
275275
t.Fatalf("failed to publish Tag: %v", err)
276276
}
277277

278+
if _, err := e2e.RetryAborted(t, ctx, clients.SubstrateAPI.DeleteActor, &ateapi.DeleteActorRequest{
279+
Actor: &ateapi.ObjectRef{Atespace: demoAtespace, Name: sourceName},
280+
}); err != nil {
281+
t.Fatalf("failed to delete source Actor: %v", err)
282+
}
283+
278284
cloned, err := clients.SubstrateAPI.CreateActor(ctx, &ateapi.CreateActorRequest{
279285
Actor: &ateapi.Actor{
280286
Metadata: &ateapi.ResourceMetadata{Atespace: demoAtespace, Name: cloneName},
@@ -302,9 +308,41 @@ func TestActorSnapshotLifecycle(t *testing.T) {
302308
}
303309
validateCounterResponse(t, response, "clone", 2, 2)
304310

311+
// The clone's first suspend writes a snapshot of its own, so the clone
312+
// still resumes after DeleteTag collects the tag's snapshot.
313+
cloneSuspended, err := clients.SubstrateAPI.SuspendActor(ctx, &ateapi.SuspendActorRequest{
314+
Actor: &ateapi.ObjectRef{Atespace: demoAtespace, Name: cloneName},
315+
Options: &ateapi.SuspendOptions{Mode: tc.mode},
316+
})
317+
if err != nil {
318+
t.Fatalf("failed to suspend cloned Actor: %v", err)
319+
}
320+
cloneSnap := snapshotAtLatestGeneration(cloneSuspended.GetActor().GetStatus())
321+
if got := cloneSnap.GetDurableSnapshot().GetState(); got != tc.wantStorage {
322+
t.Fatalf("cloned Actor snapshot DurableSnapshot.State = %v, want %v", got, tc.wantStorage)
323+
}
324+
if got := cloneSnap.GetDurableSnapshot().GetObject().GetSnapshotUri(); got == "" || got == tagSnapshotURI(tagToUpdate) {
325+
t.Fatalf("cloned Actor snapshot uri = %q, want a snapshot of its own", got)
326+
}
305327
if _, err := clients.SubstrateAPI.DeleteTag(ctx, &ateapi.DeleteTagRequest{Tag: tagRef}); err != nil {
306328
t.Fatalf("failed to delete Tag: %v", err)
307329
}
330+
t.Run("BackgroundDetach", func(t *testing.T) {
331+
e2e.RequireShortSnapshotDelays(t, ctx, maxSnapshotDelay)
332+
waitForActorDetached(ctx, t, clients, cloneName, cloneSnap.GetUuid())
333+
})
334+
335+
// Resuming restores the clone's snapshot from object storage after the
336+
// detach, or from its node-local copy when BackgroundDetach is skipped.
337+
if _, err := e2e.ResumeActorAwaitCapacity(t, ctx, clients, &ateapi.ResumeActorRequest{Actor: &ateapi.ObjectRef{Atespace: demoAtespace, Name: cloneName}}); err != nil {
338+
t.Fatalf("failed to resume cloned Actor after DeleteTag: %v", err)
339+
}
340+
waitForActorState(ctx, t, clients, cloneName, ateapi.ActorState_ACTOR_STATE_RUNNING)
341+
response, err = callActor(t, resources.ActorRef{Atespace: demoAtespace, Name: cloneName})
342+
if err != nil {
343+
t.Fatalf("failed to call cloned Actor after DeleteTag: %v", err)
344+
}
345+
validateCounterResponse(t, response, "clone after DeleteTag", 3, 3)
308346
})
309347
}
310348
}

0 commit comments

Comments
 (0)