Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jananivMS committed Apr 9, 2020
1 parent 3bb8cb0 commit 182a66a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
18 changes: 4 additions & 14 deletions controllers/storage_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ package controllers

import (
"context"
"strings"
"testing"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
config "github.com/Azure/azure-service-operator/pkg/resourcemanager/config"

"github.com/Azure/go-autorest/autorest/to"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

func TestStorageControllerHappyPathWithoutNetworkRule(t *testing.T) {
Expand Down Expand Up @@ -50,10 +47,8 @@ func TestStorageControllerHappyPathWithNetworkRule(t *testing.T) {
t.Parallel()
defer PanicRecover(t)
ctx := context.Background()
assert := assert.New(t)
var err error

StorageAccountName := GenerateTestResourceNameWithRandom("storage", 10)
StorageAccountName := GenerateAlphaNumTestResourceName("sanet")

rgName := tc.resourceGroupName
rgLocation := tc.resourceGroupLocation
Expand Down Expand Up @@ -124,15 +119,10 @@ func TestStorageControllerHappyPathWithNetworkRule(t *testing.T) {
},
}

err = tc.k8sClient.Create(ctx, cnInstance)
assert.Equal(nil, err, "create StorageAccount in k8s")
EnsureInstance(ctx, t, tc, cnInstance)

storageAccountNamespacedName := types.NamespacedName{Name: StorageAccountName, Namespace: "default"}
// Delete instance

// Wait for the APIMgmtAPI instance to be written to k8s
assert.Eventually(func() bool {
err = tc.k8sClient.Get(ctx, storageAccountNamespacedName, cnInstance)
return strings.Contains(cnInstance.Status.Message, successMsg)
}, tc.timeout, tc.retry, "awaiting storageAccount instance creation")
EnsureDelete(ctx, t, tc, cnInstance)

}
3 changes: 3 additions & 0 deletions pkg/resourcemanager/storages/storageaccount/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"log"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage"
"github.com/Azure/azure-service-operator/api/v1alpha1"
Expand Down Expand Up @@ -136,6 +137,8 @@ func (_ *azureStorageManager) CreateStorage(ctx context.Context,
return result, err
}

time.Sleep(2 * time.Second)

return future.Result(storagesClient)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (sa *azureStorageManager) Ensure(ctx context.Context, obj runtime.Object, o
_, err = sa.CreateStorage(ctx, groupName, name, location, sku, kind, labels, accessTier, enableHTTPSTrafficOnly, dataLakeEnabled, &networkAcls)
if err != nil {
instance.Status.Message = err.Error()
fmt.Println(err.Error())
azerr := errhelp.NewAzureErrorAzureError(err)
instance.Status.Provisioning = false

Expand Down Expand Up @@ -118,8 +119,10 @@ func (sa *azureStorageManager) Ensure(ctx context.Context, obj runtime.Object, o

stop := []string{
errhelp.AccountNameInvalid,
errhelp.NetworkAclsValidationFailure,
}
if helpers.ContainsString(stop, azerr.Type) {
instance.Status.Provisioning = false
return true, nil
}

Expand Down

0 comments on commit 182a66a

Please sign in to comment.