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
810ad711
Commit
810ad711
authored
Apr 13, 2015
by
Vish Kannan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6763 from swagiaal/improve-gce-pd-test
GCE PD Test: Add explicit check for attach and detach calls
parents
96bcb56f
309fd272
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
gce_pd_test.go
pkg/volume/gce_pd/gce_pd_test.go
+21
-3
No files found.
pkg/volume/gce_pd/gce_pd_test.go
View file @
810ad711
...
@@ -64,7 +64,10 @@ func contains(modes []api.AccessModeType, mode api.AccessModeType) bool {
...
@@ -64,7 +64,10 @@ func contains(modes []api.AccessModeType, mode api.AccessModeType) bool {
return
false
return
false
}
}
type
fakePDManager
struct
{}
type
fakePDManager
struct
{
attachCalled
bool
detachCalled
bool
}
// TODO(jonesdl) To fully test this, we could create a loopback device
// TODO(jonesdl) To fully test this, we could create a loopback device
// and mount that instead.
// and mount that instead.
...
@@ -74,6 +77,10 @@ func (fake *fakePDManager) AttachAndMountDisk(pd *gcePersistentDisk, globalPDPat
...
@@ -74,6 +77,10 @@ func (fake *fakePDManager) AttachAndMountDisk(pd *gcePersistentDisk, globalPDPat
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
fake
.
attachCalled
=
true
// Simulate the global mount so that the fakeMounter returns the
// expected number of mounts for the attached disk.
pd
.
mounter
.
Mount
(
globalPath
,
globalPath
,
pd
.
fsType
,
0
,
""
)
return
nil
return
nil
}
}
...
@@ -83,6 +90,7 @@ func (fake *fakePDManager) DetachDisk(pd *gcePersistentDisk) error {
...
@@ -83,6 +90,7 @@ func (fake *fakePDManager) DetachDisk(pd *gcePersistentDisk) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
fake
.
detachCalled
=
true
return
nil
return
nil
}
}
...
@@ -103,7 +111,9 @@ func TestPlugin(t *testing.T) {
...
@@ -103,7 +111,9 @@ func TestPlugin(t *testing.T) {
},
},
},
},
}
}
builder
,
err
:=
plug
.
(
*
gcePersistentDiskPlugin
)
.
newBuilderInternal
(
spec
,
types
.
UID
(
"poduid"
),
&
fakePDManager
{},
&
mount
.
FakeMounter
{})
fakeManager
:=
&
fakePDManager
{}
fakeMounter
:=
&
mount
.
FakeMounter
{}
builder
,
err
:=
plug
.
(
*
gcePersistentDiskPlugin
)
.
newBuilderInternal
(
spec
,
types
.
UID
(
"poduid"
),
fakeManager
,
fakeMounter
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -133,8 +143,12 @@ func TestPlugin(t *testing.T) {
...
@@ -133,8 +143,12 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"SetUp() failed: %v"
,
err
)
t
.
Errorf
(
"SetUp() failed: %v"
,
err
)
}
}
}
}
if
!
fakeManager
.
attachCalled
{
t
.
Errorf
(
"Attach watch not called"
)
}
cleaner
,
err
:=
plug
.
(
*
gcePersistentDiskPlugin
)
.
newCleanerInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
&
fakePDManager
{},
&
mount
.
FakeMounter
{})
fakeManager
=
&
fakePDManager
{}
cleaner
,
err
:=
plug
.
(
*
gcePersistentDiskPlugin
)
.
newCleanerInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
fakeManager
,
fakeMounter
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Cleaner: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Cleaner: %v"
,
err
)
}
}
...
@@ -150,6 +164,10 @@ func TestPlugin(t *testing.T) {
...
@@ -150,6 +164,10 @@ func TestPlugin(t *testing.T) {
}
else
if
!
os
.
IsNotExist
(
err
)
{
}
else
if
!
os
.
IsNotExist
(
err
)
{
t
.
Errorf
(
"SetUp() failed: %v"
,
err
)
t
.
Errorf
(
"SetUp() failed: %v"
,
err
)
}
}
if
!
fakeManager
.
detachCalled
{
t
.
Errorf
(
"Detach watch not called"
)
}
}
}
func
TestPluginLegacy
(
t
*
testing
.
T
)
{
func
TestPluginLegacy
(
t
*
testing
.
T
)
{
...
...
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