Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e0ab1dcf
Commit
e0ab1dcf
authored
Mar 17, 2017
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use storage.k8s.io/v1 in tests instead of v1beta1
parent
223c721d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
59 deletions
+83
-59
BUILD
test/e2e/BUILD
+2
-1
volume_provisioning.go
test/e2e/volume_provisioning.go
+81
-58
No files found.
test/e2e/BUILD
View file @
e0ab1dcf
...
@@ -116,8 +116,9 @@ go_library(
...
@@ -116,8 +116,9 @@ go_library(
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/rbac/v1beta1:go_default_library",
"//pkg/apis/rbac/v1beta1:go_default_library",
"//pkg/apis/settings/v1alpha1: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:go_default_library",
"//pkg/apis/storage/v1beta1/util:go_default_library",
"//pkg/client/clientset_generated/clientset: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/core/v1:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/extensions/v1beta1:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/extensions/v1beta1:go_default_library",
...
...
test/e2e/volume_provisioning.go
View file @
e0ab1dcf
...
@@ -26,8 +26,9 @@ import (
...
@@ -26,8 +26,9 @@ import (
"k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
rbacv1beta1
"k8s.io/kubernetes/pkg/apis/rbac/v1beta1"
rbacv1beta1
"k8s.io/kubernetes/pkg/apis/rbac/v1beta1"
storage
"k8s.io/kubernetes/pkg/apis/storage/v1beta1"
storage
"k8s.io/kubernetes/pkg/apis/storage/v1"
storageutil
"k8s.io/kubernetes/pkg/apis/storage/v1beta1/util"
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/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
...
@@ -104,46 +105,44 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
...
@@ -104,46 +105,44 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
ns
=
f
.
Namespace
.
Name
ns
=
f
.
Namespace
.
Name
})
})
/*
framework
.
KubeDescribe
(
"DynamicProvisioner"
,
func
()
{
TODO: enable when GKE is updated with the new API
It
(
"should create and delete persistent volumes [Slow] [Volume]"
,
func
()
{
framework.KubeDescribe("DynamicProvisioner", func() {
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
)
It("should create and delete persistent volumes [Slow] [Volume]", func() {
framework.SkipUnlessProviderIs("openstack", "gce", "aws", "gke", "vsphere")
By
(
"creating a StorageClass"
)
class
:=
newStorageClass
(
""
,
"internal"
)
By("creating a StorageClass")
class
,
err
:=
c
.
StorageV1
()
.
StorageClasses
()
.
Create
(
class
)
class := newStorageClass("", "internal")
defer
c
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
class, err := c.StorageV1beta1().StorageClasses().Create(class)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer c.StorageV1beta1().StorageClasses().Delete(class.Name, nil)
Expect(err).NotTo(HaveOccurred())
By
(
"creating a claim with a dynamic provisioning annotation"
)
claim
:=
newClaim
(
ns
)
By("creating a claim with a dynamic provisioning annotation")
claim
.
Spec
.
StorageClassName
=
&
class
.
Name
claim := newClaim(ns)
claim.Spec.StorageClassName = &class.Name
defer
func
()
{
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Delete
(
claim
.
Name
,
nil
)
defer func() {
}()
c.Core().PersistentVolumeClaims(ns).Delete(claim.Name, nil)
claim
,
err
=
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Create
(
claim
)
}()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
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
if framework.ProviderIs("vsphere") {
// equal to requestedSize
// vsphere provider does not allocate volumes in 1GiB chunks, so setting expected size
testDynamicProvisioning
(
c
,
claim
,
requestedSize
)
// equal to requestedSize
}
else
{
testDynamicProvisioning(c, claim, requestedSize)
// Expected size of the volume is 2GiB, because the other three supported cloud
} else {
// providers allocate volumes in 1GiB chunks.
// Expected size of the volume is 2GiB, because the other three supported cloud
testDynamicProvisioning
(
c
,
claim
,
"2Gi"
)
// providers allocate volumes in 1GiB chunks.
}
testDynamicProvisioning(c, claim, "2Gi")
}
})
})
})
*/
})
framework
.
KubeDescribe
(
"DynamicProvisioner Beta"
,
func
()
{
framework
.
KubeDescribe
(
"DynamicProvisioner Beta"
,
func
()
{
It
(
"should create and delete persistent volumes [Slow] [Volume]"
,
func
()
{
It
(
"should create and delete persistent volumes [Slow] [Volume]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
)
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
)
By
(
"creating a StorageClass"
)
By
(
"creating a StorageClass"
)
class
:=
newStorageClass
(
""
,
"beta"
)
class
:=
new
Beta
StorageClass
(
""
,
"beta"
)
_
,
err
:=
c
.
StorageV1beta1
()
.
StorageClasses
()
.
Create
(
class
)
_
,
err
:=
c
.
StorageV1beta1
()
.
StorageClasses
()
.
Create
(
class
)
defer
c
.
StorageV1beta1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
defer
c
.
StorageV1beta1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -199,17 +198,13 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
...
@@ -199,17 +198,13 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
sc
:=
newStorageClass
(
""
,
suffix
)
sc
:=
newStorageClass
(
""
,
suffix
)
// Set an unmanaged zone.
// Set an unmanaged zone.
sc
.
Parameters
=
map
[
string
]
string
{
"zone"
:
unmanagedZone
}
sc
.
Parameters
=
map
[
string
]
string
{
"zone"
:
unmanagedZone
}
sc
,
err
=
c
.
StorageV1
beta1
()
.
StorageClasses
()
.
Create
(
sc
)
sc
,
err
=
c
.
StorageV1
()
.
StorageClasses
()
.
Create
(
sc
)
defer
Expect
(
c
.
StorageV1
beta1
()
.
StorageClasses
()
.
Delete
(
sc
.
Name
,
nil
))
.
To
(
Succeed
())
defer
Expect
(
c
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
sc
.
Name
,
nil
))
.
To
(
Succeed
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Creating a claim and expecting it to timeout"
)
By
(
"Creating a claim and expecting it to timeout"
)
pvc
:=
newClaim
(
ns
)
pvc
:=
newClaim
(
ns
)
// TODO: switch to attribute when GKE is updated
pvc
.
Spec
.
StorageClassName
=
&
sc
.
Name
pvc
.
Annotations
=
map
[
string
]
string
{
v1
.
BetaStorageClassAnnotation
:
sc
.
Name
,
}
//pvc.Spec.StorageClassName = &className
pvc
,
err
=
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Create
(
pvc
)
pvc
,
err
=
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Create
(
pvc
)
defer
Expect
(
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Delete
(
pvc
.
Name
,
nil
))
.
To
(
Succeed
())
defer
Expect
(
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Delete
(
pvc
.
Name
,
nil
))
.
To
(
Succeed
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -261,16 +256,19 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
...
@@ -261,16 +256,19 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
By
(
"creating a StorageClass"
)
By
(
"creating a StorageClass"
)
class
:=
newStorageClass
(
externalPluginName
,
"external"
)
class
:=
newStorageClass
(
externalPluginName
,
"external"
)
_
,
err
=
c
.
StorageV1
beta1
()
.
StorageClasses
()
.
Create
(
class
)
_
,
err
=
c
.
StorageV1
()
.
StorageClasses
()
.
Create
(
class
)
defer
c
.
StorageV1
beta1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
defer
c
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
class
.
Name
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"creating a claim with a dynamic provisioning annotation"
)
By
(
"creating a claim with a dynamic provisioning annotation"
)
claim
:=
newClaim
(
ns
)
claim
:=
newClaim
(
ns
)
className
:=
class
.
Name
className
:=
class
.
Name
// TODO: switch to attribute when GKE is updated
// the external provisioner understands Beta only right now, see
claim
.
Annotations
=
map
[
string
]
string
{
v1
.
BetaStorageClassAnnotation
:
className
}
// https://github.com/kubernetes-incubator/external-storage/issues/37
//claim.Spec.StorageClassName = &className
// claim.Spec.StorageClassName = &className
claim
.
Annotations
=
map
[
string
]
string
{
v1
.
BetaStorageClassAnnotation
:
className
,
}
defer
func
()
{
defer
func
()
{
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Delete
(
claim
.
Name
,
nil
)
c
.
Core
()
.
PersistentVolumeClaims
(
ns
)
.
Delete
(
claim
.
Name
,
nil
)
}()
}()
...
@@ -362,11 +360,13 @@ func updateDefaultStorageClass(c clientset.Interface, defaultStr string) {
...
@@ -362,11 +360,13 @@ func updateDefaultStorageClass(c clientset.Interface, defaultStr string) {
if
defaultStr
==
""
{
if
defaultStr
==
""
{
delete
(
sc
.
Annotations
,
storageutil
.
BetaIsDefaultStorageClassAnnotation
)
delete
(
sc
.
Annotations
,
storageutil
.
BetaIsDefaultStorageClassAnnotation
)
delete
(
sc
.
Annotations
,
storageutil
.
IsDefaultStorageClassAnnotation
)
}
else
{
}
else
{
if
sc
.
Annotations
==
nil
{
if
sc
.
Annotations
==
nil
{
sc
.
Annotations
=
make
(
map
[
string
]
string
)
sc
.
Annotations
=
make
(
map
[
string
]
string
)
}
}
sc
.
Annotations
[
storageutil
.
BetaIsDefaultStorageClassAnnotation
]
=
defaultStr
sc
.
Annotations
[
storageutil
.
BetaIsDefaultStorageClassAnnotation
]
=
defaultStr
sc
.
Annotations
[
storageutil
.
IsDefaultStorageClassAnnotation
]
=
defaultStr
}
}
sc
,
err
=
c
.
StorageV1
()
.
StorageClasses
()
.
Update
(
sc
)
sc
,
err
=
c
.
StorageV1
()
.
StorageClasses
()
.
Update
(
sc
)
...
@@ -447,18 +447,23 @@ func runInPodWithVolume(c clientset.Interface, ns, claimName, command string) {
...
@@ -447,18 +447,23 @@ func runInPodWithVolume(c clientset.Interface, ns, claimName, command string) {
framework
.
ExpectNoError
(
framework
.
WaitForPodSuccessInNamespaceSlow
(
c
,
pod
.
Name
,
pod
.
Namespace
))
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
{
func
newStorageClass
(
pluginName
,
suffix
string
)
*
storage
.
StorageClass
{
if
pluginName
==
""
{
if
pluginName
==
""
{
switch
{
pluginName
=
getDefaultPluginName
()
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"
}
}
}
return
&
storage
.
StorageClass
{
return
&
storage
.
StorageClass
{
...
@@ -472,6 +477,24 @@ func newStorageClass(pluginName, suffix string) *storage.StorageClass {
...
@@ -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
{
func
startExternalProvisioner
(
c
clientset
.
Interface
,
ns
string
)
*
v1
.
Pod
{
podClient
:=
c
.
Core
()
.
Pods
(
ns
)
podClient
:=
c
.
Core
()
.
Pods
(
ns
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment