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
3b1d1c40
Commit
3b1d1c40
authored
Mar 17, 2017
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix default storage class tests
Name of the default storage class is not "default", it must be discovered dynamically.
parent
223c721d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
11 deletions
+34
-11
volume_provisioning.go
test/e2e/volume_provisioning.go
+34
-11
No files found.
test/e2e/volume_provisioning.go
View file @
3b1d1c40
...
@@ -303,11 +303,12 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
...
@@ -303,11 +303,12 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
// Modifying the default storage class can be disruptive to other tests that depend on it
// Modifying the default storage class can be disruptive to other tests that depend on it
It
(
"should be disabled by changing the default annotation[Slow] [Serial] [Disruptive] [Volume]"
,
func
()
{
It
(
"should be disabled by changing the default annotation[Slow] [Serial] [Disruptive] [Volume]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
,
"vsphere"
)
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
,
"vsphere"
)
scName
:=
getDefaultStorageClassName
(
c
)
By
(
"setting the is-default StorageClass annotation to false"
)
By
(
"setting the is-default StorageClass annotation to false"
)
verifyDefaultStorageClass
(
c
,
true
)
verifyDefaultStorageClass
(
c
,
scName
,
true
)
defer
updateDefaultStorageClass
(
c
,
"true"
)
defer
updateDefaultStorageClass
(
c
,
scName
,
"true"
)
updateDefaultStorageClass
(
c
,
"false"
)
updateDefaultStorageClass
(
c
,
scName
,
"false"
)
By
(
"creating a claim with default storageclass and expecting it to timeout"
)
By
(
"creating a claim with default storageclass and expecting it to timeout"
)
claim
:=
newClaim
(
ns
)
claim
:=
newClaim
(
ns
)
...
@@ -327,11 +328,12 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
...
@@ -327,11 +328,12 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
// Modifying the default storage class can be disruptive to other tests that depend on it
// Modifying the default storage class can be disruptive to other tests that depend on it
It
(
"should be disabled by removing the default annotation[Slow] [Serial] [Disruptive] [Volume]"
,
func
()
{
It
(
"should be disabled by removing the default annotation[Slow] [Serial] [Disruptive] [Volume]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
,
"vsphere"
)
framework
.
SkipUnlessProviderIs
(
"openstack"
,
"gce"
,
"aws"
,
"gke"
,
"vsphere"
)
scName
:=
getDefaultStorageClassName
(
c
)
By
(
"removing the is-default StorageClass annotation"
)
By
(
"removing the is-default StorageClass annotation"
)
verifyDefaultStorageClass
(
c
,
true
)
verifyDefaultStorageClass
(
c
,
scName
,
true
)
defer
updateDefaultStorageClass
(
c
,
"true"
)
defer
updateDefaultStorageClass
(
c
,
scName
,
"true"
)
updateDefaultStorageClass
(
c
,
""
)
updateDefaultStorageClass
(
c
,
scName
,
""
)
By
(
"creating a claim with default storageclass and expecting it to timeout"
)
By
(
"creating a claim with default storageclass and expecting it to timeout"
)
claim
:=
newClaim
(
ns
)
claim
:=
newClaim
(
ns
)
...
@@ -350,14 +352,35 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
...
@@ -350,14 +352,35 @@ var _ = framework.KubeDescribe("Dynamic provisioning", func() {
})
})
})
})
func
verifyDefaultStorageClass
(
c
clientset
.
Interface
,
expectedDefault
bool
)
{
func
getDefaultStorageClassName
(
c
clientset
.
Interface
)
string
{
sc
,
err
:=
c
.
StorageV1
()
.
StorageClasses
()
.
Get
(
"default"
,
metav1
.
GetOptions
{})
list
,
err
:=
c
.
StorageV1
()
.
StorageClasses
()
.
List
(
metav1
.
ListOptions
{})
if
err
!=
nil
{
framework
.
Failf
(
"Error listing storage classes: %v"
,
err
)
}
var
scName
string
for
_
,
sc
:=
range
list
.
Items
{
if
storageutil
.
IsDefaultAnnotation
(
sc
.
ObjectMeta
)
{
if
len
(
scName
)
!=
0
{
framework
.
Failf
(
"Multiple default storage classes found: %q and %q"
,
scName
,
sc
.
Name
)
}
scName
=
sc
.
Name
}
}
if
len
(
scName
)
==
0
{
framework
.
Failf
(
"No default storage class found"
)
}
framework
.
Logf
(
"Default storage class: %q"
,
scName
)
return
scName
}
func
verifyDefaultStorageClass
(
c
clientset
.
Interface
,
scName
string
,
expectedDefault
bool
)
{
sc
,
err
:=
c
.
StorageV1
()
.
StorageClasses
()
.
Get
(
scName
,
metav1
.
GetOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
storageutil
.
IsDefaultAnnotation
(
sc
.
ObjectMeta
))
.
To
(
Equal
(
expectedDefault
))
Expect
(
storageutil
.
IsDefaultAnnotation
(
sc
.
ObjectMeta
))
.
To
(
Equal
(
expectedDefault
))
}
}
func
updateDefaultStorageClass
(
c
clientset
.
Interface
,
defaultStr
string
)
{
func
updateDefaultStorageClass
(
c
clientset
.
Interface
,
scName
string
,
defaultStr
string
)
{
sc
,
err
:=
c
.
StorageV1
()
.
StorageClasses
()
.
Get
(
"default"
,
metav1
.
GetOptions
{})
sc
,
err
:=
c
.
StorageV1
()
.
StorageClasses
()
.
Get
(
scName
,
metav1
.
GetOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
if
defaultStr
==
""
{
if
defaultStr
==
""
{
...
@@ -376,7 +399,7 @@ func updateDefaultStorageClass(c clientset.Interface, defaultStr string) {
...
@@ -376,7 +399,7 @@ func updateDefaultStorageClass(c clientset.Interface, defaultStr string) {
if
defaultStr
==
"true"
{
if
defaultStr
==
"true"
{
expectedDefault
=
true
expectedDefault
=
true
}
}
verifyDefaultStorageClass
(
c
,
expectedDefault
)
verifyDefaultStorageClass
(
c
,
scName
,
expectedDefault
)
}
}
func
newClaim
(
ns
string
)
*
v1
.
PersistentVolumeClaim
{
func
newClaim
(
ns
string
)
*
v1
.
PersistentVolumeClaim
{
...
...
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