Skip to content

Commit

Permalink
Add a hostnetwork enabled test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
siyanshen committed Feb 5, 2025
1 parent eeeb147 commit 6e5f996
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/specs/specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ func (t *TestPod) SetImage(image string) {
t.pod.Spec.Containers[0].Image = image
}

func (t *TestPod) EnableHostNetwork() {
t.pod.Spec.HostNetwork = true
}

func (t *TestPod) SetResource(cpuLimit, memoryLimit, storageLimit string) {
cpu, _ := resource.ParseQuantity(cpuLimit)
mem, _ := resource.ParseQuantity(memoryLimit)
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/testsuites/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,46 @@ func (t *gcsFuseCSIMountTestSuite) DefineTests(driver storageframework.TestDrive
tPod1.Cleanup(ctx)
}

testCaseHostNetworkEnabled := func(configPrefix ...string) {
init(configPrefix...)
defer cleanup()

ginkgo.By("Configuring hostnetwork enabled pod")
tPod := specs.NewTestPod(f.ClientSet, f.Namespace)
tPod.SetupVolume(l.volumeResource, volumeName, mountPath, false)
tPod.EnableHostNetwork()

ginkgo.By("Deploying hostnetwork enabled pod")
tPod.Create(ctx)

ginkgo.By("Checking pod is running")
tPod.WaitForRunning(ctx)

ginkgo.By("Checking that the pod command exits with no error")
tPod.VerifyExecInPodSucceedWithOutput(f, specs.TesterContainerName, fmt.Sprintf(`mountpoint -d "%s"`, mountPath))

ginkgo.By("Checking that the pod can accessbucket")
// Create a new file B using gcsfuse.
tPod.VerifyExecInPodSucceed(f, specs.TesterContainerName, fmt.Sprintf("touch %v/testfile", mountPath))

// List the volume.
volumeContents := tPod.VerifyExecInPodSucceedWithOutput(f, specs.TesterContainerName, fmt.Sprintf("ls %v", mountPath))
ginkgo.By("Volume content: " + volumeContents)
ginkgo.By("Deleting pod")
tPod.Cleanup(ctx)
}

ginkgo.It("[read ahead config] should update read ahead config knobs", func() {
if pattern.VolType == storageframework.DynamicPV {
e2eskipper.Skipf("skip for volume type %v", storageframework.DynamicPV)
}
testCaseStoreAndRetainData(specs.EnableCustomReadAhead)
})

ginkgo.It("should successfully mount for hostnetwork enabled pods", func() {
if pattern.VolType == storageframework.DynamicPV {
e2eskipper.Skipf("skip for volume type %v", storageframework.DynamicPV)
}
testCaseHostNetworkEnabled()
})
}

0 comments on commit 6e5f996

Please sign in to comment.