diff --git a/pkg/util/util.go b/pkg/util/util.go index 47fbf4e31a..734bbeea88 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -219,7 +219,7 @@ func WaitUntilTimeout(timeout time.Duration, execFunc ExecFunc, timeoutFunc Time done := make(chan bool) var err error - // Start the azcopy exec function in a goroutine + // Start exec function in a goroutine go func() { err = execFunc() done <- true diff --git a/test/sanity/sanity_test.go b/test/sanity/sanity_test.go index 2476830159..0813bc78c6 100644 --- a/test/sanity/sanity_test.go +++ b/test/sanity/sanity_test.go @@ -59,7 +59,7 @@ func TestSanity(t *testing.T) { if strings.HasPrefix(creds.ResourceGroup, credentials.ResourceGroupPrefix) { log.Printf("Deleting resource group %s", creds.ResourceGroup) err := azureClient.DeleteResourceGroup(ctx, creds.ResourceGroup) - assert.NoError(t, err) + log.Printf("Deleted resource group %s failed with error %v", creds.ResourceGroup, err) } }() diff --git a/test/utils/azure/azure_helpers.go b/test/utils/azure/azure_helpers.go index b75ce37072..a1f7e6497a 100644 --- a/test/utils/azure/azure_helpers.go +++ b/test/utils/azure/azure_helpers.go @@ -131,13 +131,24 @@ func (az *Client) EnsureResourceGroup(ctx context.Context, name, location string func (az *Client) DeleteResourceGroup(ctx context.Context, groupName string) error { _, err := az.groupsClient.Get(ctx, groupName) - if err == nil { - err := az.groupsClient.Delete(ctx, groupName) - if err != nil { - return fmt.Errorf("cannot delete resource group %v: %v", groupName, err) - } + if err != nil { + return err + } + + timeout := 20 * time.Minute + ch := make(chan bool, 1) + + go func() { + err = az.groupsClient.Delete(ctx, groupName) + ch <- true + }() + + select { + case <-ch: + return err + case <-time.After(timeout): + return fmt.Errorf("timeout waiting for resource group %s to be deleted", groupName) } - return nil } func (az *Client) EnsureVirtualMachine(ctx context.Context, groupName, location, vmName string) (vm *compute.VirtualMachine, err error) {