Skip to content

Commit 8a184ea

Browse files
authored
Merge pull request #2071 from kubernetes-sigs/fix-sanity-test2
test: don't return error when deleting rg failed in sanity test
2 parents 0e0b26b + ec26726 commit 8a184ea

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

pkg/util/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func WaitUntilTimeout(timeout time.Duration, execFunc ExecFunc, timeoutFunc Time
219219
done := make(chan bool)
220220
var err error
221221

222-
// Start the azcopy exec function in a goroutine
222+
// Start exec function in a goroutine
223223
go func() {
224224
err = execFunc()
225225
done <- true

test/sanity/sanity_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestSanity(t *testing.T) {
5959
if strings.HasPrefix(creds.ResourceGroup, credentials.ResourceGroupPrefix) {
6060
log.Printf("Deleting resource group %s", creds.ResourceGroup)
6161
err := azureClient.DeleteResourceGroup(ctx, creds.ResourceGroup)
62-
assert.NoError(t, err)
62+
log.Printf("Deleted resource group %s failed with error %v", creds.ResourceGroup, err)
6363
}
6464
}()
6565

test/utils/azure/azure_helpers.go

+17-6
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,24 @@ func (az *Client) EnsureResourceGroup(ctx context.Context, name, location string
131131

132132
func (az *Client) DeleteResourceGroup(ctx context.Context, groupName string) error {
133133
_, err := az.groupsClient.Get(ctx, groupName)
134-
if err == nil {
135-
err := az.groupsClient.Delete(ctx, groupName)
136-
if err != nil {
137-
return fmt.Errorf("cannot delete resource group %v: %v", groupName, err)
138-
}
134+
if err != nil {
135+
return err
136+
}
137+
138+
timeout := 20 * time.Minute
139+
ch := make(chan bool, 1)
140+
141+
go func() {
142+
err = az.groupsClient.Delete(ctx, groupName)
143+
ch <- true
144+
}()
145+
146+
select {
147+
case <-ch:
148+
return err
149+
case <-time.After(timeout):
150+
return fmt.Errorf("timeout waiting for resource group %s to be deleted", groupName)
139151
}
140-
return nil
141152
}
142153

143154
func (az *Client) EnsureVirtualMachine(ctx context.Context, groupName, location, vmName string) (vm *compute.VirtualMachine, err error) {

0 commit comments

Comments
 (0)