|
4 | 4 | "context"
|
5 | 5 | "fmt"
|
6 | 6 | "path/filepath"
|
| 7 | + "strings" |
7 | 8 |
|
8 | 9 | "github.com/onsi/ginkgo"
|
9 | 10 | "github.com/onsi/gomega"
|
@@ -233,6 +234,29 @@ func createThinStorageClass() {
|
233 | 234 | gomega.Expect(err).To(gomega.BeNil(), "while creating a thinProvision storageclass {%s}", scName)
|
234 | 235 | }
|
235 | 236 |
|
| 237 | +func createFormatOptionsStorageClass(formatOptions string) { |
| 238 | + var ( |
| 239 | + err error |
| 240 | + ) |
| 241 | + |
| 242 | + parameters := map[string]string{ |
| 243 | + "volgroup": VOLGROUP, |
| 244 | + "formatOptions": formatOptions, |
| 245 | + } |
| 246 | + |
| 247 | + ginkgo.By("building a default storage class") |
| 248 | + scObj, err = sc.NewBuilder(). |
| 249 | + WithGenerateName(scName). |
| 250 | + WithVolumeExpansion(true). |
| 251 | + WithParametersNew(parameters). |
| 252 | + WithProvisioner(LocalProvisioner).Build() |
| 253 | + gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), |
| 254 | + "while building formatOptions storageclass obj with prefix {%s}", scName) |
| 255 | + |
| 256 | + scObj, err = SCClient.Create(scObj) |
| 257 | + gomega.Expect(err).To(gomega.BeNil(), "while creating a storageclass with formatOptions {%s}", scName) |
| 258 | +} |
| 259 | + |
236 | 260 | // VerifyLVMVolume verify the properties of a lvm-volume
|
237 | 261 | // expected_vg is supposed to be passed only when vgpatten was used for scheduling.
|
238 | 262 | // If its volgroup in sc then we can just match volgroup with lvmvolume's vg field.
|
@@ -271,6 +295,18 @@ func VerifyLVMVolume(expect_ready bool, expected_vg string) {
|
271 | 295 | }
|
272 | 296 | }
|
273 | 297 |
|
| 298 | +func VerifyLVMVolumeFormatOptions(formatOptions string) { |
| 299 | + ginkgo.By("fetching lvm volume") |
| 300 | + vol_name := pvcObj.Spec.VolumeName |
| 301 | + vol, err := LVMClient.WithNamespace(OpenEBSNamespace). |
| 302 | + Get(vol_name, metav1.GetOptions{}) |
| 303 | + gomega.Expect(err).To(gomega.BeNil(), "while fetching the lvm volume {%s}", pvcObj.Spec.VolumeName) |
| 304 | + gomega.Expect(vol).To(gomega.Not(gomega.BeNil()), "LVMVolume Obj is Nil") |
| 305 | + gomega.Expect(vol.ObjectMeta.Name).To(gomega.Not(gomega.Equal(vol_name)), "LVMVolume mismatch") |
| 306 | + gomega.Expect(vol.Spec.FormatOptions).To(gomega.Equal(strings.Split(formatOptions, " ")), |
| 307 | + "While checking if lvmvolume: %s has correct formatOptions", pvcObj.Spec.VolumeName) |
| 308 | +} |
| 309 | + |
274 | 310 | func deleteStorageClass() {
|
275 | 311 | err := SCClient.Delete(scObj.Name, &metav1.DeleteOptions{})
|
276 | 312 | gomega.Expect(err).To(gomega.BeNil(),
|
@@ -560,6 +596,77 @@ func createAndDeployBlockAppPod() {
|
560 | 596 | }
|
561 | 597 | }
|
562 | 598 |
|
| 599 | +func createDeployVerifyFormatOptions() { |
| 600 | + ginkgo.By("creating and deploying verifier pod") |
| 601 | + createAndDeployVerifyFormatOptions() |
| 602 | + ginkgo.By("verifying verifier pod is running", verifyAppPodRunning) |
| 603 | +} |
| 604 | + |
| 605 | +func createAndDeployVerifyFormatOptions() { |
| 606 | + var err error |
| 607 | + appname := "format-options-verifier" |
| 608 | + labels := map[string]string{ |
| 609 | + "role": "test", |
| 610 | + "app": appname, |
| 611 | + } |
| 612 | + ginkgo.By("building app " + appname + " using above lvm volume") |
| 613 | + deployObj, err = deploy.NewBuilder(). |
| 614 | + WithName(appname). |
| 615 | + WithNamespace(OpenEBSNamespace). |
| 616 | + WithLabelsNew(labels). |
| 617 | + WithSelectorMatchLabelsNew(labels). |
| 618 | + WithPodTemplateSpecBuilder( |
| 619 | + pts.NewBuilder(). |
| 620 | + WithLabelsNew(labels). |
| 621 | + WithContainerBuilders( |
| 622 | + container.NewBuilder(). |
| 623 | + WithImage("debian:stable-slim"). |
| 624 | + WithName("verifier"). |
| 625 | + WithImagePullPolicy(corev1.PullIfNotPresent). |
| 626 | + WithEnvsNew( |
| 627 | + []corev1.EnvVar{ |
| 628 | + { |
| 629 | + Name: "EXPECTED_INODES", |
| 630 | + Value: "5001264", |
| 631 | + }, |
| 632 | + }, |
| 633 | + ). |
| 634 | + WithCommandNew( |
| 635 | + []string{ |
| 636 | + "bash", |
| 637 | + "-c", |
| 638 | + `export DEVICE=$(df --output=source '/mnt/datadir' | tail -n 1); export ACTUAL_INODES=$(tune2fs -l "$DEVICE" | grep "Inode count" | awk '{print $3}'); [ "$ACTUAL_INODES" -eq "$EXPECTED_INODES" ] && echo "Inode count is correct: $ACTUAL_INODES" && exit 0 || echo "Inode count mismatch: expected $EXPECTED_INODES, but got $ACTUAL_INODES" && exit 1`, |
| 639 | + }, |
| 640 | + ). |
| 641 | + WithVolumeMountsNew( |
| 642 | + []corev1.VolumeMount{ |
| 643 | + { |
| 644 | + Name: "datavol1", |
| 645 | + // If this path changes, modify the above fio command line accordingly. |
| 646 | + MountPath: "/mnt/datadir", |
| 647 | + }, |
| 648 | + }, |
| 649 | + ), |
| 650 | + ). |
| 651 | + WithVolumeBuilders( |
| 652 | + k8svolume.NewBuilder(). |
| 653 | + WithName("datavol1"). |
| 654 | + WithPVCSource(pvcObj.Name), |
| 655 | + ), |
| 656 | + ). |
| 657 | + Build() |
| 658 | + |
| 659 | + gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "while building app deployement {%s}", appname) |
| 660 | + |
| 661 | + deployObj, err = DeployClient.WithNamespace(OpenEBSNamespace).Create(deployObj) |
| 662 | + gomega.Expect(err).ShouldNot( |
| 663 | + gomega.HaveOccurred(), |
| 664 | + "while creating pod {%s} in namespace {%s}", |
| 665 | + appname, |
| 666 | + OpenEBSNamespace, |
| 667 | + ) |
| 668 | +} |
| 669 | + |
563 | 670 | func createDeployVerifyBlockApp() {
|
564 | 671 | ginkgo.By("creating and deploying app pod", createAndDeployBlockAppPod)
|
565 | 672 | ginkgo.By("verifying app pod is running", verifyAppPodRunning)
|
|
0 commit comments