Skip to content

Commit

Permalink
[OCPBUGS-45069] Add a check for manila share type
Browse files Browse the repository at this point in the history
If the share type extra spec of driver_handles_share_servers is true we skip the test.
  • Loading branch information
itzikb-redhat committed Dec 3, 2024
1 parent 4f34d68 commit 5abdb3c
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 3 deletions.
23 changes: 23 additions & 0 deletions test/extended/openstack/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets"
"github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/shares"
"github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/sharetypes"
configv1 "github.com/openshift/api/config/v1"
machinev1 "github.com/openshift/api/machine/v1beta1"
operatorv1 "github.com/openshift/api/operator/v1"
Expand Down Expand Up @@ -197,6 +198,28 @@ func GetSharesFromName(ctx context.Context, client *gophercloud.ServiceClient, s
return shares, nil
}

// return sharetype from openstack with specific name
func GetShareTypesFromName(ctx context.Context, client *gophercloud.ServiceClient, shareTypeName string) ([]sharetypes.ShareType, error) {
var emptyShareTypes []sharetypes.ShareType
var allShareTypes []sharetypes.ShareType
var shareTypes []sharetypes.ShareType

allPages, err := sharetypes.List(client, sharetypes.ListOpts{}).AllPages(ctx)
if err != nil {
return emptyShareTypes, err
}
allShareTypes, err = sharetypes.ExtractShareTypes(allPages)
if err != nil {
return emptyShareTypes, err
}
for _, shareType := range allShareTypes {
if shareType.Name == shareTypeName {
shareTypes = append(shareTypes, shareType)
}
}
return shareTypes, nil
}

// return storageClass with specific provisioner. If seek_default is true, it will look also for the default annotation.
func FindStorageClassByProvider(oc *exutil.CLI, provisioner string, seek_default bool) *storagev1.StorageClass {
scList, err := oc.AdminKubeClient().StorageV1().StorageClasses().List(context.Background(), metav1.ListOptions{})
Expand Down
13 changes: 10 additions & 3 deletions test/extended/openstack/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,22 @@ var _ = g.Describe("[sig-installer][Suite:openshift/openstack] The OpenStack pla
g.It("should create a manila share when using manila storage class", func(ctx g.SpecContext) {
var err error
manilaSc := FindStorageClassByProvider(oc, "manila.csi.openstack.org", false)
shareClient, err := client.GetServiceClient(ctx, openstack.NewSharedFileSystemV2)
o.Expect(err).NotTo(o.HaveOccurred())

// Skip if Manila Storage class is not defined
// Skip if driver_handles_share_servers = true, Ref:https://issues.redhat.com/browse/OCPBUGS-45320
if manilaSc == nil {
e2eskipper.Skipf("No StorageClass with manila.csi.openstack.org provisioner")
} else {
manilaShareTypes, err := GetShareTypesFromName(ctx, shareClient, "default")
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(len(manilaShareTypes)).To(o.Equal(1))
if manilaShareTypes[0].ExtraSpecs["driver_handles_share_servers"] == "True" {
e2eskipper.Skipf("driver_handles_share_servers should be set to False in order for the test to run")
}
}

shareClient, err := client.GetServiceClient(ctx, openstack.NewSharedFileSystemV2)
o.Expect(err).NotTo(o.HaveOccurred())

ns := oc.Namespace()
pvc := CreatePVC(ctx, clientSet, "manila-pvc", ns, manilaSc.Name, "1Gi")
fileContent := "hello"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5abdb3c

Please sign in to comment.