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
8c48250a
Commit
8c48250a
authored
Jan 08, 2016
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an integration test for volume tags.
parent
400ebf87
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
9 deletions
+25
-9
persistentvolume_provisioner_controller_test.go
...entvolume/persistentvolume_provisioner_controller_test.go
+19
-5
testing.go
pkg/volume/testing.go
+5
-3
persistent_volumes_test.go
test/integration/persistent_volumes_test.go
+1
-1
No files found.
pkg/controller/persistentvolume/persistentvolume_provisioner_controller_test.go
View file @
8c48250a
...
...
@@ -33,7 +33,7 @@ import (
)
func
TestProvisionerRunStop
(
t
*
testing
.
T
)
{
controller
,
_
:=
makeTestController
()
controller
,
_
,
_
:=
makeTestController
()
if
len
(
controller
.
stopChannels
)
!=
0
{
t
.
Errorf
(
"Non-running provisioner should not have any stopChannels. Got %v"
,
len
(
controller
.
stopChannels
))
...
...
@@ -92,15 +92,15 @@ func makeTestClaim() *api.PersistentVolumeClaim {
}
}
func
makeTestController
()
(
*
PersistentVolumeProvisionerController
,
*
mockControllerClient
)
{
func
makeTestController
()
(
*
PersistentVolumeProvisionerController
,
*
mockControllerClient
,
*
volume
.
FakeVolumePlugin
)
{
mockClient
:=
&
mockControllerClient
{}
mockVolumePlugin
:=
&
volume
.
FakeVolumePlugin
{}
controller
,
_
:=
NewPersistentVolumeProvisionerController
(
mockClient
,
1
*
time
.
Second
,
nil
,
mockVolumePlugin
,
&
fake_cloud
.
FakeCloud
{})
return
controller
,
mockClient
return
controller
,
mockClient
,
mockVolumePlugin
}
func
TestReconcileClaim
(
t
*
testing
.
T
)
{
controller
,
mockClient
:=
makeTestController
()
controller
,
mockClient
,
_
:=
makeTestController
()
pvc
:=
makeTestClaim
()
// watch would have added the claim to the store
...
...
@@ -132,9 +132,16 @@ func TestReconcileClaim(t *testing.T) {
}
}
func
checkTagValue
(
t
*
testing
.
T
,
tags
map
[
string
]
string
,
tag
string
,
expectedValue
string
)
{
value
,
found
:=
tags
[
tag
]
if
!
found
||
value
!=
expectedValue
{
t
.
Errorf
(
"Expected tag value %s = %s but value %s found"
,
tag
,
expectedValue
,
value
)
}
}
func
TestReconcileVolume
(
t
*
testing
.
T
)
{
controller
,
mockClient
:=
makeTestController
()
controller
,
mockClient
,
mockVolumePlugin
:=
makeTestController
()
pv
:=
makeTestVolume
()
pvc
:=
makeTestClaim
()
...
...
@@ -163,6 +170,13 @@ func TestReconcileVolume(t *testing.T) {
if
!
isAnnotationMatch
(
pvProvisioningRequiredAnnotationKey
,
pvProvisioningCompletedAnnotationValue
,
mockClient
.
volume
.
Annotations
)
{
t
.
Errorf
(
"Expected %s but got %s"
,
pvProvisioningRequiredAnnotationKey
,
mockClient
.
volume
.
Annotations
[
pvProvisioningRequiredAnnotationKey
])
}
// Check that the volume plugin was called with correct tags
tags
:=
*
mockVolumePlugin
.
LastProvisionerOptions
.
CloudTags
checkTagValue
(
t
,
tags
,
cloudVolumeCreatedForClaimNamespaceTag
,
pvc
.
Namespace
)
checkTagValue
(
t
,
tags
,
cloudVolumeCreatedForClaimNameTag
,
pvc
.
Name
)
checkTagValue
(
t
,
tags
,
cloudVolumeCreatedForVolumeNameTag
,
pv
.
Name
)
}
var
_
controllerClient
=
&
mockControllerClient
{}
...
...
pkg/volume/testing.go
View file @
8c48250a
...
...
@@ -119,9 +119,10 @@ func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin {
// Use as:
// volume.RegisterPlugin(&FakePlugin{"fake-name"})
type
FakeVolumePlugin
struct
{
PluginName
string
Host
VolumeHost
Config
VolumeConfig
PluginName
string
Host
VolumeHost
Config
VolumeConfig
LastProvisionerOptions
VolumeOptions
}
var
_
VolumePlugin
=
&
FakeVolumePlugin
{}
...
...
@@ -160,6 +161,7 @@ func (plugin *FakeVolumePlugin) NewDeleter(spec *Spec) (Deleter, error) {
}
func
(
plugin
*
FakeVolumePlugin
)
NewProvisioner
(
options
VolumeOptions
)
(
Provisioner
,
error
)
{
plugin
.
LastProvisionerOptions
=
options
return
&
FakeProvisioner
{
options
,
plugin
.
Host
},
nil
}
...
...
test/integration/persistent_volumes_test.go
View file @
8c48250a
...
...
@@ -50,7 +50,7 @@ func TestPersistentVolumeRecycler(t *testing.T) {
testClient
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
s
.
URL
,
GroupVersion
:
testapi
.
Default
.
GroupVersion
()})
host
:=
volume
.
NewFakeVolumeHost
(
"/tmp/fake"
,
nil
,
nil
)
plugins
:=
[]
volume
.
VolumePlugin
{
&
volume
.
FakeVolumePlugin
{
"plugin-name"
,
host
,
volume
.
VolumeConfig
{}}}
plugins
:=
[]
volume
.
VolumePlugin
{
&
volume
.
FakeVolumePlugin
{
"plugin-name"
,
host
,
volume
.
VolumeConfig
{}
,
volume
.
VolumeOptions
{}
}}
cloud
:=
&
fake_cloud
.
FakeCloud
{}
binder
:=
persistentvolumecontroller
.
NewPersistentVolumeClaimBinder
(
binderClient
,
10
*
time
.
Second
)
...
...
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