@@ -2,11 +2,12 @@ package services
22
33import (
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