Skip to content

Commit c686b81

Browse files
authored
Merge pull request #1559 from andyzhangx/use-wi-for-e2e-test-1.23
[release-1.23] test: use workload identity for e2e test
2 parents 2797300 + 7ba40a9 commit c686b81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+145
-6302
lines changed

deploy/example/storageclass-blob-nfs.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
provisioner: blob.csi.azure.com
77
parameters:
88
protocol: nfs
9+
useDataPlaneAPI: "false"
910
volumeBindingMode: Immediate
1011
allowVolumeExpansion: true
1112
mountOptions:

deploy/example/storageclass-blobfuse.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
provisioner: blob.csi.azure.com
77
parameters:
88
skuName: Premium_LRS # available values: Standard_LRS, Premium_LRS, Standard_GRS, Standard_RAGRS
9+
useDataPlaneAPI: "false"
910
reclaimPolicy: Delete
1011
volumeBindingMode: Immediate
1112
allowVolumeExpansion: true

deploy/example/storageclass-blobfuse2.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ provisioner: blob.csi.azure.com
77
parameters:
88
skuName: Premium_LRS # available values: Standard_LRS, Premium_LRS, Standard_GRS, Standard_RAGRS
99
protocol: fuse2
10+
useDataPlaneAPI: "false"
1011
reclaimPolicy: Delete
1112
volumeBindingMode: Immediate
1213
allowVolumeExpansion: true

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ require (
1717
github.com/kubernetes-csi/csi-lib-utils v0.13.0
1818
github.com/onsi/gomega v1.32.0
1919
github.com/pborman/uuid v1.2.1
20-
github.com/pelletier/go-toml v1.9.5
2120
github.com/stretchr/testify v1.9.0
2221
golang.org/x/net v0.27.0
2322
google.golang.org/grpc v1.65.0

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL
215215
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
216216
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
217217
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
218-
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
219-
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
220218
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
221219
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
222220
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

hack/verify-examples.sh

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ rollout_and_wait() {
2828
}
2929

3030
echo "begin to create deployment examples ..."
31+
32+
kubectl config set-context --current --namespace=default
33+
3134
if [ -v EXTERNAL_E2E_TEST_BLOBFUSE_v2 ]; then
3235
echo "create blobfuse2 storage class ..."
3336
kubectl apply -f deploy/example/storageclass-blobfuse2.yaml

pkg/util/util.go

+4
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ func parseAzcopyJobShow(jobshow string) (AzcopyJobState, string, error) {
326326
func GetKubeClient(kubeconfig string, kubeAPIQPS float64, kubeAPIBurst int, userAgent string) (kubernetes.Interface, error) {
327327
var err error
328328
var kubeCfg *rest.Config
329+
if kubeconfig == "no-need-kubeconfig" {
330+
klog.V(2).Infof("kubeconfig is set as no-need-kubeconfig, kubeClient will be nil")
331+
return nil, nil
332+
}
329333
if kubeCfg, err = clientcmd.BuildConfigFromFlags("", kubeconfig); err != nil {
330334
return nil, err
331335
}

test/e2e/dynamic_provisioning_test.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
898898
Pod: pod,
899899
PodWithClonedVolume: podWithClonedVolume,
900900
StorageClassParameters: map[string]string{
901+
"useDataPlaneAPI": "true",
901902
"skuName": "Premium_LRS",
902903
"protocol": "nfs",
903904
"mountPermissions": "0755",
@@ -930,6 +931,7 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
930931
Pod: pod,
931932
PodWithClonedVolume: podWithClonedVolume,
932933
StorageClassParameters: map[string]string{
934+
"useDataPlaneAPI": "true",
933935
"skuName": "Premium_LRS",
934936
"protocol": "nfs",
935937
"mountPermissions": "0755",
@@ -963,8 +965,9 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
963965
Pod: pod,
964966
PodWithClonedVolume: podWithClonedVolume,
965967
StorageClassParameters: map[string]string{
966-
"skuName": "Standard_LRS",
967-
"protocol": "fuse2",
968+
"useDataPlaneAPI": "true",
969+
"skuName": "Standard_LRS",
970+
"protocol": "fuse2",
968971
},
969972
}
970973
test.Run(ctx, cs, ns)
@@ -995,8 +998,9 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
995998
Pod: pod,
996999
PodWithClonedVolume: podWithClonedVolume,
9971000
StorageClassParameters: map[string]string{
998-
"skuName": "Standard_LRS",
999-
"protocol": "fuse2",
1001+
"useDataPlaneAPI": "true",
1002+
"skuName": "Standard_LRS",
1003+
"protocol": "fuse2",
10001004
},
10011005
}
10021006
test.Run(ctx, cs, ns)
@@ -1026,12 +1030,14 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
10261030
Pod: pod,
10271031
PodWithClonedVolume: podWithClonedVolume,
10281032
StorageClassParameters: map[string]string{
1033+
"useDataPlaneAPI": "true",
10291034
"skuName": "Premium_LRS",
10301035
"protocol": "nfs",
10311036
"mountPermissions": "0755",
10321037
"allowsharedkeyaccess": "true",
10331038
},
10341039
ClonedStorageClassParameters: map[string]string{
1040+
"useDataPlaneAPI": "true",
10351041
"skuName": "Standard_LRS",
10361042
"protocol": "nfs",
10371043
"mountPermissions": "0755",
@@ -1066,12 +1072,14 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
10661072
Pod: pod,
10671073
PodWithClonedVolume: podWithClonedVolume,
10681074
StorageClassParameters: map[string]string{
1069-
"skuName": "Standard_LRS",
1070-
"protocol": "fuse2",
1075+
"useDataPlaneAPI": "true",
1076+
"skuName": "Standard_LRS",
1077+
"protocol": "fuse2",
10711078
},
10721079
ClonedStorageClassParameters: map[string]string{
1073-
"skuName": "Premium_LRS",
1074-
"protocol": "fuse2",
1080+
"useDataPlaneAPI": "true",
1081+
"skuName": "Premium_LRS",
1082+
"protocol": "fuse2",
10751083
},
10761084
}
10771085
test.Run(ctx, cs, ns)

test/e2e/pre_provisioning_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Pre-Provisioned", func() {
219219
})
220220

221221
ginkgo.It("should use Key Vault", func(ctx ginkgo.SpecContext) {
222+
ginkgo.Skip("test case is not available currently due to test-infra migration")
222223
volumeSize := fmt.Sprintf("%dGi", defaultVolumeSize)
223224
reclaimPolicy := v1.PersistentVolumeReclaimRetain
224225
volumeBindingMode := storagev1.VolumeBindingImmediate
@@ -252,6 +253,7 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Pre-Provisioned", func() {
252253
})
253254

254255
ginkgo.It("should use SAS token", func(ctx ginkgo.SpecContext) {
256+
ginkgo.Skip("test case is not available currently due to test-infra migration")
255257
pods := []testsuites.PodDetails{
256258
{
257259
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",

test/e2e/suite_test.go

+2-34
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package e2e
1818

1919
import (
2020
"context"
21-
"encoding/json"
2221
"flag"
2322
"fmt"
2423
"log"
@@ -42,7 +41,6 @@ import (
4241
"sigs.k8s.io/blob-csi-driver/pkg/util"
4342
"sigs.k8s.io/blob-csi-driver/test/utils/azure"
4443
"sigs.k8s.io/blob-csi-driver/test/utils/credentials"
45-
"sigs.k8s.io/blob-csi-driver/test/utils/testutil"
4644
)
4745

4846
const (
@@ -82,24 +80,11 @@ func TestE2E(t *testing.T) {
8280
var _ = ginkgo.SynchronizedBeforeSuite(func(ctx ginkgo.SpecContext) []byte {
8381
creds, err := credentials.CreateAzureCredentialFile()
8482
gomega.Expect(err).NotTo(gomega.HaveOccurred())
85-
azureClient, err := azure.GetClient(creds.Cloud, creds.SubscriptionID, creds.AADClientID, creds.TenantID, creds.AADClientSecret)
83+
azureClient, err := azure.GetClient(creds.Cloud, creds.SubscriptionID, creds.AADClientID, creds.TenantID, creds.AADClientSecret, creds.AADFederatedTokenFile)
8684
gomega.Expect(err).NotTo(gomega.HaveOccurred())
8785
_, err = azureClient.EnsureResourceGroup(ctx, creds.ResourceGroup, creds.Location, nil)
8886
gomega.Expect(err).NotTo(gomega.HaveOccurred())
8987

90-
if testutil.IsRunningInProw() {
91-
// Need to login to ACR using SP credential if we are running in Prow so we can push test images.
92-
// If running locally, user should run 'docker login' before running E2E tests
93-
registry := os.Getenv("REGISTRY")
94-
gomega.Expect(registry).NotTo(gomega.Equal(""))
95-
96-
log.Println("Attempting docker login with Azure service principal")
97-
cmd := exec.Command("docker", "login", fmt.Sprintf("--username=%s", creds.AADClientID), fmt.Sprintf("--password=%s", creds.AADClientSecret), registry)
98-
err = cmd.Run()
99-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
100-
log.Println("docker login is successful")
101-
}
102-
10388
// Install Azure Blob Storage CSI driver on cluster from project root
10489
e2eBootstrap := testCmd{
10590
command: "make",
@@ -115,25 +100,8 @@ var _ = ginkgo.SynchronizedBeforeSuite(func(ctx ginkgo.SpecContext) []byte {
115100
endLog: "metrics service created",
116101
}
117102
execTestCmd([]testCmd{e2eBootstrap, createMetricsSVC})
118-
119-
if testutil.IsRunningInProw() {
120-
data, err := json.Marshal(creds)
121-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
122-
return data
123-
}
124-
125103
return nil
126104
}, func(ctx ginkgo.SpecContext, data []byte) {
127-
if testutil.IsRunningInProw() {
128-
creds := &credentials.Credentials{}
129-
err := json.Unmarshal(data, creds)
130-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
131-
// set env for azidentity.EnvironmentCredential
132-
os.Setenv("AZURE_TENANT_ID", creds.TenantID)
133-
os.Setenv("AZURE_CLIENT_ID", creds.AADClientID)
134-
os.Setenv("AZURE_CLIENT_SECRET", creds.AADClientSecret)
135-
}
136-
137105
// k8s.io/kubernetes/test/e2e/framework requires env KUBECONFIG to be set
138106
// it does not fall back to defaults
139107
if os.Getenv(kubeconfigEnvVar) == "" {
@@ -226,7 +194,7 @@ func execTestCmd(cmds []testCmd) {
226194
func checkAccountCreationLeak(ctx context.Context) {
227195
creds, err := credentials.CreateAzureCredentialFile()
228196
gomega.Expect(err).NotTo(gomega.HaveOccurred())
229-
azureClient, err := azure.GetClient(creds.Cloud, creds.SubscriptionID, creds.AADClientID, creds.TenantID, creds.AADClientSecret)
197+
azureClient, err := azure.GetClient(creds.Cloud, creds.SubscriptionID, creds.AADClientID, creds.TenantID, creds.AADClientSecret, creds.AADFederatedTokenFile)
230198
gomega.Expect(err).NotTo(gomega.HaveOccurred())
231199

232200
accountNum, err := azureClient.GetAccountNumByResourceGroup(ctx, creds.ResourceGroup)

0 commit comments

Comments
 (0)