Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OCPBUGS-45069] Add a check for manila share type #205

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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