Skip to content

Commit

Permalink
Fix metadata prefetch e2e tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hime committed Nov 15, 2024
1 parent 4818cf1 commit b7d6841
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 14 additions & 4 deletions test/e2e/specs/specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const (
GolangImage = "golang:1.22.7"
UbuntuImage = "ubuntu:20.04"

LastPublishedSidecarContainerImage = "gcr.io/gke-release/gcs-fuse-csi-driver-sidecar-mounter@sha256:c83609ecf50d05a141167b8c6cf4dfe14ff07f01cd96a9790921db6748d40902"
LastPublishedSidecarContainerImage = "gcr.io/gke-release/gcs-fuse-csi-driver-sidecar-mounter@sha256:380bd2a716b936d9469d09e3a83baf22dddca1586a04a0060d7006ea78930cac"

pollInterval = 1 * time.Second
pollTimeout = 1 * time.Minute
Expand Down Expand Up @@ -497,13 +497,23 @@ func (t *TestPod) SetCustomSidecarContainerImage() {
})
}

func (t *TestPod) VerifyCustomSidecarContainerImage(isNativeSidecar bool) {
func (t *TestPod) VerifyCustomSidecarContainerImage(isNativeSidecar, hasMetadataPrefetch bool) {
if isNativeSidecar {
gomega.Expect(t.pod.Spec.InitContainers).To(gomega.HaveLen(1))
if hasMetadataPrefetch {
gomega.Expect(t.pod.Spec.InitContainers).To(gomega.HaveLen(2))
gomega.Expect(t.pod.Spec.InitContainers[1].Name).To(gomega.Equal(webhook.MetadataPrefetchSidecarName))
} else {
gomega.Expect(t.pod.Spec.InitContainers).To(gomega.HaveLen(1))
}
gomega.Expect(t.pod.Spec.InitContainers[0].Name).To(gomega.Equal(webhook.GcsFuseSidecarName))
gomega.Expect(t.pod.Spec.InitContainers[0].Image).To(gomega.Equal(LastPublishedSidecarContainerImage))
} else {
gomega.Expect(t.pod.Spec.Containers).To(gomega.HaveLen(2))
if hasMetadataPrefetch {
gomega.Expect(t.pod.Spec.Containers).To(gomega.HaveLen(3))
gomega.Expect(t.pod.Spec.Containers[1].Name).To(gomega.Equal(webhook.MetadataPrefetchSidecarName))
} else {
gomega.Expect(t.pod.Spec.Containers).To(gomega.HaveLen(2))
}
gomega.Expect(t.pod.Spec.Containers[0].Name).To(gomega.Equal(webhook.GcsFuseSidecarName))
gomega.Expect(t.pod.Spec.Containers[0].Image).To(gomega.Equal(LastPublishedSidecarContainerImage))
}
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/testsuites/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ func (t *gcsFuseCSIVolumesTestSuite) DefineTests(driver storageframework.TestDri
init(configPrefix)
defer cleanup()

// Check if test is using metadata prefetch.
var hasMetadataPrefetch bool
if configPrefix == specs.EnableMetadataPrefetchPrefix {
hasMetadataPrefetch = true
}

ginkgo.By("Configuring the pod")
tPod := specs.NewTestPod(f.ClientSet, f.Namespace)
tPod.SetCustomSidecarContainerImage()
Expand All @@ -323,7 +329,7 @@ func (t *gcsFuseCSIVolumesTestSuite) DefineTests(driver storageframework.TestDri
tPod.WaitForRunning(ctx)

ginkgo.By("Checking that the sidecar container is using the custom image")
tPod.VerifyCustomSidecarContainerImage(supportsNativeSidecar)
tPod.VerifyCustomSidecarContainerImage(supportsNativeSidecar, hasMetadataPrefetch)

ginkgo.By("Checking that the pod command exits with no error")
tPod.VerifyExecInPodSucceed(f, specs.TesterContainerName, fmt.Sprintf("mount | grep %v | grep rw,", mountPath))
Expand Down

0 comments on commit b7d6841

Please sign in to comment.