Skip to content

Commit

Permalink
Update privateclusters e2e test for SDKv2
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Nov 22, 2023
1 parent 86a9b35 commit c1bdd30
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/e2e/azure_privatecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"path/filepath"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-11-01/compute"
"github.com/Azure/azure-sdk-for-go/services/msi/mgmt/2018-11-30/msi"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-08-01/network"
Expand Down Expand Up @@ -171,12 +173,11 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat

// Check that azure bastion is provisioned successfully.
{
By("verifying the Azure Bastion Host was create successfully")
settings, err := auth.GetSettingsFromEnvironment()
Expect(err).To(BeNil())
By("verifying the Azure Bastion Host was created successfully")
cred, err := azidentity.NewDefaultAzureCredential(nil)
Expect(err).NotTo(HaveOccurred())

azureBastionClient := network.NewBastionHostsClient(settings.GetSubscriptionID())
azureBastionClient.Authorizer, err = azureutil.GetAuthorizer(settings)
azureBastionClient, err := armnetwork.NewBastionHostsClient(getSubscriptionID(Default), cred, nil)
Expect(err).To(BeNil())

groupName := os.Getenv(AzureResourceGroup)
Expand All @@ -189,19 +190,20 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat
Steps: retryBackoffSteps,
}
retryFn := func() (bool, error) {
bastion, err := azureBastionClient.Get(ctx, groupName, azureBastionName)
resp, err := azureBastionClient.Get(ctx, groupName, azureBastionName, nil)
if err != nil {
return false, err
}

switch bastion.ProvisioningState {
case network.ProvisioningStateSucceeded:
bastion := resp.BastionHost
switch ptr.Deref(bastion.Properties.ProvisioningState, "") {
case armnetwork.ProvisioningStateSucceeded:
return true, nil
case network.ProvisioningStateUpdating:
case armnetwork.ProvisioningStateUpdating:
// Wait for operation to complete.
return false, nil
default:
return false, errors.New(fmt.Sprintf("Azure Bastion provisioning failed with state: %q", bastion.ProvisioningState))
return false, errors.New(fmt.Sprintf("Azure Bastion provisioning failed with state: %q", ptr.Deref(bastion.Properties.ProvisioningState, "(nil)")))
}
}
err = wait.ExponentialBackoff(backoff, retryFn)
Expand Down

0 comments on commit c1bdd30

Please sign in to comment.