mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
feat(zfspv) Add golint check to travis (#175)
Signed-off-by: vaniisgh <vanisingh@live.co.uk>
This commit is contained in:
parent
8b7ad5cb45
commit
8bbf3d7d2f
34 changed files with 321 additions and 266 deletions
|
|
@ -21,20 +21,20 @@ import (
|
|||
)
|
||||
|
||||
// ListBuilder enables building an instance of
|
||||
// Podlist
|
||||
// List
|
||||
type ListBuilder struct {
|
||||
list *PodList
|
||||
list *List
|
||||
filters predicateList
|
||||
}
|
||||
|
||||
// NewListBuilder returns a instance of ListBuilder
|
||||
func NewListBuilder() *ListBuilder {
|
||||
return &ListBuilder{list: &PodList{items: []*Pod{}}}
|
||||
return &ListBuilder{list: &List{items: []*Pod{}}}
|
||||
}
|
||||
|
||||
// ListBuilderForAPIList returns a instance of ListBuilder from API PodList
|
||||
// ListBuilderForAPIList returns a instance of ListBuilder from API List
|
||||
func ListBuilderForAPIList(pods *corev1.PodList) *ListBuilder {
|
||||
b := &ListBuilder{list: &PodList{}}
|
||||
b := &ListBuilder{list: &List{}}
|
||||
if pods == nil {
|
||||
return b
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ func ListBuilderForAPIList(pods *corev1.PodList) *ListBuilder {
|
|||
|
||||
// ListBuilderForObjectList returns a instance of ListBuilder from API Pods
|
||||
func ListBuilderForObjectList(pods ...*Pod) *ListBuilder {
|
||||
b := &ListBuilder{list: &PodList{}}
|
||||
b := &ListBuilder{list: &List{}}
|
||||
if pods == nil {
|
||||
return b
|
||||
}
|
||||
|
|
@ -61,11 +61,11 @@ func ListBuilderForObjectList(pods ...*Pod) *ListBuilder {
|
|||
// List returns the list of pod
|
||||
// instances that was built by this
|
||||
// builder
|
||||
func (b *ListBuilder) List() *PodList {
|
||||
func (b *ListBuilder) List() *List {
|
||||
if b.filters == nil || len(b.filters) == 0 {
|
||||
return b.list
|
||||
}
|
||||
filtered := &PodList{}
|
||||
filtered := &List{}
|
||||
for _, pod := range b.list.items {
|
||||
if b.filters.all(pod) {
|
||||
filtered.items = append(filtered.items, pod)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ type Pod struct {
|
|||
object *corev1.Pod
|
||||
}
|
||||
|
||||
// PodList holds the list of API pod instances
|
||||
type PodList struct {
|
||||
// List holds the list of API pod instances
|
||||
type List struct {
|
||||
items []*Pod
|
||||
}
|
||||
|
||||
|
|
@ -36,8 +36,8 @@ type predicateList []Predicate
|
|||
// against the provided pod instance
|
||||
type Predicate func(*Pod) bool
|
||||
|
||||
// ToAPIList converts PodList to API PodList
|
||||
func (pl *PodList) ToAPIList() *corev1.PodList {
|
||||
// ToAPIList converts List to API List
|
||||
func (pl *List) ToAPIList() *corev1.PodList {
|
||||
plist := &corev1.PodList{}
|
||||
for _, pod := range pl.items {
|
||||
plist.Items = append(plist.Items, *pod.object)
|
||||
|
|
@ -56,8 +56,8 @@ func NewForAPIObject(obj *corev1.Pod, opts ...podBuildOption) *Pod {
|
|||
return p
|
||||
}
|
||||
|
||||
// Len returns the number of items present in the PodList
|
||||
func (pl *PodList) Len() int {
|
||||
// Len returns the number of items present in the List
|
||||
func (pl *List) Len() int {
|
||||
return len(pl.items)
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ func IsCompleted() Predicate {
|
|||
}
|
||||
|
||||
// HasLabels returns true if provided labels
|
||||
// map[key]value are present in the provided PodList
|
||||
// map[key]value are present in the provided List
|
||||
// instance
|
||||
func HasLabels(keyValuePair map[string]string) Predicate {
|
||||
return func(p *Pod) bool {
|
||||
|
|
@ -117,7 +117,7 @@ func HasLabels(keyValuePair map[string]string) Predicate {
|
|||
}
|
||||
|
||||
// HasLabel return true if provided lable
|
||||
// key and value are present in the the provided PodList
|
||||
// key and value are present in the the provided List
|
||||
// instance
|
||||
func (p *Pod) HasLabel(key, value string) bool {
|
||||
val, ok := p.object.GetLabels()[key]
|
||||
|
|
@ -154,15 +154,15 @@ func (p *Pod) GetAPIObject() *corev1.Pod {
|
|||
return p.object
|
||||
}
|
||||
|
||||
// FromList created a PodList with provided api podlist
|
||||
func FromList(pods *corev1.PodList) *PodList {
|
||||
// FromList created a List with provided api List
|
||||
func FromList(pods *corev1.PodList) *List {
|
||||
pl := ListBuilderForAPIList(pods).
|
||||
List()
|
||||
return pl
|
||||
}
|
||||
|
||||
// GetScheduledNodes returns the nodes on which pods are scheduled
|
||||
func (pl *PodList) GetScheduledNodes() map[string]int {
|
||||
func (pl *List) GetScheduledNodes() map[string]int {
|
||||
nodeNames := make(map[string]int)
|
||||
for _, p := range pl.items {
|
||||
p := p // pin it
|
||||
|
|
@ -171,8 +171,8 @@ func (pl *PodList) GetScheduledNodes() map[string]int {
|
|||
return nodeNames
|
||||
}
|
||||
|
||||
// IsMatchNodeAny checks the PodList is running on the provided nodes
|
||||
func (pl *PodList) IsMatchNodeAny(nodes map[string]int) bool {
|
||||
// IsMatchNodeAny checks the List is running on the provided nodes
|
||||
func (pl *List) IsMatchNodeAny(nodes map[string]int) bool {
|
||||
for _, p := range pl.items {
|
||||
p := p // pin it
|
||||
if nodes[p.object.Spec.NodeName] == 0 {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
// ListBuilder enables building an instance of
|
||||
// PVCList
|
||||
// List
|
||||
type ListBuilder struct {
|
||||
// template to build a list of pvcs
|
||||
template *corev1.PersistentVolumeClaim
|
||||
|
|
@ -32,14 +32,14 @@ type ListBuilder struct {
|
|||
// template
|
||||
count int
|
||||
|
||||
list *PVCList
|
||||
list *List
|
||||
filters PredicateList
|
||||
errs []error
|
||||
}
|
||||
|
||||
// NewListBuilder returns an instance of ListBuilder
|
||||
func NewListBuilder() *ListBuilder {
|
||||
return &ListBuilder{list: &PVCList{}}
|
||||
return &ListBuilder{list: &List{}}
|
||||
}
|
||||
|
||||
// ListBuilderFromTemplate returns a new instance of
|
||||
|
|
@ -62,7 +62,7 @@ func ListBuilderFromTemplate(pvc *corev1.PersistentVolumeClaim) *ListBuilder {
|
|||
// ListBuilderForAPIObjects returns a new instance of
|
||||
// ListBuilder based on provided api pvc list
|
||||
func ListBuilderForAPIObjects(pvcs *corev1.PersistentVolumeClaimList) *ListBuilder {
|
||||
b := &ListBuilder{list: &PVCList{}}
|
||||
b := &ListBuilder{list: &List{}}
|
||||
|
||||
if pvcs == nil {
|
||||
b.errs = append(
|
||||
|
|
@ -82,7 +82,7 @@ func ListBuilderForAPIObjects(pvcs *corev1.PersistentVolumeClaimList) *ListBuild
|
|||
|
||||
// ListBuilderForObjects returns a new instance of
|
||||
// ListBuilder based on provided pvc list
|
||||
func ListBuilderForObjects(pvcs *PVCList) *ListBuilder {
|
||||
func ListBuilderForObjects(pvcs *List) *ListBuilder {
|
||||
b := &ListBuilder{}
|
||||
if pvcs == nil {
|
||||
b.errs = append(
|
||||
|
|
@ -122,7 +122,7 @@ func (b *ListBuilder) buildFromTemplateIfNilList() {
|
|||
|
||||
// List returns the list of pvc instances
|
||||
// that was built by this builder
|
||||
func (b *ListBuilder) List() (*PVCList, error) {
|
||||
func (b *ListBuilder) List() (*List, error) {
|
||||
if len(b.errs) > 0 {
|
||||
return nil, errors.Errorf("failed to build pvc list: %+v", b.errs)
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ func (b *ListBuilder) List() (*PVCList, error) {
|
|||
return b.list, nil
|
||||
}
|
||||
|
||||
filteredList := &PVCList{}
|
||||
filteredList := &List{}
|
||||
for _, pvc := range b.list.items {
|
||||
if b.filters.all(pvc) {
|
||||
filteredList.items = append(filteredList.items, pvc)
|
||||
|
|
@ -144,7 +144,7 @@ func (b *ListBuilder) List() (*PVCList, error) {
|
|||
}
|
||||
|
||||
// Len returns the number of items present
|
||||
// in the PVCList of a builder
|
||||
// in the List of a builder
|
||||
func (b *ListBuilder) Len() (int, error) {
|
||||
l, err := b.List()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -27,21 +27,21 @@ type PVC struct {
|
|||
object *corev1.PersistentVolumeClaim
|
||||
}
|
||||
|
||||
// PVCList is a wrapper over persistentvolumeclaim api
|
||||
// List is a wrapper over persistentvolumeclaim api
|
||||
// object. It provides build, validations and other common
|
||||
// logic to be used by various feature specific callers.
|
||||
type PVCList struct {
|
||||
type List struct {
|
||||
items []*PVC
|
||||
}
|
||||
|
||||
// Len returns the number of items present
|
||||
// in the PVCList
|
||||
func (p *PVCList) Len() int {
|
||||
// in the List
|
||||
func (p *List) Len() int {
|
||||
return len(p.items)
|
||||
}
|
||||
|
||||
// ToAPIList converts PVCList to API PVCList
|
||||
func (p *PVCList) ToAPIList() *corev1.PersistentVolumeClaimList {
|
||||
// ToAPIList converts List to API List
|
||||
func (p *List) ToAPIList() *corev1.PersistentVolumeClaimList {
|
||||
plist := &corev1.PersistentVolumeClaimList{}
|
||||
for _, pvc := range p.items {
|
||||
plist.Items = append(plist.Items, *pvc.object)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func (b *ListBuilder) APIList() (*storagev1.StorageClassList, error) {
|
|||
}
|
||||
|
||||
// Len returns the number of items present
|
||||
// in the PVCList of a builder
|
||||
// in the List of a builder
|
||||
func (b *ListBuilder) Len() (int, error) {
|
||||
l, err := b.List()
|
||||
if err != nil {
|
||||
|
|
|
|||
235
tests/utils.go
235
tests/utils.go
|
|
@ -19,8 +19,9 @@ package tests
|
|||
import (
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
|
||||
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
|
||||
"github.com/openebs/zfs-localpv/pkg/zfs"
|
||||
"github.com/openebs/zfs-localpv/tests/container"
|
||||
|
|
@ -39,14 +40,14 @@ import (
|
|||
|
||||
// IsPVCBoundEventually checks if the pvc is bound or not eventually
|
||||
func IsPVCBoundEventually(pvcName string) bool {
|
||||
return Eventually(func() bool {
|
||||
return gomega.Eventually(func() bool {
|
||||
volume, err := PVCClient.
|
||||
Get(pvcName, metav1.GetOptions{})
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
return pvc.NewForAPIObject(volume).IsBound()
|
||||
},
|
||||
60, 5).
|
||||
Should(BeTrue())
|
||||
Should(gomega.BeTrue())
|
||||
}
|
||||
|
||||
// IsPVCResizedEventually checks if the pvc is bound or not eventually
|
||||
|
|
@ -55,54 +56,54 @@ func IsPVCResizedEventually(pvcName string, newCapacity string) bool {
|
|||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return Eventually(func() bool {
|
||||
return gomega.Eventually(func() bool {
|
||||
volume, err := PVCClient.
|
||||
Get(pvcName, metav1.GetOptions{})
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
pvcStorage := volume.Status.Capacity[corev1.ResourceName(corev1.ResourceStorage)]
|
||||
return pvcStorage == newStorage
|
||||
},
|
||||
120, 5).
|
||||
Should(BeTrue())
|
||||
Should(gomega.BeTrue())
|
||||
}
|
||||
|
||||
// IsPodRunningEventually return true if the pod comes to running state
|
||||
func IsPodRunningEventually(namespace, podName string) bool {
|
||||
return Eventually(func() bool {
|
||||
return gomega.Eventually(func() bool {
|
||||
p, err := PodClient.
|
||||
WithNamespace(namespace).
|
||||
Get(podName, metav1.GetOptions{})
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
return pod.NewForAPIObject(p).
|
||||
IsRunning()
|
||||
},
|
||||
60, 5).
|
||||
Should(BeTrue())
|
||||
Should(gomega.BeTrue())
|
||||
}
|
||||
|
||||
// IsPropUpdatedEventually checks if the property is updated or not eventually
|
||||
func IsPropUpdatedEventually(vol *apis.ZFSVolume, prop string, val string) bool {
|
||||
return Eventually(func() bool {
|
||||
return gomega.Eventually(func() bool {
|
||||
|
||||
newVal, err := zfs.GetVolumeProperty(vol, prop)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
return (newVal == val)
|
||||
},
|
||||
60, 5).
|
||||
Should(BeTrue())
|
||||
Should(gomega.BeTrue())
|
||||
}
|
||||
|
||||
// IsPVCDeletedEventually tries to get the deleted pvc
|
||||
// and returns true if pvc is not found
|
||||
// else returns false
|
||||
func IsPVCDeletedEventually(pvcName string) bool {
|
||||
return Eventually(func() bool {
|
||||
return gomega.Eventually(func() bool {
|
||||
_, err := PVCClient.
|
||||
Get(pvcName, metav1.GetOptions{})
|
||||
return k8serrors.IsNotFound(err)
|
||||
},
|
||||
120, 10).
|
||||
Should(BeTrue())
|
||||
Should(gomega.BeTrue())
|
||||
}
|
||||
|
||||
func createExt4StorageClass() {
|
||||
|
|
@ -115,16 +116,16 @@ func createExt4StorageClass() {
|
|||
"fstype": "ext4",
|
||||
}
|
||||
|
||||
By("building a ext4 storage class")
|
||||
ginkgo.By("building a ext4 storage class")
|
||||
scObj, err = sc.NewBuilder().
|
||||
WithGenerateName(scName).
|
||||
WithParametersNew(parameters).
|
||||
WithProvisioner(ZFSProvisioner).Build()
|
||||
Expect(err).ShouldNot(HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(),
|
||||
"while building ext4 storageclass obj with prefix {%s}", scName)
|
||||
|
||||
scObj, err = SCClient.Create(scObj)
|
||||
Expect(err).To(BeNil(), "while creating a ext4 storageclass {%s}", scName)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while creating a ext4 storageclass {%s}", scName)
|
||||
}
|
||||
|
||||
func createStorageClass() {
|
||||
|
|
@ -136,16 +137,16 @@ func createStorageClass() {
|
|||
"poolname": POOLNAME,
|
||||
}
|
||||
|
||||
By("building a default storage class")
|
||||
ginkgo.By("building a default storage class")
|
||||
scObj, err = sc.NewBuilder().
|
||||
WithGenerateName(scName).
|
||||
WithParametersNew(parameters).
|
||||
WithProvisioner(ZFSProvisioner).Build()
|
||||
Expect(err).ShouldNot(HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(),
|
||||
"while building default storageclass obj with prefix {%s}", scName)
|
||||
|
||||
scObj, err = SCClient.Create(scObj)
|
||||
Expect(err).To(BeNil(), "while creating a default storageclass {%s}", scName)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while creating a default storageclass {%s}", scName)
|
||||
}
|
||||
|
||||
func createZfsStorageClass() {
|
||||
|
|
@ -158,145 +159,147 @@ func createZfsStorageClass() {
|
|||
"fstype": "zfs",
|
||||
}
|
||||
|
||||
By("building a zfs storage class")
|
||||
ginkgo.By("building a zfs storage class")
|
||||
scObj, err = sc.NewBuilder().
|
||||
WithGenerateName(scName).
|
||||
WithParametersNew(parameters).
|
||||
WithVolumeExpansion(true).
|
||||
WithProvisioner(ZFSProvisioner).Build()
|
||||
Expect(err).ShouldNot(HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(),
|
||||
"while building zfs storageclass obj with prefix {%s}", scName)
|
||||
|
||||
scObj, err = SCClient.Create(scObj)
|
||||
Expect(err).To(BeNil(), "while creating a zfs storageclass {%s}", scName)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while creating a zfs storageclass {%s}", scName)
|
||||
}
|
||||
|
||||
// VerifyZFSVolume verify the properties of a zfs-volume
|
||||
func VerifyZFSVolume() {
|
||||
By("fetching zfs volume")
|
||||
ginkgo.By("fetching zfs volume")
|
||||
vol, err := ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", pvcObj.Spec.VolumeName)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", pvcObj.Spec.VolumeName)
|
||||
|
||||
volType := zfs.VOLTYPE_ZVOL
|
||||
if scObj.Parameters["fstype"] == zfs.FSTYPE_ZFS {
|
||||
volType = zfs.VOLTYPE_DATASET
|
||||
volType := zfs.VolTypeZVol
|
||||
if scObj.Parameters["fstype"] == zfs.FSTypeZFS {
|
||||
volType = zfs.VolTypeDataset
|
||||
}
|
||||
|
||||
By("verifying zfs volume")
|
||||
Expect(vol.Spec.PoolName).To(Equal(scObj.Parameters["poolname"]),
|
||||
ginkgo.By("verifying zfs volume")
|
||||
gomega.Expect(vol.Spec.PoolName).To(gomega.Equal(scObj.Parameters["poolname"]),
|
||||
"while checking poolname of zfs volume", pvcObj.Spec.VolumeName)
|
||||
Expect(vol.Spec.FsType).To(Equal(scObj.Parameters["fstype"]),
|
||||
gomega.Expect(vol.Spec.FsType).To(gomega.Equal(scObj.Parameters["fstype"]),
|
||||
"while checking fstype of zfs volume", pvcObj.Spec.VolumeName)
|
||||
Expect(vol.Spec.VolumeType).To(Equal(volType),
|
||||
gomega.Expect(vol.Spec.VolumeType).To(gomega.Equal(volType),
|
||||
"while checking Volume type as dataset", pvcObj.Spec.VolumeName)
|
||||
Expect(vol.Spec.Capacity).To(Equal(capacity),
|
||||
gomega.Expect(vol.Spec.Capacity).To(gomega.Equal(capacity),
|
||||
"while checking capacity of zfs volume", pvcObj.Spec.VolumeName)
|
||||
|
||||
// it might fail if we are checking finializer before event is processed by node agent
|
||||
Expect(vol.Finalizers[0]).To(Equal(zfs.ZFSFinalizer), "while checking finializer to be set {%s}", pvcObj.Spec.VolumeName)
|
||||
gomega.Expect(vol.Finalizers[0]).To(gomega.Equal(zfs.ZFSFinalizer), "while checking finializer to be set {%s}", pvcObj.Spec.VolumeName)
|
||||
}
|
||||
|
||||
// VerifyZFSVolumePropEdit verigies the volume properties
|
||||
func VerifyZFSVolumePropEdit() {
|
||||
By("verifying compression property update")
|
||||
ginkgo.By("verifying compression property update")
|
||||
|
||||
By("fetching zfs volume for setting compression=on")
|
||||
ginkgo.By("fetching zfs volume for setting compression=on")
|
||||
vol, err := ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
|
||||
val := "on"
|
||||
vol.Spec.Compression = val
|
||||
_, err = ZFSClient.WithNamespace(OpenEBSNamespace).Update(vol)
|
||||
Expect(err).To(BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
|
||||
status := IsPropUpdatedEventually(vol, "compression", val)
|
||||
Expect(status).To(Equal(true), "while updating compression=on {%s}", vol.Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while updating compression=on {%s}", vol.Name)
|
||||
|
||||
By("fetching zfs volume for setting compression=off")
|
||||
ginkgo.By("fetching zfs volume for setting compression=off")
|
||||
vol, err = ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
|
||||
val = "off"
|
||||
vol.Spec.Compression = val
|
||||
_, err = ZFSClient.WithNamespace(OpenEBSNamespace).Update(vol)
|
||||
Expect(err).To(BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
|
||||
status = IsPropUpdatedEventually(vol, "compression", val)
|
||||
Expect(status).To(Equal(true), "while updating compression=off {%s}", vol.Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while updating compression=off {%s}", vol.Name)
|
||||
|
||||
By("verifying dedup property update")
|
||||
ginkgo.By("verifying dedup property update")
|
||||
|
||||
By("fetching zfs volume for setting dedup=on")
|
||||
ginkgo.By("fetching zfs volume for setting dedup=on")
|
||||
vol, err = ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
|
||||
val = "on"
|
||||
vol.Spec.Dedup = val
|
||||
_, err = ZFSClient.WithNamespace(OpenEBSNamespace).Update(vol)
|
||||
Expect(err).To(BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
|
||||
status = IsPropUpdatedEventually(vol, "dedup", val)
|
||||
Expect(status).To(Equal(true), "while updating dedup=on {%s}", vol.Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while updating dedup=on {%s}", vol.Name)
|
||||
|
||||
By("fetching zfs volume for setting dedup=off")
|
||||
ginkgo.By("fetching zfs volume for setting dedup=off")
|
||||
vol, err = ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
|
||||
val = "off"
|
||||
vol.Spec.Dedup = val
|
||||
_, err = ZFSClient.WithNamespace(OpenEBSNamespace).Update(vol)
|
||||
Expect(err).To(BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
|
||||
status = IsPropUpdatedEventually(vol, "dedup", val)
|
||||
Expect(status).To(Equal(true), "while updating dedup=off {%s}", vol.Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while updating dedup=off {%s}", vol.Name)
|
||||
|
||||
if vol.Spec.VolumeType == zfs.VOLTYPE_DATASET {
|
||||
By("verifying recordsize property update")
|
||||
if vol.Spec.VolumeType == zfs.VolTypeDataset {
|
||||
ginkgo.By("verifying recordsize property update")
|
||||
|
||||
By("fetching zfs volume for setting the recordsize")
|
||||
ginkgo.By("fetching zfs volume for setting the recordsize")
|
||||
vol, err = ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
|
||||
val = "4096" // 4k
|
||||
vol.Spec.RecordSize = val
|
||||
vol.Spec.VolBlockSize = "8192"
|
||||
_, err = ZFSClient.WithNamespace(OpenEBSNamespace).Update(vol)
|
||||
Expect(err).To(BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
|
||||
status = IsPropUpdatedEventually(vol, "recordsize", val)
|
||||
Expect(status).To(Equal(true), "while updating redordsize {%s}", vol.Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while updating redordsize {%s}", vol.Name)
|
||||
} else {
|
||||
|
||||
Expect(vol.Spec.VolumeType).To(Equal(zfs.VOLTYPE_ZVOL), "voltype should be zvol {%s}", vol.Name)
|
||||
gomega.Expect(vol.Spec.VolumeType).To(gomega.Equal(zfs.VolTypeZVol), "voltype should be zvol {%s}", vol.Name)
|
||||
|
||||
By("verifying blocksize property update")
|
||||
ginkgo.By("verifying blocksize property update")
|
||||
|
||||
By("fetching zfs volume for setting the blocksize")
|
||||
ginkgo.By("fetching zfs volume for setting the blocksize")
|
||||
vol, err = ZFSClient.WithNamespace(OpenEBSNamespace).
|
||||
Get(pvcObj.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name)
|
||||
|
||||
val, err = zfs.GetVolumeProperty(vol, "volblocksize")
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
|
||||
nval := "8192" // 8k
|
||||
vol.Spec.VolBlockSize = nval
|
||||
vol.Spec.RecordSize = "16384"
|
||||
_, err = ZFSClient.WithNamespace(OpenEBSNamespace).Update(vol)
|
||||
Expect(err).To(BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
gomega.Expect(err).To(gomega.BeNil(), "while updating the zfs volume {%s}", vol.Name)
|
||||
|
||||
status = IsPropUpdatedEventually(vol, "volblocksize", val)
|
||||
Expect(status).To(Equal(true), "while updating volblocksize {%s}", vol.Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while updating volblocksize {%s}", vol.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func deleteStorageClass() {
|
||||
err := SCClient.Delete(scObj.Name, &metav1.DeleteOptions{})
|
||||
Expect(err).To(BeNil(),
|
||||
gomega.Expect(err).To(gomega.BeNil(),
|
||||
"while deleting zfs storageclass {%s}", scObj.Name)
|
||||
}
|
||||
|
||||
|
|
@ -305,38 +308,38 @@ func createAndVerifyPVC() {
|
|||
err error
|
||||
pvcName = "zfspv-pvc"
|
||||
)
|
||||
By("building a pvc")
|
||||
ginkgo.By("building a pvc")
|
||||
pvcObj, err = pvc.NewBuilder().
|
||||
WithName(pvcName).
|
||||
WithNamespace(OpenEBSNamespace).
|
||||
WithStorageClass(scObj.Name).
|
||||
WithAccessModes(accessModes).
|
||||
WithCapacity(capacity).Build()
|
||||
Expect(err).ShouldNot(
|
||||
HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(
|
||||
gomega.HaveOccurred(),
|
||||
"while building pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
|
||||
By("creating above pvc")
|
||||
ginkgo.By("creating above pvc")
|
||||
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Create(pvcObj)
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while creating pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
|
||||
By("verifying pvc status as bound")
|
||||
ginkgo.By("verifying pvc status as bound")
|
||||
|
||||
status := IsPVCBoundEventually(pvcName)
|
||||
Expect(status).To(Equal(true),
|
||||
gomega.Expect(status).To(gomega.Equal(true),
|
||||
"while checking status equal to bound")
|
||||
|
||||
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Get(pvcObj.Name, metav1.GetOptions{})
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while retrieving pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
|
|
@ -351,7 +354,7 @@ func createAndVerifyBlockPVC() {
|
|||
|
||||
volmode := corev1.PersistentVolumeBlock
|
||||
|
||||
By("building a pvc")
|
||||
ginkgo.By("building a pvc")
|
||||
pvcObj, err = pvc.NewBuilder().
|
||||
WithName(pvcName).
|
||||
WithNamespace(OpenEBSNamespace).
|
||||
|
|
@ -359,31 +362,31 @@ func createAndVerifyBlockPVC() {
|
|||
WithAccessModes(accessModes).
|
||||
WithVolumeMode(&volmode).
|
||||
WithCapacity(capacity).Build()
|
||||
Expect(err).ShouldNot(
|
||||
HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(
|
||||
gomega.HaveOccurred(),
|
||||
"while building pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
|
||||
By("creating above pvc")
|
||||
ginkgo.By("creating above pvc")
|
||||
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Create(pvcObj)
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while creating pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
|
||||
By("verifying pvc status as bound")
|
||||
ginkgo.By("verifying pvc status as bound")
|
||||
|
||||
status := IsPVCBoundEventually(pvcName)
|
||||
Expect(status).To(Equal(true),
|
||||
gomega.Expect(status).To(gomega.Equal(true),
|
||||
"while checking status equal to bound")
|
||||
|
||||
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Get(pvcObj.Name, metav1.GetOptions{})
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while retrieving pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
|
|
@ -395,46 +398,46 @@ func resizeAndVerifyPVC() {
|
|||
err error
|
||||
pvcName = "zfspv-pvc"
|
||||
)
|
||||
By("updating the pvc with new size")
|
||||
ginkgo.By("updating the pvc with new size")
|
||||
pvcObj, err = pvc.BuildFrom(pvcObj).
|
||||
WithCapacity(NewCapacity).Build()
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while building pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Update(pvcObj)
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while updating pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
|
||||
By("verifying pvc size to be updated")
|
||||
ginkgo.By("verifying pvc size to be updated")
|
||||
|
||||
status := IsPVCResizedEventually(pvcName, NewCapacity)
|
||||
Expect(status).To(Equal(true),
|
||||
gomega.Expect(status).To(gomega.Equal(true),
|
||||
"while checking pvc resize")
|
||||
|
||||
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Get(pvcObj.Name, metav1.GetOptions{})
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while retrieving pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
}
|
||||
func createDeployVerifyApp() {
|
||||
By("creating and deploying app pod", createAndDeployAppPod)
|
||||
ginkgo.By("creating and deploying app pod", createAndDeployAppPod)
|
||||
time.Sleep(30 * time.Second)
|
||||
By("verifying app pod is running", verifyAppPodRunning)
|
||||
ginkgo.By("verifying app pod is running", verifyAppPodRunning)
|
||||
}
|
||||
|
||||
func createAndDeployAppPod() {
|
||||
var err error
|
||||
By("building a busybox app pod deployment using above zfs volume")
|
||||
ginkgo.By("building a busybox app pod deployment using above zfs volume")
|
||||
deployObj, err = deploy.NewBuilder().
|
||||
WithName(appName).
|
||||
WithNamespace(OpenEBSNamespace).
|
||||
|
|
@ -484,11 +487,11 @@ func createAndDeployAppPod() {
|
|||
).
|
||||
Build()
|
||||
|
||||
Expect(err).ShouldNot(HaveOccurred(), "while building app deployement {%s}", appName)
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "while building app deployement {%s}", appName)
|
||||
|
||||
deployObj, err = DeployClient.WithNamespace(OpenEBSNamespace).Create(deployObj)
|
||||
Expect(err).ShouldNot(
|
||||
HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(
|
||||
gomega.HaveOccurred(),
|
||||
"while creating pod {%s} in namespace {%s}",
|
||||
appName,
|
||||
OpenEBSNamespace,
|
||||
|
|
@ -497,7 +500,7 @@ func createAndDeployAppPod() {
|
|||
|
||||
func createAndDeployBlockAppPod() {
|
||||
var err error
|
||||
By("building a busybox app pod deployment using above zfs volume")
|
||||
ginkgo.By("building a busybox app pod deployment using above zfs volume")
|
||||
deployObj, err = deploy.NewBuilder().
|
||||
WithName(appName).
|
||||
WithNamespace(OpenEBSNamespace).
|
||||
|
|
@ -547,11 +550,11 @@ func createAndDeployBlockAppPod() {
|
|||
).
|
||||
Build()
|
||||
|
||||
Expect(err).ShouldNot(HaveOccurred(), "while building app deployement {%s}", appName)
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "while building app deployement {%s}", appName)
|
||||
|
||||
deployObj, err = DeployClient.WithNamespace(OpenEBSNamespace).Create(deployObj)
|
||||
Expect(err).ShouldNot(
|
||||
HaveOccurred(),
|
||||
gomega.Expect(err).ShouldNot(
|
||||
gomega.HaveOccurred(),
|
||||
"while creating pod {%s} in namespace {%s}",
|
||||
appName,
|
||||
OpenEBSNamespace,
|
||||
|
|
@ -559,9 +562,9 @@ func createAndDeployBlockAppPod() {
|
|||
}
|
||||
|
||||
func createDeployVerifyBlockApp() {
|
||||
By("creating and deploying app pod", createAndDeployBlockAppPod)
|
||||
ginkgo.By("creating and deploying app pod", createAndDeployBlockAppPod)
|
||||
time.Sleep(30 * time.Second)
|
||||
By("verifying app pod is running", verifyAppPodRunning)
|
||||
ginkgo.By("verifying app pod is running", verifyAppPodRunning)
|
||||
}
|
||||
|
||||
func verifyAppPodRunning() {
|
||||
|
|
@ -571,28 +574,28 @@ func verifyAppPodRunning() {
|
|||
LabelSelector: "app=busybox",
|
||||
},
|
||||
)
|
||||
Expect(err).ShouldNot(HaveOccurred(), "while verifying application pod")
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "while verifying application pod")
|
||||
|
||||
status := IsPodRunningEventually(OpenEBSNamespace, appPod.Items[0].Name)
|
||||
Expect(status).To(Equal(true), "while checking status of pod {%s}", appPod.Items[0].Name)
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while checking status of pod {%s}", appPod.Items[0].Name)
|
||||
}
|
||||
|
||||
func deleteAppDeployment() {
|
||||
err := DeployClient.WithNamespace(OpenEBSNamespace).
|
||||
Delete(deployObj.Name, &metav1.DeleteOptions{})
|
||||
Expect(err).ShouldNot(HaveOccurred(), "while deleting application pod")
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "while deleting application pod")
|
||||
}
|
||||
|
||||
func deletePVC() {
|
||||
err := PVCClient.WithNamespace(OpenEBSNamespace).Delete(pvcName, &metav1.DeleteOptions{})
|
||||
Expect(err).To(
|
||||
BeNil(),
|
||||
gomega.Expect(err).To(
|
||||
gomega.BeNil(),
|
||||
"while deleting pvc {%s} in namespace {%s}",
|
||||
pvcName,
|
||||
OpenEBSNamespace,
|
||||
)
|
||||
By("verifying deleted pvc")
|
||||
ginkgo.By("verifying deleted pvc")
|
||||
status := IsPVCDeletedEventually(pvcName)
|
||||
Expect(status).To(Equal(true), "while trying to get deleted pvc")
|
||||
gomega.Expect(status).To(gomega.Equal(true), "while trying to get deleted pvc")
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue