Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 160ebdc

Browse files
committed
Wait for the service to be ready and delete
We have been seeing some flakes in TestServiceIgnoreCleanup related to the service not being deleted when we force it to delete. This change will wait for the service to be in a deleting state before we force. Signed-off-by: Donnie Adams <[email protected]>
1 parent a2b288d commit 160ebdc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

integration/services/services_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package services
22

33
import (
44
"testing"
5-
"time"
65

76
"github.com/acorn-io/runtime/integration/helper"
87
apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1"
8+
v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1"
99
"github.com/acorn-io/runtime/pkg/client"
10+
"github.com/acorn-io/runtime/pkg/labels"
1011
"github.com/stretchr/testify/assert"
1112
)
1213

@@ -56,8 +57,10 @@ func TestServiceIgnoreCleanup(t *testing.T) {
5657
t.Fatal(err)
5758
}
5859

59-
// Sleep for 1 second to give the controller time to create the service.
60-
time.Sleep(1 * time.Second)
60+
helper.Wait(t, helper.Watcher(t, c), &apiv1.AppList{}, func(obj *apiv1.App) bool {
61+
// Just wait for the service to go through the controller successfully
62+
return obj.Labels[labels.AcornPublicName] == "myapp.myservice" && obj.Status.Condition(v1.AppInstanceConditionController).Success
63+
})
6164

6265
// Delete the app.
6366
if _, err := c.AppDelete(ctx, "myapp"); err != nil {
@@ -74,6 +77,10 @@ func TestServiceIgnoreCleanup(t *testing.T) {
7477
assert.Len(t, list, 1)
7578
assert.Equal(t, "myapp.myservice", list[0].Name)
7679

80+
helper.Wait(t, helper.Watcher(t, c), &apiv1.AppList{}, func(obj *apiv1.App) bool {
81+
return obj.Labels[labels.AcornPublicName] == "myapp.myservice" && !obj.DeletionTimestamp.IsZero()
82+
})
83+
7784
// Delete it next.
7885
if err := c.AppIgnoreDeleteCleanup(ctx, "myapp.myservice"); err != nil {
7986
t.Fatal(err)

0 commit comments

Comments
 (0)