diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a471ffdd..65d0deaa 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -88,7 +88,6 @@ jobs: REQUEST_TOKEN=$ACTIONS_ID_TOKEN_REQUEST_TOKEN REQUEST_URI=$ACTIONS_ID_TOKEN_REQUEST_URL FED_TOKEN=$(curl -H "Authorization: bearer $REQUEST_TOKEN" "${REQUEST_URI}&audience=api://AzureADTokenExchange" | jq .value -r) - echo "FED_TOKEN=$FED_TOKEN" >> $GITHUB_ENV az login --service-principal -u ${{ secrets.E2E_AZURE_CLIENT_ID }} -t ${{ secrets.AZURE_TENANT_ID }} --federated-token $FED_TOKEN --output none sleep 240 done & @@ -109,9 +108,6 @@ jobs: AZURE_NETWORK_SETTING: ${{ matrix.network-setting }} AZURE_RESOURCE_GROUP: ${{ env.AZURE_RESOURCE_GROUP }} ENABLE_TRAFFIC_MANAGER: ${{ matrix.enable-traffic-manager }} - AZURE_CLIENT_ID: ${{ secrets.E2E_AZURE_CLIENT_ID}} - AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} - FED_TOKEN: ${{ env.FED_TOKEN }} - name: Cleanup e2e if: always() run: | diff --git a/pkg/controllers/hub/trafficmanagerprofile/controller.go b/pkg/controllers/hub/trafficmanagerprofile/controller.go index 9fd09c43..e8965bda 100644 --- a/pkg/controllers/hub/trafficmanagerprofile/controller.go +++ b/pkg/controllers/hub/trafficmanagerprofile/controller.go @@ -171,7 +171,7 @@ func (r *Reconciler) handleUpdate(ctx context.Context, profile *fleetnetv1alpha1 return r.updateProfileStatus(ctx, profile, res.Profile, updateErr) } -// EqualAzureTrafficManagerProfile compares only few fields of the buildCurrentFunc and desired Azure Traffic Manager profiles +// EqualAzureTrafficManagerProfile compares only few fields of the current and desired Azure Traffic Manager profiles // by ignoring others. // The desired profile is built by the controllers and all the required fields should not be nil. func EqualAzureTrafficManagerProfile(current, desired armtrafficmanager.Profile) bool { diff --git a/test/README.md b/test/README.md index 04dd2a58..81c71e1b 100644 --- a/test/README.md +++ b/test/README.md @@ -22,7 +22,6 @@ export AZURE_SUBSCRIPTION_ID= # and detailed explanations for each network setting are provided in the scripts under folder "test/scripts". export AZURE_NETWORK_SETTING=shared-vnet export ENABLE_TRAFFIC_MANAGER=true -export USE_DEFAULT_AZURE_CLIENTS=true ``` Run Makefile Target to setup e2e environment: diff --git a/test/common/trafficmanager/azureprovider/profile.go b/test/common/trafficmanager/azureprovider/profile.go index 03f9cbb9..4c3e5596 100644 --- a/test/common/trafficmanager/azureprovider/profile.go +++ b/test/common/trafficmanager/azureprovider/profile.go @@ -8,10 +8,10 @@ package azureprovider import ( "context" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" . "github.com/onsi/gomega" ) @@ -29,6 +29,7 @@ type Validator struct { ResourceGroup string } +// ValidateProfile validates the traffic manager profile. func (v *Validator) ValidateProfile(ctx context.Context, name string, want armtrafficmanager.Profile) { res, err := v.ProfileClient.Get(ctx, v.ResourceGroup, name, nil) Expect(err).Should(Succeed(), "Failed to get the traffic manager profile") diff --git a/test/e2e/azuretrafficmanager_utils.go b/test/e2e/azuretrafficmanager_utils.go deleted file mode 100644 index d02254e7..00000000 --- a/test/e2e/azuretrafficmanager_utils.go +++ /dev/null @@ -1,6 +0,0 @@ -/* -Copyright (c) Microsoft Corporation. -Licensed under the MIT license. -*/ - -package e2e diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index f749d1e7..9ddaa57d 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -8,13 +8,11 @@ package e2e import ( "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" - "go.goms.io/fleet-networking/test/common/trafficmanager/azureprovider" "os" "testing" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -26,20 +24,13 @@ import ( fleetv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1" fleetnetv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1" + "go.goms.io/fleet-networking/test/common/trafficmanager/azureprovider" "go.goms.io/fleet-networking/test/e2e/framework" ) const ( - // common environments required by both ci pipeline and local development azureSubscriptionEnv = "AZURE_SUBSCRIPTION_ID" azureTrafficManagerResourceGroupEnv = "AZURE_RESOURCE_GROUP" - - // environments required by the ci pipeline - azureClientIDEnv = "AZURE_CLIENT_ID" - azureTenantIDEnv = "AZURE_TENANT_ID" - federatedTokenEnv = "FED_TOKEN" - - useDefaultAzureClientsEnv = "USE_DEFAULT_AZURE_CLIENTS" ) var ( @@ -87,6 +78,7 @@ var _ = BeforeSuite(func() { testNamespace = framework.UniqueTestNamespace() createTestNamespace(context.Background()) + initAzureClients() }) @@ -97,29 +89,9 @@ func initAzureClients() { atmResourceGroup := os.Getenv(azureTrafficManagerResourceGroupEnv) Expect(atmResourceGroup).ShouldNot(BeEmpty(), "Azure traffic manager resource group is not set") - //createDefaultAzureClients := os.Getenv(useDefaultAzureClientsEnv) - var cred azcore.TokenCredential - var err error - //if createDefaultAzureClients == "true" { - cred, err = azidentity.NewDefaultAzureCredential(nil) + cred, err := azidentity.NewDefaultAzureCredential(nil) Expect(err).Should(Succeed(), "Failed to obtain default Azure credential") - //} else { - // clientID := os.Getenv(azureClientIDEnv) - // Expect(clientID).ShouldNot(BeEmpty(), "Azure client ID is not set") - // tenantID := os.Getenv(azureTenantIDEnv) - // Expect(tenantID).ShouldNot(BeEmpty(), "Azure tenant ID is not set") - // - // options := &azidentity.ClientAssertionCredentialOptions{} - // cred, err = azidentity.NewClientAssertionCredential( - // tenantID, - // clientID, - // func(ctx context.Context) (string, error) { - // return os.Getenv(federatedTokenEnv), nil - // }, - // options, - // ) - // Expect(err).Should(Succeed(), "Failed to obtain Azure credential") - //} + clientFactory, err := armtrafficmanager.NewClientFactory(subscriptionID, cred, nil) Expect(err).Should(Succeed(), "Failed to create client") atmValidator = &azureprovider.Validator{ diff --git a/test/e2e/traffic_manager_test.go b/test/e2e/traffic_manager_test.go index 35672acf..e2e6908c 100644 --- a/test/e2e/traffic_manager_test.go +++ b/test/e2e/traffic_manager_test.go @@ -26,11 +26,10 @@ var ( enabled = os.Getenv("ENABLE_TRAFFIC_MANAGER") == "true" ) -var _ = FDescribe("Test exporting service via Azure traffic manager", func() { +var _ = Describe("Test exporting service via Azure traffic manager", func() { var wm *framework.WorkloadManager var profile fleetnetv1alpha1.TrafficManagerProfile var hubClient client.Client - //var dnsName string BeforeEach(func() { if !enabled {