diff --git a/azure/services/agentpools/agentpools_test.go b/azure/services/agentpools/agentpools_test.go index 60b37cdd1b1..95f76d364c8 100644 --- a/azure/services/agentpools/agentpools_test.go +++ b/azure/services/agentpools/agentpools_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools/mock_agentpools" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) @@ -38,12 +38,12 @@ func TestReconcileAgentPools(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "agent pool successfully created with autoscaling enabled", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(sdkFakeAgentPool(sdkWithAutoscaling(true), sdkWithCount(1)), nil) @@ -55,7 +55,7 @@ func TestReconcileAgentPools(t *testing.T) { { name: "agent pool successfully created with autoscaling disabled", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(sdkFakeAgentPool(sdkWithAutoscaling(false), sdkWithCount(1)), nil) @@ -67,14 +67,14 @@ func TestReconcileAgentPools(t *testing.T) { { name: "no agent pool spec found", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AgentPoolSpec().Return(nil) }, }, { name: "fail to create a agent pool", expectedError: internalError.Error(), - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(nil, internalError) @@ -91,7 +91,7 @@ func TestReconcileAgentPools(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_agentpools.NewMockAgentPoolScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -115,12 +115,12 @@ func TestDeleteAgentPools(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "existing agent pool successfully deleted", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(nil) @@ -130,14 +130,14 @@ func TestDeleteAgentPools(t *testing.T) { { name: "no agent pool spec found", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AgentPoolSpec().Return(nil) }, }, { name: "fail to delete a agent pool", expectedError: internalError.Error(), - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(internalError) @@ -154,7 +154,7 @@ func TestDeleteAgentPools(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_agentpools.NewMockAgentPoolScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/async/async.go b/azure/services/async/async.go deleted file mode 100644 index d2646cfbbb7..00000000000 --- a/azure/services/async/async.go +++ /dev/null @@ -1,244 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package async - -import ( - "context" - "fmt" - "net/http" - "strconv" - "time" - - "github.com/Azure/go-autorest/autorest" - azureautorest "github.com/Azure/go-autorest/autorest/azure" - "github.com/pkg/errors" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" -) - -// Service is an implementation of the Reconciler interface. It handles asynchronous creation and deletion of resources. -type Service struct { - Scope FutureScope - Creator - Deleter -} - -// New creates a new async service. -func New(scope FutureScope, createClient Creator, deleteClient Deleter) *Service { - return &Service{ - Scope: scope, - Creator: createClient, - Deleter: deleteClient, - } -} - -// processOngoingOperation is a helper function that will process an ongoing operation to check if it is done. -// If it is not done, it will return a transient error. -func processOngoingOperation(ctx context.Context, scope FutureScope, client FutureHandler, resourceName string, serviceName string, futureType string) (result interface{}, err error) { - ctx, log, done := tele.StartSpanWithLogger(ctx, "async.Service.processOngoingOperation") - defer done() - - future := scope.GetLongRunningOperationState(resourceName, serviceName, futureType) - if future == nil { - log.V(2).Info("no long running operation found", "service", serviceName, "resource", resourceName) - return nil, nil - } - sdkFuture, err := converters.FutureToSDK(*future) - if err != nil { - // Reset the future data to avoid getting stuck in a bad loop. - // In theory, this should never happen, but if for some reason the future that is already stored in Status isn't properly formatted - // and we don't reset it we would be stuck in an infinite loop trying to parse it. - scope.DeleteLongRunningOperationState(resourceName, serviceName, futureType) - return nil, errors.Wrap(err, "could not decode future data, resetting long-running operation state") - } - - isDone, err := client.IsDone(ctx, sdkFuture) - // Assume that if isDone is true, then we successfully checked that the - // operation was complete even if err is non-nil. Assume the error in that - // case is unrelated and will be captured in Result below. - if !isDone { - if err != nil { - return nil, errors.Wrap(err, "failed checking if the operation was complete") - } - - // Operation is still in progress, update conditions and requeue. - log.V(2).Info("long running operation is still ongoing", "service", serviceName, "resource", resourceName) - return nil, azure.WithTransientError(azure.NewOperationNotDoneError(future), getRequeueAfterFromFuture(sdkFuture)) - } - if err != nil { - log.V(2).Error(err, "error checking long running operation status after it finished") - } - - // Once the operation is done, we can delete the long running operation state. - // If the operation failed, this will allow it to be retried during the next reconciliation. - // If the resource is not found, we also reset the long-running operation state so we can attempt to create it again. - // This can happen if the resource was deleted by another process before we could get the result. - scope.DeleteLongRunningOperationState(resourceName, serviceName, futureType) - - // Resource has been created/deleted/updated. - log.V(2).Info("long running operation has completed", "service", serviceName, "resource", resourceName) - return client.Result(ctx, sdkFuture, future.Type) -} - -// CreateOrUpdateResource implements the logic for creating a new, or updating an existing, resource Asynchronously. -func (s *Service) CreateOrUpdateResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (result interface{}, err error) { - ctx, log, done := tele.StartSpanWithLogger(ctx, "async.Service.CreateOrUpdateResource") - defer done() - - resourceName := spec.ResourceName() - rgName := spec.ResourceGroupName() - futureType := infrav1.PutFuture - - // Check if there is an ongoing long running operation. - future := s.Scope.GetLongRunningOperationState(resourceName, serviceName, futureType) - if future != nil { - return processOngoingOperation(ctx, s.Scope, s.Creator, resourceName, serviceName, futureType) - } - - // Get the resource if it already exists, and use it to construct the desired resource parameters. - var existingResource interface{} - if existing, err := s.Creator.Get(ctx, spec); err != nil && !azure.ResourceNotFound(err) { - errWrapped := errors.Wrapf(err, "failed to get existing resource %s/%s (service: %s)", rgName, resourceName, serviceName) - return nil, azure.WithTransientError(errWrapped, getRetryAfterFromError(err)) - } else if err == nil { - existingResource = existing - log.V(2).Info("successfully got existing resource", "service", serviceName, "resource", resourceName, "resourceGroup", rgName) - } - - // Construct parameters using the resource spec and information from the existing resource, if there is one. - parameters, err := spec.Parameters(ctx, existingResource) - if err != nil { - return nil, errors.Wrapf(err, "failed to get desired parameters for resource %s/%s (service: %s)", rgName, resourceName, serviceName) - } else if parameters == nil { - // Nothing to do, don't create or update the resource and return the existing resource. - log.V(2).Info("resource up to date", "service", serviceName, "resource", resourceName, "resourceGroup", rgName) - return existingResource, nil - } - - // Create or update the resource with the desired parameters. - logMessageVerbPrefix := "creat" - if existingResource != nil { - logMessageVerbPrefix = "updat" - } - log.V(2).Info(fmt.Sprintf("%sing resource", logMessageVerbPrefix), "service", serviceName, "resource", resourceName, "resourceGroup", rgName) - result, sdkFuture, err := s.Creator.CreateOrUpdateAsync(ctx, spec, parameters) - errWrapped := errors.Wrapf(err, fmt.Sprintf("failed to %se resource %s/%s (service: %s)", logMessageVerbPrefix, rgName, resourceName, serviceName)) - - if sdkFuture != nil { - future, err := converters.SDKToFuture(sdkFuture, infrav1.PutFuture, serviceName, resourceName, rgName) - if err != nil { - return nil, errWrapped - } - s.Scope.SetLongRunningOperationState(future) - return nil, azure.WithTransientError(azure.NewOperationNotDoneError(future), getRequeueAfterFromFuture(sdkFuture)) - } else if err != nil { - // If it is an intermittent failure with context deadline exceeded or canceled as the reconciler could not complete - // in the max amount of time, mark it as a transient error and return. - if azure.IsContextDeadlineExceededOrCanceledError(ctx.Err()) { - return nil, azure.WithTransientError(errWrapped, getRetryAfterFromError(err)) - } - return nil, errWrapped - } - - log.V(2).Info(fmt.Sprintf("successfully %sed resource", logMessageVerbPrefix), "service", serviceName, "resource", resourceName, "resourceGroup", rgName) - return result, nil -} - -// DeleteResource implements the logic for deleting a resource Asynchronously. -func (s *Service) DeleteResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (err error) { - ctx, log, done := tele.StartSpanWithLogger(ctx, "async.Service.DeleteResource") - defer done() - - resourceName := spec.ResourceName() - rgName := spec.ResourceGroupName() - futureType := infrav1.DeleteFuture - - // Check if there is an ongoing long running operation. - future := s.Scope.GetLongRunningOperationState(resourceName, serviceName, futureType) - if future != nil { - _, err := processOngoingOperation(ctx, s.Scope, s.Deleter, resourceName, serviceName, futureType) - return err - } - - // No long running operation is active, so delete the resource. - log.V(2).Info("deleting resource", "service", serviceName, "resource", resourceName, "resourceGroup", rgName) - sdkFuture, err := s.Deleter.DeleteAsync(ctx, spec) - - if sdkFuture != nil { - future, err := converters.SDKToFuture(sdkFuture, infrav1.DeleteFuture, serviceName, resourceName, rgName) - if err != nil { - return errors.Wrapf(err, "failed to delete resource %s/%s (service: %s)", rgName, resourceName, serviceName) - } - s.Scope.SetLongRunningOperationState(future) - return azure.WithTransientError(azure.NewOperationNotDoneError(future), getRequeueAfterFromFuture(sdkFuture)) - } else if err != nil { - if azure.ResourceNotFound(err) { - // already deleted - return nil - } - // If it is an intermittent failure with context deadline exceeded or canceled as the reconciler could not complete - // in the max amount of time, mark it as a transient error and return. - if azure.IsContextDeadlineExceededOrCanceledError(ctx.Err()) { - return azure.WithTransientError(err, getRetryAfterFromError(err)) - } - return errors.Wrapf(err, "failed to delete resource %s/%s (service: %s)", rgName, resourceName, serviceName) - } - - log.V(2).Info("successfully deleted resource", "service", serviceName, "resource", resourceName, "resourceGroup", rgName) - return nil -} - -// getRequeueAfterFromFuture returns the max between the `RETRY-AFTER` header and the default requeue time. -// This ensures we respect the retry-after header if it is set and avoid retrying too often during an API throttling event. -func getRequeueAfterFromFuture(sdkFuture azureautorest.FutureAPI) time.Duration { - retryAfter, _ := sdkFuture.GetPollingDelay() - if retryAfter < reconciler.DefaultReconcilerRequeue { - retryAfter = reconciler.DefaultReconcilerRequeue - } - return retryAfter -} - -// getRetryAfterFromError returns the time.Duration from the http.Response in the autorest.DetailedError. -// If there is no Response object, or if there is no meaningful Retry-After header data, we return a default. -func getRetryAfterFromError(err error) time.Duration { - // In case we aren't able to introspect Retry-After from the error type, we'll return this default - ret := reconciler.DefaultReconcilerRequeue - var detailedError autorest.DetailedError - // if we have a strongly typed autorest.DetailedError then we can introspect the HTTP response data - if errors.As(err, &detailedError) { - if detailedError.Response != nil { - // If we have Retry-After HTTP header data for any reason, prefer it - if retryAfter := detailedError.Response.Header.Get("Retry-After"); retryAfter != "" { - // This handles the case where Retry-After data is in the form of units of seconds - if rai, err := strconv.Atoi(retryAfter); err == nil { - ret = time.Duration(rai) * time.Second - // This handles the case where Retry-After data is in the form of absolute time - } else if t, err := time.Parse(time.RFC1123, retryAfter); err == nil { - ret = time.Until(t) - } - // If we didn't find Retry-After HTTP header data but the response type is 429, - // we'll have to come up with our sane default. - } else if detailedError.Response.StatusCode == http.StatusTooManyRequests { - ret = reconciler.DefaultHTTP429RetryAfter - } - } - } - return ret -} diff --git a/azure/services/async/async_test.go b/azure/services/async/async_test.go deleted file mode 100644 index 116bc3fa350..00000000000 --- a/azure/services/async/async_test.go +++ /dev/null @@ -1,521 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package async - -import ( - "context" - "errors" - "net/http" - "testing" - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - "github.com/Azure/go-autorest/autorest" - azureautorest "github.com/Azure/go-autorest/autorest/azure" - . "github.com/onsi/gomega" - "go.uber.org/mock/gomock" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" - gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" -) - -var ( - validCreateFuture = infrav1.Future{ - Type: infrav1.PutFuture, - ServiceName: "test-service", - Name: "test-resource", - ResourceGroup: "test-group", - Data: "eyJtZXRob2QiOiJQVVQiLCJwb2xsaW5nTWV0aG9kIjoiTG9jYXRpb24iLCJscm9TdGF0ZSI6IkluUHJvZ3Jlc3MifQ==", - } - validDeleteFuture = infrav1.Future{ - Type: infrav1.DeleteFuture, - ServiceName: "test-service", - Name: "test-resource", - ResourceGroup: "test-group", - Data: "eyJtZXRob2QiOiJERUxFVEUiLCJwb2xsaW5nTWV0aG9kIjoiTG9jYXRpb24iLCJscm9TdGF0ZSI6IkluUHJvZ3Jlc3MifQ==", - } - invalidFuture = infrav1.Future{ - Type: infrav1.DeleteFuture, - ServiceName: "test-service", - Name: "test-resource", - ResourceGroup: "test-group", - Data: "ZmFrZSBiNjQgZnV0dXJlIGRhdGEK", - } - fakeExistingResource = armresources.GenericResource{} - fakeResourceParameters = armresources.GenericResource{} - fakeInternalError = autorest.NewErrorWithResponse("", "", &http.Response{StatusCode: http.StatusInternalServerError}, "Internal Server Error") - fakeNotFoundError = autorest.NewErrorWithResponse("", "", &http.Response{StatusCode: http.StatusNotFound}, "Not Found") - errCtxExceeded = errors.New("ctx exceeded") -) - -// TestProcessOngoingOperation tests the processOngoingOperation function. -func TestProcessOngoingOperation(t *testing.T) { - testcases := []struct { - name string - resourceName string - serviceName string - futureType string - expectedError string - expectedResult interface{} - expect func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) - }{ - { - name: "no future data stored in status", - expectedError: "", - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(nil) - }, - }, - { - name: "future data is not valid", - expectedError: "could not decode future data, resetting long-running operation state", - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&invalidFuture) - s.DeleteLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture) - }, - }, - { - name: "fail to check if ongoing operation is done", - expectedError: "failed checking if the operation was complete", - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(false, fakeInternalError) - }, - }, - { - name: "ongoing operation is not done", - expectedError: "operation type DELETE on Azure resource test-group/test-resource is not done", - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(false, nil) - }, - }, - { - name: "operation is done", - expectedError: "", - expectedResult: &fakeExistingResource, - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(true, nil) - c.Result(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{}), infrav1.DeleteFuture).Return(&fakeExistingResource, nil) - s.DeleteLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture) - }, - }, - { - name: "resource was deleted by an external process", - expectedError: fakeNotFoundError.Error(), - expectedResult: nil, - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(true, nil) - c.Result(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{}), infrav1.DeleteFuture).Return(nil, fakeNotFoundError) - s.DeleteLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture) - }, - }, - { - name: "failed to get resulting resource", - expectedError: fakeInternalError.Error(), - expectedResult: nil, - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(true, nil) - c.Result(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{}), infrav1.DeleteFuture).Return(nil, fakeInternalError) - s.DeleteLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture) - }, - }, - { - name: "terminal failure with IsDone error", - expectedError: fakeInternalError.Error(), - expectedResult: nil, - resourceName: "test-resource", - serviceName: "test-service", - futureType: infrav1.DeleteFuture, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockFutureHandlerMockRecorder) { - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(true, errors.New("IsDone error")) - c.Result(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{}), infrav1.DeleteFuture).Return(nil, fakeInternalError) - s.DeleteLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture) - }, - }, - } - - for _, tc := range testcases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - g := NewWithT(t) - - t.Parallel() - mockCtrl := gomock.NewController(t) - defer mockCtrl.Finish() - scopeMock := mock_async.NewMockFutureScope(mockCtrl) - clientMock := mock_async.NewMockFutureHandler(mockCtrl) - - tc.expect(scopeMock.EXPECT(), clientMock.EXPECT()) - - result, err := processOngoingOperation(context.TODO(), scopeMock, clientMock, tc.resourceName, tc.serviceName, tc.futureType) - if tc.expectedError != "" { - g.Expect(err).To(HaveOccurred()) - g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) - } else { - g.Expect(err).NotTo(HaveOccurred()) - } - if tc.expectedResult != nil { - g.Expect(result).To(Equal(tc.expectedResult)) - } else { - g.Expect(result).To(BeNil()) - } - }) - } -} - -// TestCreateOrUpdateResource tests the CreateOrUpdateResource function. -func TestCreateOrUpdateResource(t *testing.T) { - testcases := []struct { - name string - serviceName string - expectedError string - expectedResult interface{} - expect func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) - }{ - { - name: "create operation is already in progress", - expectedError: "operation type PUT on Azure resource test-group/test-resource is not done. Object will be requeued after 15s", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Times(2).Return(&validCreateFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(false, nil) - }, - }, - { - name: "create async returns success", - expectedError: "", - expectedResult: "test-resource", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(&fakeExistingResource, nil) - r.Parameters(gomockinternal.AContext(), &fakeExistingResource).Return(&fakeResourceParameters, nil) - c.CreateOrUpdateAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{}), &fakeResourceParameters).Return("test-resource", nil, nil) - }, - }, - { - name: "error occurs while running async get", - expectedError: "failed to get existing resource test-group/test-resource (service: test-service)", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(nil, fakeInternalError) - }, - }, - { - name: "async get returns not found", - expectedError: "", - serviceName: "test-service", - expectedResult: &fakeExistingResource, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(nil, fakeNotFoundError) - r.Parameters(gomockinternal.AContext(), nil).Return(&fakeResourceParameters, nil) - c.CreateOrUpdateAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{}), &fakeResourceParameters).Return(&fakeExistingResource, nil, nil) - }, - }, - { - name: "error occurs while running async spec parameters", - expectedError: "failed to get desired parameters for resource test-group/test-resource (service: test-service)", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(&fakeExistingResource, nil) - r.Parameters(gomockinternal.AContext(), &fakeExistingResource).Return(nil, fakeInternalError) - }, - }, - { - name: "async spec parameters returns nil", - expectedError: "", - serviceName: "test-service", - expectedResult: &fakeExistingResource, - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(&fakeExistingResource, nil) - r.Parameters(gomockinternal.AContext(), &fakeExistingResource).Return(nil, nil) - }, - }, - { - name: "error occurs while running async create", - expectedError: "failed to update resource test-group/test-resource (service: test-service)", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(&fakeExistingResource, nil) - r.Parameters(gomockinternal.AContext(), &fakeExistingResource).Return(&fakeResourceParameters, nil) - c.CreateOrUpdateAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{}), &fakeResourceParameters).Return(nil, nil, fakeInternalError) - }, - }, - { - name: "create async exits before completing", - expectedError: "operation type PUT on Azure resource test-group/test-resource is not done. Object will be requeued after 15s", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.PutFuture).Return(nil) - c.Get(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(&fakeExistingResource, nil) - r.Parameters(gomockinternal.AContext(), &fakeExistingResource).Return(&fakeResourceParameters, nil) - c.CreateOrUpdateAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{}), &fakeResourceParameters).Return(nil, &azureautorest.Future{}, errCtxExceeded) - s.SetLongRunningOperationState(gomock.AssignableToTypeOf(&infrav1.Future{})) - }, - }, - } - - for _, tc := range testcases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - g := NewWithT(t) - - t.Parallel() - mockCtrl := gomock.NewController(t) - defer mockCtrl.Finish() - scopeMock := mock_async.NewMockFutureScope(mockCtrl) - creatorMock := mock_async.NewMockCreator(mockCtrl) - specMock := mock_azure.NewMockResourceSpecGetter(mockCtrl) - - tc.expect(scopeMock.EXPECT(), creatorMock.EXPECT(), specMock.EXPECT()) - - s := New(scopeMock, creatorMock, nil) - result, err := s.CreateOrUpdateResource(context.TODO(), specMock, tc.serviceName) - if tc.expectedError != "" { - g.Expect(err).To(HaveOccurred()) - g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) - } else { - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(result).To(Equal(tc.expectedResult)) - } - }) - } -} - -// TestDeleteResource tests the DeleteResource function. -func TestDeleteResource(t *testing.T) { - testcases := []struct { - name string - serviceName string - expectedError string - expect func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockDeleterMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) - }{ - { - name: "delete operation is already in progress", - expectedError: "operation type DELETE on Azure resource test-group/test-resource is not done. Object will be requeued after 15s", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockDeleterMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Times(2).Return(&validDeleteFuture) - c.IsDone(gomockinternal.AContext(), gomock.AssignableToTypeOf(&azureautorest.Future{})).Return(false, nil) - }, - }, - { - name: "delete async returns success", - expectedError: "", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockDeleterMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(nil) - c.DeleteAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(nil, nil) - }, - }, - { - name: "delete async returns not found", - expectedError: "", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockDeleterMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(nil) - c.DeleteAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(nil, fakeNotFoundError) - }, - }, - { - name: "error occurs while running async delete", - expectedError: "failed to delete resource test-group/test-resource (service: test-service)", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockDeleterMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(nil) - c.DeleteAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(nil, fakeInternalError) - }, - }, - { - name: "delete async exits before completing", - expectedError: "operation type DELETE on Azure resource test-group/test-resource is not done. Object will be requeued after 15s", - serviceName: "test-service", - expect: func(s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockDeleterMockRecorder, r *mock_azure.MockResourceSpecGetterMockRecorder) { - r.ResourceName().Return("test-resource") - r.ResourceGroupName().Return("test-group") - s.GetLongRunningOperationState("test-resource", "test-service", infrav1.DeleteFuture).Return(nil) - c.DeleteAsync(gomockinternal.AContext(), gomock.AssignableToTypeOf(&mock_azure.MockResourceSpecGetter{})).Return(&azureautorest.Future{}, errCtxExceeded) - s.SetLongRunningOperationState(gomock.AssignableToTypeOf(&infrav1.Future{})) - }, - }, - } - - for _, tc := range testcases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - g := NewWithT(t) - - t.Parallel() - mockCtrl := gomock.NewController(t) - defer mockCtrl.Finish() - scopeMock := mock_async.NewMockFutureScope(mockCtrl) - deleterMock := mock_async.NewMockDeleter(mockCtrl) - specMock := mock_azure.NewMockResourceSpecGetter(mockCtrl) - - tc.expect(scopeMock.EXPECT(), deleterMock.EXPECT(), specMock.EXPECT()) - - s := New(scopeMock, nil, deleterMock) - err := s.DeleteResource(context.TODO(), specMock, tc.serviceName) - if tc.expectedError != "" { - g.Expect(err).To(HaveOccurred()) - g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) - } else { - g.Expect(err).NotTo(HaveOccurred()) - } - }) - } -} - -func TestGetRetryAfterFromError(t *testing.T) { - cases := []struct { - name string - input error - expected time.Duration - expectedRangeTolerance time.Duration - }{ - { - name: "Retry-After header data present in the form of units of seconds", - input: autorest.DetailedError{ - Response: &http.Response{ - Header: http.Header{ - "Retry-After": []string{"2"}, - }, - }, - }, - expected: 2 * time.Second, - }, - { - name: "Retry-After header data present in the form of units of absolute time", - input: autorest.DetailedError{ - Response: &http.Response{ - Header: http.Header{ - "Retry-After": []string{time.Now().Add(1 * time.Hour).Format(time.RFC1123)}, - }, - }, - }, - expected: 1 * time.Hour, - expectedRangeTolerance: 5 * time.Second, - }, - { - name: "Retry-After header data not present", - input: autorest.DetailedError{ - Response: &http.Response{ - Header: http.Header{ - "foo": []string{"bar"}, - }, - }, - }, - expected: reconciler.DefaultReconcilerRequeue, - }, - { - name: "Retry-After header data not present in HTTP 429", - input: autorest.DetailedError{ - Response: &http.Response{ - StatusCode: http.StatusTooManyRequests, - Header: http.Header{ - "foo": []string{"bar"}, - }, - }, - }, - expected: reconciler.DefaultHTTP429RetryAfter, - }, - { - name: "nil http.Response", - input: autorest.DetailedError{ - Response: nil, - }, - expected: reconciler.DefaultReconcilerRequeue, - }, - { - name: "error type is not autorest.DetailedError", - input: errors.New("error"), - expected: reconciler.DefaultReconcilerRequeue, - }, - } - - for _, c := range cases { - c := c - t.Run(c.name, func(t *testing.T) { - t.Parallel() - g := NewWithT(t) - ret := getRetryAfterFromError(c.input) - if c.expectedRangeTolerance > 0 { - g.Expect(ret).To(BeNumerically("<", c.expected)) - g.Expect(ret + c.expectedRangeTolerance).To(BeNumerically(">", c.expected)) - } else { - g.Expect(ret).To(Equal(c.expected)) - } - }) - } -} diff --git a/azure/services/async/interfaces.go b/azure/services/async/interfaces.go deleted file mode 100644 index d39fde5b9bf..00000000000 --- a/azure/services/async/interfaces.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package async - -import ( - "context" - - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - azureautorest "github.com/Azure/go-autorest/autorest/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure" -) - -// FutureScope is a scope that can perform store futures and conditions in Status. -type FutureScope interface { - azure.AsyncStatusUpdater -} - -// FutureHandler is a client that can check on the progress of a future. -type FutureHandler interface { - // IsDone returns true if the operation is complete. - IsDone(ctx context.Context, future azureautorest.FutureAPI) (isDone bool, err error) - // Result returns the result of the operation. - Result(ctx context.Context, future azureautorest.FutureAPI, futureType string) (result interface{}, err error) -} - -// Getter is an interface that can get a resource. -type Getter interface { - Get(ctx context.Context, spec azure.ResourceSpecGetter) (result interface{}, err error) -} - -// TagsGetter is an interface that can get a tags resource. -type TagsGetter interface { - GetAtScope(ctx context.Context, scope string) (result armresources.TagsResource, err error) -} - -// Creator is a client that can create or update a resource asynchronously. -type Creator interface { - FutureHandler - Getter - CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, parameters interface{}) (result interface{}, future azureautorest.FutureAPI, err error) -} - -// Deleter is a client that can delete a resource asynchronously. -type Deleter interface { - FutureHandler - DeleteAsync(ctx context.Context, spec azure.ResourceSpecGetter) (future azureautorest.FutureAPI, err error) -} - -// Reconciler is a generic interface used to perform asynchronous reconciliation of Azure resources. -type Reconciler interface { - CreateOrUpdateResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (result interface{}, err error) - DeleteResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (err error) -} diff --git a/azure/services/async/mock_async/async_mock.go b/azure/services/async/mock_async/async_mock.go deleted file mode 100644 index d4c73988a2a..00000000000 --- a/azure/services/async/mock_async/async_mock.go +++ /dev/null @@ -1,463 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by MockGen. DO NOT EDIT. -// Source: ../interfaces.go - -// Package mock_async is a generated GoMock package. -package mock_async - -import ( - context "context" - reflect "reflect" - - armresources "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - azure "github.com/Azure/go-autorest/autorest/azure" - gomock "go.uber.org/mock/gomock" - v1beta1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - azure0 "sigs.k8s.io/cluster-api-provider-azure/azure" - v1beta10 "sigs.k8s.io/cluster-api/api/v1beta1" -) - -// MockFutureScope is a mock of FutureScope interface. -type MockFutureScope struct { - ctrl *gomock.Controller - recorder *MockFutureScopeMockRecorder -} - -// MockFutureScopeMockRecorder is the mock recorder for MockFutureScope. -type MockFutureScopeMockRecorder struct { - mock *MockFutureScope -} - -// NewMockFutureScope creates a new mock instance. -func NewMockFutureScope(ctrl *gomock.Controller) *MockFutureScope { - mock := &MockFutureScope{ctrl: ctrl} - mock.recorder = &MockFutureScopeMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockFutureScope) EXPECT() *MockFutureScopeMockRecorder { - return m.recorder -} - -// DeleteLongRunningOperationState mocks base method. -func (m *MockFutureScope) DeleteLongRunningOperationState(arg0, arg1, arg2 string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "DeleteLongRunningOperationState", arg0, arg1, arg2) -} - -// DeleteLongRunningOperationState indicates an expected call of DeleteLongRunningOperationState. -func (mr *MockFutureScopeMockRecorder) DeleteLongRunningOperationState(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLongRunningOperationState", reflect.TypeOf((*MockFutureScope)(nil).DeleteLongRunningOperationState), arg0, arg1, arg2) -} - -// GetLongRunningOperationState mocks base method. -func (m *MockFutureScope) GetLongRunningOperationState(arg0, arg1, arg2 string) *v1beta1.Future { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLongRunningOperationState", arg0, arg1, arg2) - ret0, _ := ret[0].(*v1beta1.Future) - return ret0 -} - -// GetLongRunningOperationState indicates an expected call of GetLongRunningOperationState. -func (mr *MockFutureScopeMockRecorder) GetLongRunningOperationState(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLongRunningOperationState", reflect.TypeOf((*MockFutureScope)(nil).GetLongRunningOperationState), arg0, arg1, arg2) -} - -// SetLongRunningOperationState mocks base method. -func (m *MockFutureScope) SetLongRunningOperationState(arg0 *v1beta1.Future) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetLongRunningOperationState", arg0) -} - -// SetLongRunningOperationState indicates an expected call of SetLongRunningOperationState. -func (mr *MockFutureScopeMockRecorder) SetLongRunningOperationState(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLongRunningOperationState", reflect.TypeOf((*MockFutureScope)(nil).SetLongRunningOperationState), arg0) -} - -// UpdateDeleteStatus mocks base method. -func (m *MockFutureScope) UpdateDeleteStatus(arg0 v1beta10.ConditionType, arg1 string, arg2 error) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "UpdateDeleteStatus", arg0, arg1, arg2) -} - -// UpdateDeleteStatus indicates an expected call of UpdateDeleteStatus. -func (mr *MockFutureScopeMockRecorder) UpdateDeleteStatus(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDeleteStatus", reflect.TypeOf((*MockFutureScope)(nil).UpdateDeleteStatus), arg0, arg1, arg2) -} - -// UpdatePatchStatus mocks base method. -func (m *MockFutureScope) UpdatePatchStatus(arg0 v1beta10.ConditionType, arg1 string, arg2 error) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "UpdatePatchStatus", arg0, arg1, arg2) -} - -// UpdatePatchStatus indicates an expected call of UpdatePatchStatus. -func (mr *MockFutureScopeMockRecorder) UpdatePatchStatus(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePatchStatus", reflect.TypeOf((*MockFutureScope)(nil).UpdatePatchStatus), arg0, arg1, arg2) -} - -// UpdatePutStatus mocks base method. -func (m *MockFutureScope) UpdatePutStatus(arg0 v1beta10.ConditionType, arg1 string, arg2 error) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "UpdatePutStatus", arg0, arg1, arg2) -} - -// UpdatePutStatus indicates an expected call of UpdatePutStatus. -func (mr *MockFutureScopeMockRecorder) UpdatePutStatus(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePutStatus", reflect.TypeOf((*MockFutureScope)(nil).UpdatePutStatus), arg0, arg1, arg2) -} - -// MockFutureHandler is a mock of FutureHandler interface. -type MockFutureHandler struct { - ctrl *gomock.Controller - recorder *MockFutureHandlerMockRecorder -} - -// MockFutureHandlerMockRecorder is the mock recorder for MockFutureHandler. -type MockFutureHandlerMockRecorder struct { - mock *MockFutureHandler -} - -// NewMockFutureHandler creates a new mock instance. -func NewMockFutureHandler(ctrl *gomock.Controller) *MockFutureHandler { - mock := &MockFutureHandler{ctrl: ctrl} - mock.recorder = &MockFutureHandlerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockFutureHandler) EXPECT() *MockFutureHandlerMockRecorder { - return m.recorder -} - -// IsDone mocks base method. -func (m *MockFutureHandler) IsDone(ctx context.Context, future azure.FutureAPI) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsDone", ctx, future) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// IsDone indicates an expected call of IsDone. -func (mr *MockFutureHandlerMockRecorder) IsDone(ctx, future interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDone", reflect.TypeOf((*MockFutureHandler)(nil).IsDone), ctx, future) -} - -// Result mocks base method. -func (m *MockFutureHandler) Result(ctx context.Context, future azure.FutureAPI, futureType string) (interface{}, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Result", ctx, future, futureType) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Result indicates an expected call of Result. -func (mr *MockFutureHandlerMockRecorder) Result(ctx, future, futureType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Result", reflect.TypeOf((*MockFutureHandler)(nil).Result), ctx, future, futureType) -} - -// MockGetter is a mock of Getter interface. -type MockGetter struct { - ctrl *gomock.Controller - recorder *MockGetterMockRecorder -} - -// MockGetterMockRecorder is the mock recorder for MockGetter. -type MockGetterMockRecorder struct { - mock *MockGetter -} - -// NewMockGetter creates a new mock instance. -func NewMockGetter(ctrl *gomock.Controller) *MockGetter { - mock := &MockGetter{ctrl: ctrl} - mock.recorder = &MockGetterMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockGetter) EXPECT() *MockGetterMockRecorder { - return m.recorder -} - -// Get mocks base method. -func (m *MockGetter) Get(ctx context.Context, spec azure0.ResourceSpecGetter) (interface{}, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, spec) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockGetterMockRecorder) Get(ctx, spec interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockGetter)(nil).Get), ctx, spec) -} - -// MockTagsGetter is a mock of TagsGetter interface. -type MockTagsGetter struct { - ctrl *gomock.Controller - recorder *MockTagsGetterMockRecorder -} - -// MockTagsGetterMockRecorder is the mock recorder for MockTagsGetter. -type MockTagsGetterMockRecorder struct { - mock *MockTagsGetter -} - -// NewMockTagsGetter creates a new mock instance. -func NewMockTagsGetter(ctrl *gomock.Controller) *MockTagsGetter { - mock := &MockTagsGetter{ctrl: ctrl} - mock.recorder = &MockTagsGetterMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockTagsGetter) EXPECT() *MockTagsGetterMockRecorder { - return m.recorder -} - -// GetAtScope mocks base method. -func (m *MockTagsGetter) GetAtScope(ctx context.Context, scope string) (armresources.TagsResource, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAtScope", ctx, scope) - ret0, _ := ret[0].(armresources.TagsResource) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetAtScope indicates an expected call of GetAtScope. -func (mr *MockTagsGetterMockRecorder) GetAtScope(ctx, scope interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAtScope", reflect.TypeOf((*MockTagsGetter)(nil).GetAtScope), ctx, scope) -} - -// MockCreator is a mock of Creator interface. -type MockCreator struct { - ctrl *gomock.Controller - recorder *MockCreatorMockRecorder -} - -// MockCreatorMockRecorder is the mock recorder for MockCreator. -type MockCreatorMockRecorder struct { - mock *MockCreator -} - -// NewMockCreator creates a new mock instance. -func NewMockCreator(ctrl *gomock.Controller) *MockCreator { - mock := &MockCreator{ctrl: ctrl} - mock.recorder = &MockCreatorMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCreator) EXPECT() *MockCreatorMockRecorder { - return m.recorder -} - -// CreateOrUpdateAsync mocks base method. -func (m *MockCreator) CreateOrUpdateAsync(ctx context.Context, spec azure0.ResourceSpecGetter, parameters interface{}) (interface{}, azure.FutureAPI, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateOrUpdateAsync", ctx, spec, parameters) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(azure.FutureAPI) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// CreateOrUpdateAsync indicates an expected call of CreateOrUpdateAsync. -func (mr *MockCreatorMockRecorder) CreateOrUpdateAsync(ctx, spec, parameters interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateAsync", reflect.TypeOf((*MockCreator)(nil).CreateOrUpdateAsync), ctx, spec, parameters) -} - -// Get mocks base method. -func (m *MockCreator) Get(ctx context.Context, spec azure0.ResourceSpecGetter) (interface{}, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, spec) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockCreatorMockRecorder) Get(ctx, spec interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockCreator)(nil).Get), ctx, spec) -} - -// IsDone mocks base method. -func (m *MockCreator) IsDone(ctx context.Context, future azure.FutureAPI) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsDone", ctx, future) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// IsDone indicates an expected call of IsDone. -func (mr *MockCreatorMockRecorder) IsDone(ctx, future interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDone", reflect.TypeOf((*MockCreator)(nil).IsDone), ctx, future) -} - -// Result mocks base method. -func (m *MockCreator) Result(ctx context.Context, future azure.FutureAPI, futureType string) (interface{}, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Result", ctx, future, futureType) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Result indicates an expected call of Result. -func (mr *MockCreatorMockRecorder) Result(ctx, future, futureType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Result", reflect.TypeOf((*MockCreator)(nil).Result), ctx, future, futureType) -} - -// MockDeleter is a mock of Deleter interface. -type MockDeleter struct { - ctrl *gomock.Controller - recorder *MockDeleterMockRecorder -} - -// MockDeleterMockRecorder is the mock recorder for MockDeleter. -type MockDeleterMockRecorder struct { - mock *MockDeleter -} - -// NewMockDeleter creates a new mock instance. -func NewMockDeleter(ctrl *gomock.Controller) *MockDeleter { - mock := &MockDeleter{ctrl: ctrl} - mock.recorder = &MockDeleterMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDeleter) EXPECT() *MockDeleterMockRecorder { - return m.recorder -} - -// DeleteAsync mocks base method. -func (m *MockDeleter) DeleteAsync(ctx context.Context, spec azure0.ResourceSpecGetter) (azure.FutureAPI, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteAsync", ctx, spec) - ret0, _ := ret[0].(azure.FutureAPI) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DeleteAsync indicates an expected call of DeleteAsync. -func (mr *MockDeleterMockRecorder) DeleteAsync(ctx, spec interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAsync", reflect.TypeOf((*MockDeleter)(nil).DeleteAsync), ctx, spec) -} - -// IsDone mocks base method. -func (m *MockDeleter) IsDone(ctx context.Context, future azure.FutureAPI) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsDone", ctx, future) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// IsDone indicates an expected call of IsDone. -func (mr *MockDeleterMockRecorder) IsDone(ctx, future interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDone", reflect.TypeOf((*MockDeleter)(nil).IsDone), ctx, future) -} - -// Result mocks base method. -func (m *MockDeleter) Result(ctx context.Context, future azure.FutureAPI, futureType string) (interface{}, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Result", ctx, future, futureType) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Result indicates an expected call of Result. -func (mr *MockDeleterMockRecorder) Result(ctx, future, futureType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Result", reflect.TypeOf((*MockDeleter)(nil).Result), ctx, future, futureType) -} - -// MockReconciler is a mock of Reconciler interface. -type MockReconciler struct { - ctrl *gomock.Controller - recorder *MockReconcilerMockRecorder -} - -// MockReconcilerMockRecorder is the mock recorder for MockReconciler. -type MockReconcilerMockRecorder struct { - mock *MockReconciler -} - -// NewMockReconciler creates a new mock instance. -func NewMockReconciler(ctrl *gomock.Controller) *MockReconciler { - mock := &MockReconciler{ctrl: ctrl} - mock.recorder = &MockReconcilerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockReconciler) EXPECT() *MockReconcilerMockRecorder { - return m.recorder -} - -// CreateOrUpdateResource mocks base method. -func (m *MockReconciler) CreateOrUpdateResource(ctx context.Context, spec azure0.ResourceSpecGetter, serviceName string) (interface{}, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateOrUpdateResource", ctx, spec, serviceName) - ret0, _ := ret[0].(interface{}) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateOrUpdateResource indicates an expected call of CreateOrUpdateResource. -func (mr *MockReconcilerMockRecorder) CreateOrUpdateResource(ctx, spec, serviceName interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateResource", reflect.TypeOf((*MockReconciler)(nil).CreateOrUpdateResource), ctx, spec, serviceName) -} - -// DeleteResource mocks base method. -func (m *MockReconciler) DeleteResource(ctx context.Context, spec azure0.ResourceSpecGetter, serviceName string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteResource", ctx, spec, serviceName) - ret0, _ := ret[0].(error) - return ret0 -} - -// DeleteResource indicates an expected call of DeleteResource. -func (mr *MockReconcilerMockRecorder) DeleteResource(ctx, spec, serviceName interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteResource", reflect.TypeOf((*MockReconciler)(nil).DeleteResource), ctx, spec, serviceName) -} diff --git a/azure/services/async/mock_async/doc.go b/azure/services/async/mock_async/doc.go deleted file mode 100644 index 66a4902521b..00000000000 --- a/azure/services/async/mock_async/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Run go generate to regenerate this mock. -// -//go:generate ../../../../hack/tools/bin/mockgen -destination async_mock.go -package mock_async -source ../interfaces.go FutureHandler -//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt async_mock.go > _async_mock.go && mv _async_mock.go async_mock.go" -package mock_async diff --git a/azure/services/asyncpoller/interfaces.go b/azure/services/asyncpoller/interfaces.go index 7a3073c81e3..f6cf0f8e595 100644 --- a/azure/services/asyncpoller/interfaces.go +++ b/azure/services/asyncpoller/interfaces.go @@ -20,6 +20,7 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -33,6 +34,11 @@ type Getter interface { Get(ctx context.Context, spec azure.ResourceSpecGetter) (result interface{}, err error) } +// TagsGetter is an interface that can get a tags resource. +type TagsGetter interface { + GetAtScope(ctx context.Context, scope string) (result armresources.TagsResource, err error) +} + // Creator creates or updates a resource asynchronously. type Creator[T any] interface { Getter diff --git a/azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go b/azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go index 6a3b79268bb..0278822b882 100644 --- a/azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go +++ b/azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go @@ -25,6 +25,7 @@ import ( reflect "reflect" runtime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + armresources "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" gomock "go.uber.org/mock/gomock" v1beta1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" azure "sigs.k8s.io/cluster-api-provider-azure/azure" @@ -166,6 +167,44 @@ func (mr *MockGetterMockRecorder) Get(ctx, spec interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockGetter)(nil).Get), ctx, spec) } +// MockTagsGetter is a mock of TagsGetter interface. +type MockTagsGetter struct { + ctrl *gomock.Controller + recorder *MockTagsGetterMockRecorder +} + +// MockTagsGetterMockRecorder is the mock recorder for MockTagsGetter. +type MockTagsGetterMockRecorder struct { + mock *MockTagsGetter +} + +// NewMockTagsGetter creates a new mock instance. +func NewMockTagsGetter(ctrl *gomock.Controller) *MockTagsGetter { + mock := &MockTagsGetter{ctrl: ctrl} + mock.recorder = &MockTagsGetterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTagsGetter) EXPECT() *MockTagsGetterMockRecorder { + return m.recorder +} + +// GetAtScope mocks base method. +func (m *MockTagsGetter) GetAtScope(ctx context.Context, scope string) (armresources.TagsResource, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAtScope", ctx, scope) + ret0, _ := ret[0].(armresources.TagsResource) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAtScope indicates an expected call of GetAtScope. +func (mr *MockTagsGetterMockRecorder) GetAtScope(ctx, scope interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAtScope", reflect.TypeOf((*MockTagsGetter)(nil).GetAtScope), ctx, scope) +} + // MockCreator is a mock of Creator interface. type MockCreator[T any] struct { ctrl *gomock.Controller diff --git a/azure/services/availabilitysets/availabilitysets.go b/azure/services/availabilitysets/availabilitysets.go index b717e4b8917..ee98eba1d72 100644 --- a/azure/services/availabilitysets/availabilitysets.go +++ b/azure/services/availabilitysets/availabilitysets.go @@ -23,7 +23,6 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -42,7 +41,7 @@ type AvailabilitySetScope interface { // Service provides operations on Azure resources. type Service struct { Scope AvailabilitySetScope - async.Getter + asyncpoller.Getter asyncpoller.Reconciler resourceSKUCache *resourceskus.Cache } diff --git a/azure/services/availabilitysets/availabilitysets_test.go b/azure/services/availabilitysets/availabilitysets_test.go index 39df89812f7..db09622c8f5 100644 --- a/azure/services/availabilitysets/availabilitysets_test.go +++ b/azure/services/availabilitysets/availabilitysets_test.go @@ -29,7 +29,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/availabilitysets/mock_availabilitysets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" @@ -77,12 +77,12 @@ func TestReconcileAvailabilitySets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "create or update availability set", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSetSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, nil) @@ -91,14 +91,14 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "noop if no availability set spec returns nil", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(nil) }, }, { name: "missing required value in availability set spec", expectedError: "some error with parameters", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpecMissing) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSetSpecMissing, serviceName).Return(nil, parameterError) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, parameterError) @@ -107,7 +107,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "error in creating availability set", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSetSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, internalError) @@ -123,7 +123,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_availabilitysets.NewMockAvailabilitySetScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -147,12 +147,12 @@ func TestDeleteAvailabilitySets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "deletes availability set", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(armcompute.AvailabilitySet{}, nil), @@ -164,14 +164,14 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "noop if AvailabilitySetSpec returns nil", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(nil) }, }, { name: "delete proceeds with missing required value in availability set spec", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpecMissing) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpecMissing).Return(armcompute.AvailabilitySet{}, nil), @@ -183,7 +183,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "noop if availability set has vms", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(fakeSetWithVMs, nil), @@ -194,7 +194,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "availability set not found", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(nil, notFoundError), @@ -205,7 +205,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "error in getting availability set", expectedError: "failed to get availability set test-as in resource group test-rg: #: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(nil, internalError), @@ -216,7 +216,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "availability set get result is not an availability set", expectedError: "string is not an armcompute.AvailabilitySet", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return("not an availability set", nil), @@ -227,7 +227,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "error in deleting availability set", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(armcompute.AvailabilitySet{}, nil), @@ -246,8 +246,8 @@ func TestDeleteAvailabilitySets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_availabilitysets.NewMockAvailabilitySetScope(mockCtrl) - getterMock := mock_async.NewMockGetter(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + getterMock := mock_asyncpoller.NewMockGetter(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), getterMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/bastionhosts/bastionhosts_test.go b/azure/services/bastionhosts/bastionhosts_test.go index 7634875f3c5..b8e58e16743 100644 --- a/azure/services/bastionhosts/bastionhosts_test.go +++ b/azure/services/bastionhosts/bastionhosts_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/client-go/kubernetes/scheme" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" mock_bastionhosts "sigs.k8s.io/cluster-api-provider-azure/azure/services/bastionhosts/mocks_bastionhosts" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -53,12 +53,12 @@ func TestReconcileBastionHosts(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "bastion successfully created", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.BastionHostReadyCondition, serviceName, nil) @@ -67,14 +67,14 @@ func TestReconcileBastionHosts(t *testing.T) { { name: "no bastion spec found", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(nil) }, }, { name: "fail to create a bastion", expectedError: internalError.Error(), - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.BastionHostReadyCondition, serviceName, internalError) @@ -90,7 +90,7 @@ func TestReconcileBastionHosts(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_bastionhosts.NewMockBastionScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -114,12 +114,12 @@ func TestDeleteBastionHost(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "successfully delete an existing bastion host", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.BastionHostReadyCondition, serviceName, nil) @@ -128,7 +128,7 @@ func TestDeleteBastionHost(t *testing.T) { { name: "bastion host deletion fails", expectedError: internalError.Error(), - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(internalError) s.UpdateDeleteStatus(infrav1.BastionHostReadyCondition, serviceName, internalError) @@ -137,7 +137,7 @@ func TestDeleteBastionHost(t *testing.T) { { name: "no bastion spec found", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(nil) }, }, @@ -151,7 +151,7 @@ func TestDeleteBastionHost(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_bastionhosts.NewMockBastionScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/disks/disks_test.go b/azure/services/disks/disks_test.go index 0a1cfc71dd6..ce1279ecc30 100644 --- a/azure/services/disks/disks_test.go +++ b/azure/services/disks/disks_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/disks/mock_disks" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -54,19 +54,19 @@ func TestDeleteDisk(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no disk specs are found", expectedError: "", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.DiskSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete the disk", expectedError: "", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.DiskSpecs().Return(fakeDiskSpecs) gomock.InOrder( r.DeleteResource(gomockinternal.AContext(), &diskSpec1, serviceName).Return(nil), @@ -78,7 +78,7 @@ func TestDeleteDisk(t *testing.T) { { name: "disk already deleted", expectedError: "", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.DiskSpecs().Return(fakeDiskSpecs) gomock.InOrder( r.DeleteResource(gomockinternal.AContext(), &diskSpec1, serviceName).Return(nil), @@ -90,7 +90,7 @@ func TestDeleteDisk(t *testing.T) { { name: "error while trying to delete the disk", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.DiskSpecs().Return(fakeDiskSpecs) gomock.InOrder( r.DeleteResource(gomockinternal.AContext(), &diskSpec1, serviceName).Return(internalError), @@ -110,7 +110,7 @@ func TestDeleteDisk(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_disks.NewMockDiskScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/inboundnatrules/inboundnatrules_test.go b/azure/services/inboundnatrules/inboundnatrules_test.go index 44ca569aa63..606bb3b426c 100644 --- a/azure/services/inboundnatrules/inboundnatrules_test.go +++ b/azure/services/inboundnatrules/inboundnatrules_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/inboundnatrules/mock_inboundnatrules" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -88,14 +88,14 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError string expect func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) + r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no NAT rule specs are found", expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{}) @@ -106,7 +106,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) m.List(gomockinternal.AContext(), fakeGroupName, fakeLBName).Return(noExistingRules, nil) @@ -123,7 +123,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return("my-lb") m.List(gomockinternal.AContext(), fakeGroupName, "my-lb").Return(fakeExistingRules, nil) @@ -139,7 +139,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.APIServerLBName().AnyTimes().Return("") }, }, @@ -148,7 +148,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "failed to get existing NAT rules: #: Internal Server Error: StatusCode=500", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return("my-lb") s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{&fakeNatSpec}) @@ -161,7 +161,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "#: Internal Server Error: StatusCode=500", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return("my-lb") m.List(gomockinternal.AContext(), fakeGroupName, "my-lb").Return(fakeExistingRules, nil) @@ -183,7 +183,7 @@ func TestReconcileInboundNATRule(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_inboundnatrules.NewMockInboundNatScope(mockCtrl) clientMock := mock_inboundnatrules.NewMockclient(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), clientMock.EXPECT(), asyncMock.EXPECT()) @@ -209,13 +209,13 @@ func TestDeleteNetworkInterface(t *testing.T) { name string expectedError string expect func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no NAT rules are found", expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{}) }, }, @@ -223,7 +223,7 @@ func TestDeleteNetworkInterface(t *testing.T) { name: "successfully delete an existing NAT rule", expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{&fakeNatSpec}) s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) @@ -237,7 +237,7 @@ func TestDeleteNetworkInterface(t *testing.T) { name: "NAT rule deletion fails", expectedError: "#: Internal Server Error: StatusCode=500", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{&fakeNatSpec}) s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) @@ -258,7 +258,7 @@ func TestDeleteNetworkInterface(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_inboundnatrules.NewMockInboundNatScope(mockCtrl) clientMock := mock_inboundnatrules.NewMockclient(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), clientMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/loadbalancers/loadbalancers_test.go b/azure/services/loadbalancers/loadbalancers_test.go index 3f67d7b9551..5c63b0cbcb4 100644 --- a/azure/services/loadbalancers/loadbalancers_test.go +++ b/azure/services/loadbalancers/loadbalancers_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/loadbalancers/mock_loadbalancers" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -108,19 +108,19 @@ func TestReconcileLoadBalancer(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no LBSpecs are found", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "fail to create a public LB", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, internalError) @@ -129,7 +129,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create public apiserver LB", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -138,7 +138,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create internal apiserver LB", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakeInternalAPILBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeInternalAPILBSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -147,7 +147,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create node outbound LB", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakeNodeOutboundLBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNodeOutboundLBSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -156,7 +156,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create multiple LBs", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec, &fakeInternalAPILBSpec, &fakeNodeOutboundLBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeInternalAPILBSpec, serviceName).Return(nil, nil) @@ -176,7 +176,7 @@ func TestReconcileLoadBalancer(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_loadbalancers.NewMockLBScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -199,19 +199,19 @@ func TestDeleteLoadBalancer(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no LBSpecs are found", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete a load balancer", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.DeleteResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -220,7 +220,7 @@ func TestDeleteLoadBalancer(t *testing.T) { { name: "delete multiple load balancers", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec, &fakeInternalAPILBSpec, &fakeNodeOutboundLBSpec}) r.DeleteResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakeInternalAPILBSpec, serviceName).Return(nil) @@ -231,7 +231,7 @@ func TestDeleteLoadBalancer(t *testing.T) { { name: "load balancer deletion fails", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.DeleteResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(internalError) s.UpdateDeleteStatus(infrav1.LoadBalancersReadyCondition, serviceName, internalError) @@ -249,7 +249,7 @@ func TestDeleteLoadBalancer(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_loadbalancers.NewMockLBScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/managedclusters/managedclusters_test.go b/azure/services/managedclusters/managedclusters_test.go index 52ed19d3657..9d665f519ec 100644 --- a/azure/services/managedclusters/managedclusters_test.go +++ b/azure/services/managedclusters/managedclusters_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/managedclusters/mock_managedclusters" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -38,19 +38,19 @@ func TestReconcile(t *testing.T) { testcases := []struct { name string expectedError string - expect func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if managedcluster spec is nil", expectedError: "", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(nil) }, }, { name: "create managed cluster returns an error", expectedError: "some unexpected error occurred", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(nil, errors.New("some unexpected error occurred")) s.UpdatePutStatus(infrav1.ManagedClusterRunningCondition, serviceName, errors.New("some unexpected error occurred")) @@ -59,7 +59,7 @@ func TestReconcile(t *testing.T) { { name: "create managed cluster succeeds", expectedError: "", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(armcontainerservice.ManagedCluster{ Properties: &armcontainerservice.ManagedClusterProperties{ @@ -85,7 +85,7 @@ func TestReconcile(t *testing.T) { { name: "fail to get managed cluster credentials", expectedError: "failed to get credentials for managed cluster: internal server error", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(armcontainerservice.ManagedCluster{ Properties: &armcontainerservice.ManagedClusterProperties{ @@ -111,7 +111,7 @@ func TestReconcile(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_managedclusters.NewMockManagedClusterScope(mockCtrl) credsGetterMock := mock_managedclusters.NewMockCredentialGetter(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(credsGetterMock.EXPECT(), scopeMock.EXPECT(), reconcilerMock.EXPECT()) @@ -136,19 +136,19 @@ func TestDelete(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no managed cluster spec is found", expectedError: "", - expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(nil) }, }, { name: "successfully delete an existing managed cluster", expectedError: "", - expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.DeleteResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.ManagedClusterRunningCondition, serviceName, nil) @@ -157,7 +157,7 @@ func TestDelete(t *testing.T) { { name: "managed cluster deletion fails", expectedError: "internal error", - expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.DeleteResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(errors.New("internal error")) s.UpdateDeleteStatus(infrav1.ManagedClusterRunningCondition, serviceName, errors.New("internal error")) @@ -173,7 +173,7 @@ func TestDelete(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_managedclusters.NewMockManagedClusterScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/natgateways/natgateways_test.go b/azure/services/natgateways/natgateways_test.go index 3ad663b422a..c4ddd071287 100644 --- a/azure/services/natgateways/natgateways_test.go +++ b/azure/services/natgateways/natgateways_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/natgateways/mock_natgateways" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -69,13 +69,13 @@ func TestReconcileNatGateways(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no NAT gateways specs are found", tags: customVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -84,7 +84,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "NAT gateways in custom vnet mode", tags: customVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -92,7 +92,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "NAT gateway create successfully", tags: ownedVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(natGateway1, nil) @@ -104,7 +104,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "fail to create a NAT gateway", tags: ownedVNetTags, expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(nil, internalError) @@ -115,7 +115,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "result is not a NAT gateway", tags: ownedVNetTags, expectedError: "created resource string is not an armnetwork.NatGateway", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return("not a nat gateway", nil) @@ -132,7 +132,7 @@ func TestReconcileNatGateways(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_natgateways.NewMockNatGatewayScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -157,13 +157,13 @@ func TestDeleteNatGateway(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no NAT gateways specs are found", tags: ownedVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -172,7 +172,7 @@ func TestDeleteNatGateway(t *testing.T) { name: "NAT gateways in custom vnet mode", tags: customVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -180,7 +180,7 @@ func TestDeleteNatGateway(t *testing.T) { name: "NAT gateway deleted successfully", tags: ownedVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.DeleteResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(nil) @@ -191,7 +191,7 @@ func TestDeleteNatGateway(t *testing.T) { name: "NAT gateway deletion fails", tags: ownedVNetTags, expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.DeleteResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(internalError) @@ -208,7 +208,7 @@ func TestDeleteNatGateway(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_natgateways.NewMockNatGatewayScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/networkinterfaces/networkinterfaces.go b/azure/services/networkinterfaces/networkinterfaces.go index 1b89860fba8..3b931813d49 100644 --- a/azure/services/networkinterfaces/networkinterfaces.go +++ b/azure/services/networkinterfaces/networkinterfaces.go @@ -22,7 +22,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -41,7 +40,7 @@ type NICScope interface { // Service provides operations on Azure resources. type Service struct { Scope NICScope - async.Reconciler + asyncpoller.Reconciler resourceSKUCache *resourceskus.Cache } diff --git a/azure/services/networkinterfaces/networkinterfaces_test.go b/azure/services/networkinterfaces/networkinterfaces_test.go index c16d90831ff..a0dec8f6e35 100644 --- a/azure/services/networkinterfaces/networkinterfaces_test.go +++ b/azure/services/networkinterfaces/networkinterfaces_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/networkinterfaces/mock_networkinterfaces" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -77,19 +77,19 @@ func TestReconcileNetworkInterface(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no network interface specs are found", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully create a network interface", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.NetworkInterfaceReadyCondition, serviceName, nil) @@ -98,7 +98,7 @@ func TestReconcileNetworkInterface(t *testing.T) { { name: "successfully create a network interface with multiple IPConfigs", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec3}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec3, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.NetworkInterfaceReadyCondition, serviceName, nil) @@ -107,7 +107,7 @@ func TestReconcileNetworkInterface(t *testing.T) { { name: "successfully create multiple network interfaces", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(nil, nil) @@ -117,7 +117,7 @@ func TestReconcileNetworkInterface(t *testing.T) { { name: "network interface create fails", expectedError: internalError.Error(), - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil, internalError) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(nil, nil) @@ -134,7 +134,7 @@ func TestReconcileNetworkInterface(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_networkinterfaces.NewMockNICScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -160,19 +160,19 @@ func TestDeleteNetworkInterface(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no network interface specs are found", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully delete an existing network interface", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1}) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.NetworkInterfaceReadyCondition, serviceName, nil) @@ -181,7 +181,7 @@ func TestDeleteNetworkInterface(t *testing.T) { { name: "successfully delete multiple existing network interfaces", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(nil) @@ -191,7 +191,7 @@ func TestDeleteNetworkInterface(t *testing.T) { { name: "network interface deletion fails", expectedError: internalError.Error(), - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(internalError) @@ -208,7 +208,7 @@ func TestDeleteNetworkInterface(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_networkinterfaces.NewMockNICScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/privatedns/privatedns.go b/azure/services/privatedns/privatedns.go index fe46200c604..1d3f7af2189 100644 --- a/azure/services/privatedns/privatedns.go +++ b/azure/services/privatedns/privatedns.go @@ -24,7 +24,6 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -44,7 +43,7 @@ type Scope interface { // Service provides operations on Azure resources. type Service struct { Scope Scope - TagsGetter async.TagsGetter + TagsGetter asyncpoller.TagsGetter zoneReconciler asyncpoller.Reconciler vnetLinkReconciler asyncpoller.Reconciler recordReconciler asyncpoller.Reconciler diff --git a/azure/services/privatedns/privatedns_test.go b/azure/services/privatedns/privatedns_test.go index d7217ea6240..031c4a4f7ae 100644 --- a/azure/services/privatedns/privatedns_test.go +++ b/azure/services/privatedns/privatedns_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/privatedns/mock_privatedns" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -98,20 +98,20 @@ func TestReconcilePrivateDNS(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_privatedns.MockScopeMockRecorder, zoneReconiler, linksReconciler, recordsReconciler *mock_async.MockReconcilerMockRecorder, - tagsGetter *mock_async.MockTagsGetterMockRecorder) + expect func(s *mock_privatedns.MockScopeMockRecorder, zoneReconiler, linksReconciler, recordsReconciler *mock_asyncpoller.MockReconcilerMockRecorder, + tagsGetter *mock_asyncpoller.MockTagsGetterMockRecorder) }{ { name: "no private dns", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(nil, nil, nil) }, }, { name: "create private dns with multiple links successfully", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -135,7 +135,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "zone creation in progress", expectedError: "operation type resourceType on Azure resource my-rg/resourceName is not done", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -148,7 +148,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "zone creation fails", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -160,7 +160,7 @@ func TestReconcilePrivateDNS(t *testing.T) { }, { name: "unmanaged zone does not update ready condition", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -183,7 +183,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "link 1 creation fails but still proceeds to link 2, and returns the error", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -205,7 +205,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "link 2 creation fails", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -227,7 +227,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "link 1 is long running, link 2 fails, it returns the failure of link2", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -248,7 +248,7 @@ func TestReconcilePrivateDNS(t *testing.T) { }, { name: "unmanaged link does not update ready condition", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -270,7 +270,7 @@ func TestReconcilePrivateDNS(t *testing.T) { }, { name: "vnet link is considered managed if at least one of the links is managed", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -294,7 +294,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "record creation fails", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -326,10 +326,10 @@ func TestReconcilePrivateDNS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privatedns.NewMockScope(mockCtrl) - zoneReconcilerMock := mock_async.NewMockReconciler(mockCtrl) - vnetLinkReconcilerMock := mock_async.NewMockReconciler(mockCtrl) - recordReconcilerMock := mock_async.NewMockReconciler(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + zoneReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + vnetLinkReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + recordReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) tc.expect(scopeMock.EXPECT(), zoneReconcilerMock.EXPECT(), vnetLinkReconcilerMock.EXPECT(), recordReconcilerMock.EXPECT(), tagsGetterMock.EXPECT()) @@ -356,19 +356,19 @@ func TestDeletePrivateDNS(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_privatedns.MockScopeMockRecorder, linkReconciler, zoneReconciler *mock_async.MockReconcilerMockRecorder, tagsGetter *mock_async.MockTagsGetterMockRecorder) + expect func(s *mock_privatedns.MockScopeMockRecorder, linkReconciler, zoneReconciler *mock_asyncpoller.MockReconcilerMockRecorder, tagsGetter *mock_asyncpoller.MockTagsGetterMockRecorder) }{ { name: "no private dns", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(nil, nil, nil) }, }, { name: "dns and links deletion succeeds", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -396,7 +396,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "skips if zone and links are unmanaged", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -415,7 +415,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "skips if unmanaged, but deletes the next resource if it is managed", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -440,7 +440,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "link1 is deleted, link2 is long running. It returns not done error", expectedError: "operation type resourceType on Azure resource my-rg/resourceName is not done", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}) s.SubscriptionID().Return("123") @@ -460,7 +460,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "link1 deletion fails and link2 is long running, returns the more pressing error", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}) s.SubscriptionID().Return("123") @@ -480,7 +480,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "links are deleted, zone is long running", expectedError: "operation type resourceType on Azure resource my-rg/resourceName is not done", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -509,7 +509,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "links are deleted, zone deletion fails with error", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -546,9 +546,9 @@ func TestDeletePrivateDNS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privatedns.NewMockScope(mockCtrl) - vnetLinkReconcilerMock := mock_async.NewMockReconciler(mockCtrl) - zoneReconcilerMock := mock_async.NewMockReconciler(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + vnetLinkReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + zoneReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) tc.expect(scopeMock.EXPECT(), vnetLinkReconcilerMock.EXPECT(), zoneReconcilerMock.EXPECT(), tagsGetterMock.EXPECT()) diff --git a/azure/services/privateendpoints/privateendpoints_test.go b/azure/services/privateendpoints/privateendpoints_test.go index 0509d5d6659..16ef5fe85d8 100644 --- a/azure/services/privateendpoints/privateendpoints_test.go +++ b/azure/services/privateendpoints/privateendpoints_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/privateendpoints/mock_privateendpoints" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -70,13 +70,13 @@ var ( func TestReconcilePrivateEndpoint(t *testing.T) { testcases := []struct { name string - expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) expectedError string }{ { name: "create a private endpoint with automatic approval", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return([]azure.ResourceSpecGetter{&fakePrivateEndpoint1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) p.UpdatePutStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, nil) @@ -85,7 +85,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "create a private endpoint with manual approval", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[1:2]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(&fakePrivateEndpoint2, nil) p.UpdatePutStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, nil) @@ -94,7 +94,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "create multiple private endpoints", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:2]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(&fakePrivateEndpoint2, nil) @@ -104,7 +104,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "return error when creating a private endpoint using an empty spec", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[3:]) r.CreateOrUpdateResource(gomockinternal.AContext(), &emptyPrivateEndpointSpec, ServiceName).Return(nil, internalError) p.UpdatePutStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, internalError) @@ -113,7 +113,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "not done error in creating is ignored", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(&fakePrivateEndpoint2, internalError) @@ -124,7 +124,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "not done error in creating remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(nil, notDoneError) @@ -142,7 +142,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privateendpoints.NewMockPrivateEndpointScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -165,13 +165,13 @@ func TestReconcilePrivateEndpoint(t *testing.T) { func TestDeletePrivateEndpoints(t *testing.T) { testcases := []struct { name string - expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) expectedError string }{ { name: "delete a private endpoint", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:1]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) p.UpdateDeleteStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, nil) @@ -180,14 +180,14 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "noop if no private endpoints specs are found", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, _ *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, _ *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete multiple private endpoints", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:2]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(nil) @@ -197,7 +197,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "error in deleting peering", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:2]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(internalError) @@ -207,7 +207,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "not done error in deleting is ignored", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(internalError) @@ -218,7 +218,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "not done error in deleting remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(nil) @@ -237,7 +237,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privateendpoints.NewMockPrivateEndpointScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/publicips/publicips.go b/azure/services/publicips/publicips.go index c4bc7f0d3af..69867c1488b 100644 --- a/azure/services/publicips/publicips.go +++ b/azure/services/publicips/publicips.go @@ -24,7 +24,6 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -44,8 +43,8 @@ type PublicIPScope interface { type Service struct { Scope PublicIPScope asyncpoller.Reconciler - async.Getter - async.TagsGetter + asyncpoller.Getter + asyncpoller.TagsGetter } // New creates a new service. diff --git a/azure/services/publicips/publicips_test.go b/azure/services/publicips/publicips_test.go index d64642131cb..5cb225ae0a8 100644 --- a/azure/services/publicips/publicips_test.go +++ b/azure/services/publicips/publicips_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips/mock_publicips" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -119,19 +119,19 @@ func TestReconcilePublicIP(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully create public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec2, serviceName).Return(nil, nil) @@ -143,7 +143,7 @@ func TestReconcilePublicIP(t *testing.T) { { name: "fail to create a public IP", expectedError: internalError.Error(), - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec2, serviceName).Return(nil, nil) @@ -164,8 +164,8 @@ func TestReconcilePublicIP(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_publicips.NewMockPublicIPScope(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) @@ -190,19 +190,19 @@ func TestDeletePublicIP(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully delete managed public IPs and ignore unmanaged public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) s.SubscriptionID().Return("123") @@ -230,7 +230,7 @@ func TestDeletePublicIP(t *testing.T) { { name: "noop if no managed public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) s.SubscriptionID().Return("123") @@ -253,7 +253,7 @@ func TestDeletePublicIP(t *testing.T) { { name: "fail to delete managed public IP", expectedError: internalError.Error(), - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) s.SubscriptionID().Return("123") @@ -291,8 +291,8 @@ func TestDeletePublicIP(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_publicips.NewMockPublicIPScope(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) diff --git a/azure/services/roleassignments/roleassignments.go b/azure/services/roleassignments/roleassignments.go index 06098e6de73..4eb0e552fd8 100644 --- a/azure/services/roleassignments/roleassignments.go +++ b/azure/services/roleassignments/roleassignments.go @@ -23,7 +23,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachines" @@ -47,9 +46,9 @@ type RoleAssignmentScope interface { // Service provides operations on Azure resources. type Service struct { Scope RoleAssignmentScope - virtualMachinesGetter async.Getter + virtualMachinesGetter asyncpoller.Getter asyncpoller.Reconciler - virtualMachineScaleSetGetter async.Getter + virtualMachineScaleSetGetter asyncpoller.Getter } // New creates a new service. diff --git a/azure/services/roleassignments/roleassignments_test.go b/azure/services/roleassignments/roleassignments_test.go index 69d0093d2bc..f754d13831a 100644 --- a/azure/services/roleassignments/roleassignments_test.go +++ b/azure/services/roleassignments/roleassignments_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/roleassignments/mock_roleassignments" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets/mock_scalesets" @@ -65,7 +65,7 @@ var ( func TestReconcileRoleAssignmentsVM(t *testing.T) { testcases := []struct { name string - expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) expectedError string }{ { @@ -73,8 +73,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { expectedError: "", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - m *mock_async.MockGetterMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + m *mock_asyncpoller.MockGetterMockRecorder, + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubscriptionID().AnyTimes().Return("12345") s.ResourceGroup().Return("my-rg") s.Name().Return(fakeRoleAssignment1.MachineName) @@ -93,8 +93,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { name: "error getting VM", expectedError: "failed to assign role to system assigned identity: failed to get principal ID for VM: #: Internal Server Error: StatusCode=500", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - m *mock_async.MockGetterMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + m *mock_asyncpoller.MockGetterMockRecorder, + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubscriptionID().AnyTimes().Return("12345") s.ResourceGroup().Return("my-rg") s.Name().Return(fakeRoleAssignment1.MachineName) @@ -107,8 +107,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { name: "return error when creating a role assignment", expectedError: "cannot assign role to VirtualMachine system assigned identity: #: Internal Server Error: StatusCode=500", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - m *mock_async.MockGetterMockRecorder, - r *mock_async.MockReconcilerMockRecorder) { + m *mock_asyncpoller.MockGetterMockRecorder, + r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubscriptionID().AnyTimes().Return("12345") s.ResourceGroup().Return("my-rg") s.Name().Return(fakeRoleAssignment1.MachineName) @@ -134,8 +134,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_roleassignments.NewMockRoleAssignmentScope(mockCtrl) - vmGetterMock := mock_async.NewMockGetter(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + vmGetterMock := mock_asyncpoller.NewMockGetter(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), vmGetterMock.EXPECT(), asyncMock.EXPECT()) @@ -159,7 +159,7 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { func TestReconcileRoleAssignmentsVMSS(t *testing.T) { testcases := []struct { name string - expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, + expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) expectedError string }{ @@ -167,7 +167,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { name: "create a role assignment", expectedError: "", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - r *mock_async.MockReconcilerMockRecorder, + r *mock_asyncpoller.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) { s.HasSystemAssignedIdentity().Return(true) s.RoleAssignmentSpecs(&fakePrincipalID).Return(fakeRoleAssignmentSpecs[1:2]) @@ -186,7 +186,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { name: "error getting VMSS", expectedError: "failed to assign role to system assigned identity: failed to get principal ID for VMSS: #: Internal Server Error: StatusCode=500", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - r *mock_async.MockReconcilerMockRecorder, + r *mock_asyncpoller.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) { s.RoleAssignmentResourceType().Return(azure.VirtualMachineScaleSet) s.ResourceGroup().Return("my-rg") @@ -200,7 +200,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { name: "return error when creating a role assignment", expectedError: fmt.Sprintf("cannot assign role to %s system assigned identity: #: Internal Server Error: StatusCode=500", azure.VirtualMachineScaleSet), expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - r *mock_async.MockReconcilerMockRecorder, + r *mock_asyncpoller.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) { s.HasSystemAssignedIdentity().Return(true) s.RoleAssignmentSpecs(&fakePrincipalID).Return(fakeRoleAssignmentSpecs[1:2]) @@ -226,7 +226,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_roleassignments.NewMockRoleAssignmentScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) vmMock := mock_scalesets.NewMockClient(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT(), vmMock.EXPECT()) diff --git a/azure/services/routetables/routetables_test.go b/azure/services/routetables/routetables_test.go index 91fbb9c9203..d39f4ebe73a 100644 --- a/azure/services/routetables/routetables_test.go +++ b/azure/services/routetables/routetables_test.go @@ -25,7 +25,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/routetables/mock_routetables" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -55,12 +55,12 @@ func TestReconcileRouteTables(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no route table specs are found", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -68,7 +68,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "create multiple route tables succeeds", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil, nil) @@ -79,7 +79,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "first route table create fails", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil, errFake) @@ -90,7 +90,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "second route table create not done", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil, errFake) @@ -101,7 +101,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "noop if vnet is not managed", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -115,7 +115,7 @@ func TestReconcileRouteTables(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_routetables.NewMockRouteTableScope(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) @@ -140,12 +140,12 @@ func TestDeleteRouteTable(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no route table specs are found", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -153,7 +153,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "delete multiple route tables succeeds", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.DeleteResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil) @@ -164,7 +164,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "first route table delete fails", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.DeleteResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(errFake) @@ -175,7 +175,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "second route table delete not done", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.DeleteResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(errFake) @@ -186,7 +186,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "noop if vnet is not managed", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -200,7 +200,7 @@ func TestDeleteRouteTable(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_routetables.NewMockRouteTableScope(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) diff --git a/azure/services/scalesets/scalesets_test.go b/azure/services/scalesets/scalesets_test.go index 4e8228d39ee..6b98b3a5207 100644 --- a/azure/services/scalesets/scalesets_test.go +++ b/azure/services/scalesets/scalesets_test.go @@ -30,7 +30,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets/mock_scalesets" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" @@ -97,13 +97,13 @@ func TestReconcileVMSS(t *testing.T) { testcases := []struct { name string - expect func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) + expect func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) expectedError string }{ { name: "update an existing vmss", expectedError: "", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -120,7 +120,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "create a vmss, skip list instances if vmss doesn't exist", expectedError: "", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -136,7 +136,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "error getting existing vmss", expectedError: "failed to get existing VMSS: #: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -146,7 +146,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "failed to list instances", expectedError: "failed to get existing VMSS instances: #: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -158,7 +158,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "failed to create a vmss", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() m.Get(gomockinternal.AContext(), &defaultSpec).Return(&resultVMSS, nil) @@ -172,7 +172,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "failed to reconcile replicas", expectedError: "unable to reconcile VMSS replicas: #: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() m.Get(gomockinternal.AContext(), &defaultSpec).Return(&resultVMSS, nil) @@ -187,7 +187,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: less than 2 vCPUs", expectedError: "reconcile error that cannot be recovered occurred: vm size should be bigger or equal to at least 2 vCPUs. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = "VM_SIZE_1_CPU" spec.Capacity = 2 @@ -198,7 +198,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: Memory is less than 2Gi", expectedError: "reconcile error that cannot be recovered occurred: vm memory should be bigger or equal to at least 2Gi. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = "VM_SIZE_1_MEM" spec.Capacity = 2 @@ -209,7 +209,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: failed to get SKU", expectedError: "failed to get SKU INVALID_VM_SIZE in compute api: reconcile error that cannot be recovered occurred: resource sku with name 'INVALID_VM_SIZE' and category 'virtualMachines' not found in location 'test-location'. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = "INVALID_VM_SIZE" spec.Capacity = 2 @@ -220,7 +220,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with ultra disk implicitly enabled by data disk, when location not supported", expectedError: "reconcile error that cannot be recovered occurred: vm size VM_SIZE_USSD does not support ultra disks in location test-location. select a different vm size or disable ultra disks. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -236,7 +236,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with ultra disk explicitly enabled via additional capabilities, when location not supported", expectedError: "reconcile error that cannot be recovered occurred: vm size VM_SIZE_USSD does not support ultra disks in location test-location. select a different vm size or disable ultra disks. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -250,7 +250,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with ultra disk explicitly enabled via additional capabilities, when location not supported", expectedError: "reconcile error that cannot be recovered occurred: vm size VM_SIZE_USSD does not support ultra disks in location test-location. select a different vm size or disable ultra disks. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -269,7 +269,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with diagnostics set to User Managed but empty StorageAccountURI", expectedError: "reconcile error that cannot be recovered occurred: userManaged must be specified when storageAccountType is 'UserManaged'. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -294,7 +294,7 @@ func TestReconcileVMSS(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_scalesets.NewMockScaleSetScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) clientMock := mock_scalesets.NewMockClient(mockCtrl) tc.expect(g, scopeMock.EXPECT(), asyncMock.EXPECT(), clientMock.EXPECT()) @@ -328,12 +328,12 @@ func TestDeleteVMSS(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) + expect func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) }{ { name: "successfully delete an existing vmss", expectedError: "", - expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { s.ScaleSetSpec(gomockinternal.AContext()).Return(&defaultSpec).AnyTimes() r.DeleteResource(gomockinternal.AContext(), &defaultSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.BootstrapSucceededCondition, serviceName, nil) @@ -346,7 +346,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "successfully delete an existing vmss, fetch call returns error", expectedError: "", - expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { s.ScaleSetSpec(gomockinternal.AContext()).Return(&defaultSpec).AnyTimes() r.DeleteResource(gomockinternal.AContext(), &defaultSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.BootstrapSucceededCondition, serviceName, nil) @@ -356,7 +356,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "failed to delete an existing vmss", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { s.ScaleSetSpec(gomockinternal.AContext()).Return(&defaultSpec).AnyTimes() r.DeleteResource(gomockinternal.AContext(), &defaultSpec, serviceName).Return(internalError) s.UpdateDeleteStatus(infrav1.BootstrapSucceededCondition, serviceName, internalError) @@ -373,7 +373,7 @@ func TestDeleteVMSS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_scalesets.NewMockScaleSetScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) mockClient := mock_scalesets.NewMockClient(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT(), mockClient.EXPECT()) diff --git a/azure/services/scalesetvms/scalesetvms_test.go b/azure/services/scalesetvms/scalesetvms_test.go index 8236a8edda5..f63fa2c57ab 100644 --- a/azure/services/scalesetvms/scalesetvms_test.go +++ b/azure/services/scalesetvms/scalesetvms_test.go @@ -27,7 +27,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms/mock_scalesetvms" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -69,13 +69,13 @@ var ( func TestReconcileVMSS(t *testing.T) { testcases := []struct { name string - expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) + expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) expectedError string }{ { name: "get a uniform vmss vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(uniformScaleSetVM, nil) s.SetVMSSVM(converters.SDKToVMSSVM(uniformScaleSetVM)) @@ -84,7 +84,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "get a vmss flex vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.CreateOrUpdateResource(gomockinternal.AContext(), flexGetter, serviceName).Return(flexScaleSetVM, nil) s.SetVMSSVM(converters.SDKVMToVMSSVM(flexScaleSetVM, infrav1.FlexibleOrchestrationMode)) @@ -93,7 +93,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "uniform vmss vm doesn't exist yet", expectedError: "instance does not exist yet. Object will be requeued after 30s", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(nil, nil) }, @@ -101,7 +101,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "vmss flex vm doesn't exist yet", expectedError: "instance does not exist yet. Object will be requeued after 30s", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.CreateOrUpdateResource(gomockinternal.AContext(), flexGetter, serviceName).Return(nil, nil) }, @@ -109,7 +109,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "error getting uniform vmss vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(nil, errInternal) }, @@ -117,7 +117,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "error getting vmss flex vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.CreateOrUpdateResource(gomockinternal.AContext(), flexGetter, serviceName).Return(nil, errInternal) }, @@ -133,8 +133,8 @@ func TestReconcileVMSS(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_scalesetvms.NewMockScaleSetVMScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) - vmAsyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + vmAsyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(g, scopeMock.EXPECT(), asyncMock.EXPECT(), vmAsyncMock.EXPECT()) @@ -158,13 +158,13 @@ func TestReconcileVMSS(t *testing.T) { func TestDeleteVMSS(t *testing.T) { testcases := []struct { name string - expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) + expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) expectedError string }{ { name: "delete a uniform vmss vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.DeleteResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(nil) s.SetVMSSVMState(infrav1.Deleted) @@ -173,7 +173,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "delete a vmss flex vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.DeleteResource(gomockinternal.AContext(), flexGetter, serviceName).Return(nil) s.SetVMSSVMState(infrav1.Deleted) @@ -182,7 +182,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "error when deleting a uniform vmss vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.DeleteResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(errInternal) s.SetVMSSVMState(infrav1.Deleting) @@ -191,7 +191,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "error when deleting a vmss flex vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.DeleteResource(gomockinternal.AContext(), flexGetter, serviceName).Return(errInternal) s.SetVMSSVMState(infrav1.Deleting) @@ -208,8 +208,8 @@ func TestDeleteVMSS(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_scalesetvms.NewMockScaleSetVMScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) - vmAsyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + vmAsyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(g, scopeMock.EXPECT(), asyncMock.EXPECT(), vmAsyncMock.EXPECT()) diff --git a/azure/services/securitygroups/securitygroups_test.go b/azure/services/securitygroups/securitygroups_test.go index 64bc28940cb..486a72ae14f 100644 --- a/azure/services/securitygroups/securitygroups_test.go +++ b/azure/services/securitygroups/securitygroups_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/securitygroups/mock_securitygroups" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -92,12 +92,12 @@ func TestReconcileSecurityGroups(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "create single security group with single rule succeeds, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -108,7 +108,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "create single security group with multiple rules succeeds, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&multipleRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{multipleRulesNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description, securityRule2.Name: securityRule2.Description}}).Times(1) @@ -119,7 +119,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "create multiple security groups, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -131,7 +131,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "first security groups create fails, should return error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -143,7 +143,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "first sg create fails, second sg create not done, should return create error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -155,7 +155,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "security groups create not done, should return not done error", expectedError: notDoneError.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}) @@ -166,7 +166,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "vnet is not managed, should skip reconcile", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -180,7 +180,7 @@ func TestReconcileSecurityGroups(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_securitygroups.NewMockNSGScope(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) @@ -204,12 +204,12 @@ func TestDeleteSecurityGroups(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "delete multiple security groups succeeds, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(nil) @@ -220,7 +220,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "first security groups delete fails, should return an error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(errFake) @@ -231,7 +231,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "first security groups delete fails and second security groups create not done, should return an error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(errFake) @@ -242,7 +242,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "security groups delete not done, should return not done error", expectedError: notDoneError.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(notDoneError) @@ -252,7 +252,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "vnet is not managed, should skip delete", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -266,7 +266,7 @@ func TestDeleteSecurityGroups(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_securitygroups.NewMockNSGScope(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) diff --git a/azure/services/subnets/subnets_test.go b/azure/services/subnets/subnets_test.go index 348edd36d1f..fdeb70a7086 100644 --- a/azure/services/subnets/subnets_test.go +++ b/azure/services/subnets/subnets_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets/mock_subnets" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -205,19 +205,19 @@ func TestReconcileSubnets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no subnet specs are found", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "create subnet", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(fakeSubnet1, nil) @@ -231,7 +231,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create multiple subnets", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeSubnetSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(fakeSubnet1, nil) @@ -249,7 +249,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "don't update ready condition when subnet not managed", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpecNotManaged}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpecNotManaged, serviceName).Return(fakeSubnetNotManaged, nil) @@ -262,7 +262,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create ipv6 subnet", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeIpv6SubnetSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeIpv6SubnetSpec, serviceName).Return(fakeIpv6Subnet, nil) @@ -276,7 +276,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create multiple ipv6 subnets", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeIpv6SubnetSpec, &fakeIpv6SubnetSpecCP}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeIpv6SubnetSpec, serviceName).Return(fakeIpv6Subnet, nil) @@ -294,7 +294,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "fail to create subnet", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil, internalError) @@ -305,7 +305,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create returns a non subnet", expectedError: notASubnetErr.Error(), - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(notASubnet, nil) }, @@ -313,7 +313,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "fail to create subnets", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeSubnetSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil, internalError) @@ -336,7 +336,7 @@ func TestReconcileSubnets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_subnets.NewMockSubnetScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -360,12 +360,12 @@ func TestDeleteSubnets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no subnet specs are found", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -373,7 +373,7 @@ func TestDeleteSubnets(t *testing.T) { { name: "subnets deleted successfully", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeSubnetSpec2}) r.DeleteResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil) @@ -384,7 +384,7 @@ func TestDeleteSubnets(t *testing.T) { { name: "node subnet and controlplane subnet deleted successfully", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeCtrlPlaneSubnetSpec}) r.DeleteResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil) @@ -395,14 +395,14 @@ func TestDeleteSubnets(t *testing.T) { { name: "skip delete if vnet is not managed", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(false) }, }, { name: "fail delete subnet", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.DeleteResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(internalError) @@ -419,7 +419,7 @@ func TestDeleteSubnets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_subnets.NewMockSubnetScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/virtualmachines/virtualmachines.go b/azure/services/virtualmachines/virtualmachines.go index 6420fc3f296..e1e20b49c86 100644 --- a/azure/services/virtualmachines/virtualmachines.go +++ b/azure/services/virtualmachines/virtualmachines.go @@ -29,7 +29,6 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" "sigs.k8s.io/cluster-api-provider-azure/azure/services/networkinterfaces" @@ -58,8 +57,8 @@ type VMScope interface { type Service struct { Scope VMScope asyncpoller.Reconciler - interfacesGetter async.Getter - publicIPsGetter async.Getter + interfacesGetter asyncpoller.Getter + publicIPsGetter asyncpoller.Getter identitiesGetter identities.Client } diff --git a/azure/services/virtualmachines/virtualmachines_test.go b/azure/services/virtualmachines/virtualmachines_test.go index b53ea984d7e..e8870789065 100644 --- a/azure/services/virtualmachines/virtualmachines_test.go +++ b/azure/services/virtualmachines/virtualmachines_test.go @@ -30,7 +30,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities/mock_identities" "sigs.k8s.io/cluster-api-provider-azure/azure/services/networkinterfaces" "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips" @@ -123,19 +123,19 @@ func TestReconcileVM(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no vm spec is found", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().Return(nil) }, }, { name: "create vm succeeds", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(fakeExistingVM, nil) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, nil) @@ -151,7 +151,7 @@ func TestReconcileVM(t *testing.T) { { name: "creating vm fails", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, internalError) @@ -161,7 +161,7 @@ func TestReconcileVM(t *testing.T) { { name: "create vm succeeds but failed to get network interfaces", expectedError: "failed to fetch VM addresses: #: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(fakeExistingVM, nil) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, nil) @@ -174,7 +174,7 @@ func TestReconcileVM(t *testing.T) { { name: "create vm succeeds but failed to get public IPs", expectedError: "failed to fetch VM addresses: #: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(fakeExistingVM, nil) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, nil) @@ -196,9 +196,9 @@ func TestReconcileVM(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_virtualmachines.NewMockVMScope(mockCtrl) - interfaceMock := mock_async.NewMockGetter(mockCtrl) - publicIPMock := mock_async.NewMockGetter(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + interfaceMock := mock_asyncpoller.NewMockGetter(mockCtrl) + publicIPMock := mock_asyncpoller.NewMockGetter(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), interfaceMock.EXPECT(), publicIPMock.EXPECT(), asyncMock.EXPECT()) @@ -224,19 +224,19 @@ func TestDeleteVM(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no vm spec is found", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().Return(nil) }, }, { name: "vm doesn't exist", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().AnyTimes().Return(&fakeVMSpec) r.DeleteResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(nil) s.SetVMState(infrav1.Deleted) @@ -246,7 +246,7 @@ func TestDeleteVM(t *testing.T) { { name: "error occurs when deleting vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().AnyTimes().Return(&fakeVMSpec) r.DeleteResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(internalError) s.SetVMState(infrav1.Deleting) @@ -256,7 +256,7 @@ func TestDeleteVM(t *testing.T) { { name: "delete the vm successfully", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMSpec().AnyTimes().Return(&fakeVMSpec) r.DeleteResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(nil) s.SetVMState(infrav1.Deleted) @@ -273,7 +273,7 @@ func TestDeleteVM(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualmachines.NewMockVMScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -376,7 +376,7 @@ func TestCheckUserAssignedIdentities(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualmachines.NewMockVMScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) identitiesMock := mock_identities.NewMockClient(mockCtrl) tc.expect(scopeMock.EXPECT(), identitiesMock.EXPECT()) diff --git a/azure/services/virtualnetworks/virtualnetworks.go b/azure/services/virtualnetworks/virtualnetworks.go index 4069fbf4b83..be49a669a0a 100644 --- a/azure/services/virtualnetworks/virtualnetworks.go +++ b/azure/services/virtualnetworks/virtualnetworks.go @@ -25,7 +25,6 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -49,8 +48,8 @@ type VNetScope interface { type Service struct { Scope VNetScope asyncpoller.Reconciler - async.Getter - async.TagsGetter + asyncpoller.Getter + asyncpoller.TagsGetter } // New creates a new service. diff --git a/azure/services/virtualnetworks/virtualnetworks_test.go b/azure/services/virtualnetworks/virtualnetworks_test.go index 28bc7b8e134..5ede5c313aa 100644 --- a/azure/services/virtualnetworks/virtualnetworks_test.go +++ b/azure/services/virtualnetworks/virtualnetworks_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks/mock_virtualnetworks" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -99,19 +99,19 @@ func TestReconcileVnet(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no vnet spec is found", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Return(nil) }, }, { name: "reconcile when vnet is not managed", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(nil, nil) s.IsVnetManaged().Return(false) @@ -120,7 +120,7 @@ func TestReconcileVnet(t *testing.T) { { name: "create vnet succeeds, should not return an error", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(nil, nil) s.IsVnetManaged().Return(true) @@ -130,7 +130,7 @@ func TestReconcileVnet(t *testing.T) { { name: "create vnet fails, should return an error", expectedError: internalError.Error(), - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(nil, internalError) s.IsVnetManaged().Return(true) @@ -140,7 +140,7 @@ func TestReconcileVnet(t *testing.T) { { name: "existing vnet should update subnet CIDR blocks", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(customVnet, nil) s.Vnet().Return(&infrav1.VnetSpec{}) @@ -160,8 +160,8 @@ func TestReconcileVnet(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualnetworks.NewMockVNetScope(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) @@ -186,19 +186,19 @@ func TestDeleteVnet(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "noop if no vnet spec is found", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Return(nil) }, }, { name: "delete vnet succeeds, should not return an error", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Times(2).Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(managedTags, nil) @@ -210,7 +210,7 @@ func TestDeleteVnet(t *testing.T) { { name: "delete vnet fails, should return an error", expectedError: internalError.Error(), - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Times(2).Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(managedTags, nil) @@ -222,7 +222,7 @@ func TestDeleteVnet(t *testing.T) { { name: "vnet is not managed, do nothing", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VNetSpec().Times(2).Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(unmanagedTags, nil) @@ -239,8 +239,8 @@ func TestDeleteVnet(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualnetworks.NewMockVNetScope(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_async.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) @@ -266,13 +266,13 @@ func TestIsVnetManaged(t *testing.T) { name string expectedError string result bool - expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) + expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) }{ { name: "spec is nil", result: false, expectedError: "cannot get vnet to check if it is managed: spec is nil", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { s.VNetSpec().Return(nil) }, }, @@ -280,7 +280,7 @@ func TestIsVnetManaged(t *testing.T) { name: "managed vnet returns true", result: true, expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(managedTags, nil) @@ -291,7 +291,7 @@ func TestIsVnetManaged(t *testing.T) { name: "custom vnet returns false", result: false, expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(unmanagedTags, nil) @@ -301,7 +301,7 @@ func TestIsVnetManaged(t *testing.T) { { name: "GET fails returns an error", expectedError: internalError.Error(), - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(armresources.TagsResource{}, internalError) @@ -317,7 +317,7 @@ func TestIsVnetManaged(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualnetworks.NewMockVNetScope(mockCtrl) - tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT()) diff --git a/azure/services/vmextensions/vmextensions_test.go b/azure/services/vmextensions/vmextensions_test.go index 7297bd87141..c4f97af7312 100644 --- a/azure/services/vmextensions/vmextensions_test.go +++ b/azure/services/vmextensions/vmextensions_test.go @@ -27,7 +27,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vmextensions/mock_vmextensions" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -66,12 +66,12 @@ func TestReconcileVMExtension(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "extension is in succeeded state", expectedError: "", - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, nil) @@ -80,7 +80,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "extension is in failed state", expectedError: extensionFailedError.Error(), - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, gomockinternal.ErrStrEq(extensionFailedError.Error())) @@ -89,7 +89,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "extension is still creating", expectedError: extensionNotDoneError.Error(), - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, notDoneError) s.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, gomockinternal.ErrStrEq(extensionNotDoneError.Error())) @@ -98,7 +98,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "reconcile multiple extensions", expectedError: "", - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1, &extensionSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec2, serviceName).Return(nil, nil) @@ -108,7 +108,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "error creating the first extension", expectedError: extensionFailedError.Error(), - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1, &extensionSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, internalError) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec2, serviceName).Return(nil, nil) @@ -125,7 +125,7 @@ func TestReconcileVMExtension(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_vmextensions.NewMockVMExtensionScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/vnetpeerings/vnetpeerings_test.go b/azure/services/vnetpeerings/vnetpeerings_test.go index b437c0eb8d0..f995214381a 100644 --- a/azure/services/vnetpeerings/vnetpeerings_test.go +++ b/azure/services/vnetpeerings/vnetpeerings_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings/mock_vnetpeerings" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -108,12 +108,12 @@ func TestReconcileVnetPeerings(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "create one peering", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:1]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) p.UpdatePutStatus(infrav1.VnetPeeringReadyCondition, ServiceName, nil) @@ -122,14 +122,14 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "noop if no peering specs are found", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "create even number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:2]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -139,7 +139,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "create odd number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringExtraSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -150,7 +150,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "create multiple peerings on one vnet", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -164,7 +164,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "error in creating peering", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -178,7 +178,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "not done error in creating is ignored", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil, internalError) @@ -192,7 +192,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "not done error in creating is overwritten", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -206,7 +206,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "not done error in creating remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -228,7 +228,7 @@ func TestReconcileVnetPeerings(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_vnetpeerings.NewMockVnetPeeringScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -252,12 +252,12 @@ func TestDeleteVnetPeerings(t *testing.T) { testcases := []struct { name string expectedError string - expect func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) }{ { name: "delete one peering", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:1]) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) p.UpdateDeleteStatus(infrav1.VnetPeeringReadyCondition, ServiceName, nil) @@ -266,14 +266,14 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "noop if no peering specs are found", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete even number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:2]) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -283,7 +283,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "delete odd number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringExtraSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -294,7 +294,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "delete multiple peerings on one vnet", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -308,7 +308,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "error in deleting peering", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -322,7 +322,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "not done error in deleting is ignored", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(internalError) @@ -336,7 +336,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "not done error in deleting is overwritten", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -350,7 +350,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "not done error in deleting remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -372,7 +372,7 @@ func TestDeleteVnetPeerings(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_vnetpeerings.NewMockVnetPeeringScope(mockCtrl) - asyncMock := mock_async.NewMockReconciler(mockCtrl) + asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT())