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

Use storage.k8s.io/v1 in tests instead of v1beta1 #43296

Merged
merged 1 commit into from
Mar 17, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/e2e/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ go_library(
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/rbac/v1beta1:go_default_library",
"//pkg/apis/settings/v1alpha1:go_default_library",
"//pkg/apis/storage/v1:go_default_library",
"//pkg/apis/storage/v1/util:go_default_library",
"//pkg/apis/storage/v1beta1:go_default_library",
"//pkg/apis/storage/v1beta1/util:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/core/v1:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/extensions/v1beta1:go_default_library",
Expand Down
139 changes: 81 additions & 58 deletions test/e2e/volume_provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
"k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/kubernetes/pkg/api/v1"
rbacv1beta1 "k8s.io/kubernetes/pkg/apis/rbac/v1beta1"
storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util"
storage "k8s.io/kubernetes/pkg/apis/storage/v1"
storageutil "k8s.io/kubernetes/pkg/apis/storage/v1/util"
storagebeta "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/test/e2e/framework"

Expand Down Expand Up @@ -104,46 +105,44 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
ns = f.Namespace.Name
})

/*
TODO: enable when GKE is updated with the new API
framework.KubeDescribe("DynamicProvisioner", func() {
It("should create and delete persistent volumes [Slow] [Volume]", func() {
framework.SkipUnlessProviderIs("openstack", "gce", "aws", "gke", "vsphere")

By("creating a StorageClass")
class := newStorageClass("", "internal")
class, err := c.StorageV1beta1().StorageClasses().Create(class)
defer c.StorageV1beta1().StorageClasses().Delete(class.Name, nil)
Expect(err).NotTo(HaveOccurred())

By("creating a claim with a dynamic provisioning annotation")
claim := newClaim(ns)
claim.Spec.StorageClassName = &class.Name

defer func() {
c.Core().PersistentVolumeClaims(ns).Delete(claim.Name, nil)
}()
claim, err = c.Core().PersistentVolumeClaims(ns).Create(claim)
Expect(err).NotTo(HaveOccurred())

if framework.ProviderIs("vsphere") {
// vsphere provider does not allocate volumes in 1GiB chunks, so setting expected size
// equal to requestedSize
testDynamicProvisioning(c, claim, requestedSize)
} else {
// Expected size of the volume is 2GiB, because the other three supported cloud
// providers allocate volumes in 1GiB chunks.
testDynamicProvisioning(c, claim, "2Gi")
}
})
framework.KubeDescribe("DynamicProvisioner", func() {
It("should create and delete persistent volumes [Slow] [Volume]", func() {
framework.SkipUnlessProviderIs("openstack", "gce", "aws", "gke")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@divyenpatel You should add vsphere back to all these tests once your CI environment is updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msau42 Yes sure.

cc: @BaluDontu @tusharnt


By("creating a StorageClass")
class := newStorageClass("", "internal")
class, err := c.StorageV1().StorageClasses().Create(class)
defer c.StorageV1().StorageClasses().Delete(class.Name, nil)
Expect(err).NotTo(HaveOccurred())

By("creating a claim with a dynamic provisioning annotation")
claim := newClaim(ns)
claim.Spec.StorageClassName = &class.Name

defer func() {
c.Core().PersistentVolumeClaims(ns).Delete(claim.Name, nil)
}()
claim, err = c.Core().PersistentVolumeClaims(ns).Create(claim)
Expect(err).NotTo(HaveOccurred())

if framework.ProviderIs("vsphere") {
// vsphere provider does not allocate volumes in 1GiB chunks, so setting expected size
// equal to requestedSize
testDynamicProvisioning(c, claim, requestedSize)
} else {
// Expected size of the volume is 2GiB, because the other three supported cloud
// providers allocate volumes in 1GiB chunks.
testDynamicProvisioning(c, claim, "2Gi")
}
})
*/
})

framework.KubeDescribe("DynamicProvisioner Beta", func() {
It("should create and delete persistent volumes [Slow] [Volume]", func() {
framework.SkipUnlessProviderIs("openstack", "gce", "aws", "gke")

By("creating a StorageClass")
class := newStorageClass("", "beta")
class := newBetaStorageClass("", "beta")
_, err := c.StorageV1beta1().StorageClasses().Create(class)
defer c.StorageV1beta1().StorageClasses().Delete(class.Name, nil)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -199,17 +198,13 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
sc := newStorageClass("", suffix)
// Set an unmanaged zone.
sc.Parameters = map[string]string{"zone": unmanagedZone}
sc, err = c.StorageV1beta1().StorageClasses().Create(sc)
defer Expect(c.StorageV1beta1().StorageClasses().Delete(sc.Name, nil)).To(Succeed())
sc, err = c.StorageV1().StorageClasses().Create(sc)
defer Expect(c.StorageV1().StorageClasses().Delete(sc.Name, nil)).To(Succeed())
Expect(err).NotTo(HaveOccurred())

By("Creating a claim and expecting it to timeout")
pvc := newClaim(ns)
// TODO: switch to attribute when GKE is updated
pvc.Annotations = map[string]string{
v1.BetaStorageClassAnnotation: sc.Name,
}
//pvc.Spec.StorageClassName = &className
pvc.Spec.StorageClassName = &sc.Name
pvc, err = c.Core().PersistentVolumeClaims(ns).Create(pvc)
defer Expect(c.Core().PersistentVolumeClaims(ns).Delete(pvc.Name, nil)).To(Succeed())
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -261,16 +256,19 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {

By("creating a StorageClass")
class := newStorageClass(externalPluginName, "external")
_, err = c.StorageV1beta1().StorageClasses().Create(class)
defer c.StorageV1beta1().StorageClasses().Delete(class.Name, nil)
_, err = c.StorageV1().StorageClasses().Create(class)
defer c.StorageV1().StorageClasses().Delete(class.Name, nil)
Expect(err).NotTo(HaveOccurred())

By("creating a claim with a dynamic provisioning annotation")
claim := newClaim(ns)
className := class.Name
// TODO: switch to attribute when GKE is updated
claim.Annotations = map[string]string{v1.BetaStorageClassAnnotation: className}
//claim.Spec.StorageClassName = &className
// the external provisioner understands Beta only right now, see
// https://github.com/kubernetes-incubator/external-storage/issues/37
// claim.Spec.StorageClassName = &className
claim.Annotations = map[string]string{
v1.BetaStorageClassAnnotation: className,
}
defer func() {
c.Core().PersistentVolumeClaims(ns).Delete(claim.Name, nil)
}()
Expand Down Expand Up @@ -362,11 +360,13 @@ func updateDefaultStorageClass(c clientset.Interface, defaultStr string) {

if defaultStr == "" {
delete(sc.Annotations, storageutil.BetaIsDefaultStorageClassAnnotation)
delete(sc.Annotations, storageutil.IsDefaultStorageClassAnnotation)
} else {
if sc.Annotations == nil {
sc.Annotations = make(map[string]string)
}
sc.Annotations[storageutil.BetaIsDefaultStorageClassAnnotation] = defaultStr
sc.Annotations[storageutil.IsDefaultStorageClassAnnotation] = defaultStr
}

sc, err = c.StorageV1().StorageClasses().Update(sc)
Expand Down Expand Up @@ -447,18 +447,23 @@ func runInPodWithVolume(c clientset.Interface, ns, claimName, command string) {
framework.ExpectNoError(framework.WaitForPodSuccessInNamespaceSlow(c, pod.Name, pod.Namespace))
}

func getDefaultPluginName() string {
switch {
case framework.ProviderIs("gke"), framework.ProviderIs("gce"):
return "kubernetes.io/gce-pd"
case framework.ProviderIs("aws"):
return "kubernetes.io/aws-ebs"
case framework.ProviderIs("openstack"):
return "kubernetes.io/cinder"
case framework.ProviderIs("vsphere"):
return "kubernetes.io/vsphere-volume"
}
return ""
}

func newStorageClass(pluginName, suffix string) *storage.StorageClass {
if pluginName == "" {
switch {
case framework.ProviderIs("gke"), framework.ProviderIs("gce"):
pluginName = "kubernetes.io/gce-pd"
case framework.ProviderIs("aws"):
pluginName = "kubernetes.io/aws-ebs"
case framework.ProviderIs("openstack"):
pluginName = "kubernetes.io/cinder"
case framework.ProviderIs("vsphere"):
pluginName = "kubernetes.io/vsphere-volume"
}
pluginName = getDefaultPluginName()
}

return &storage.StorageClass{
Expand All @@ -472,6 +477,24 @@ func newStorageClass(pluginName, suffix string) *storage.StorageClass {
}
}

// TODO: remove when storage.k8s.io/v1beta1 and beta storage class annotations
// are removed.
func newBetaStorageClass(pluginName, suffix string) *storagebeta.StorageClass {
if pluginName == "" {
pluginName = getDefaultPluginName()
}

return &storagebeta.StorageClass{
TypeMeta: metav1.TypeMeta{
Kind: "StorageClass",
},
ObjectMeta: metav1.ObjectMeta{
Name: "myclass-" + suffix,
},
Provisioner: pluginName,
}
}

func startExternalProvisioner(c clientset.Interface, ns string) *v1.Pod {
podClient := c.Core().Pods(ns)

Expand Down