Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
b6505c23
Unverified
Commit
b6505c23
authored
4 years ago
by
James Rasell
Browse files
Options
Download
Email Patches
Plain Diff
volumewatcher: fix test data race.
parent
ff2e2c11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/volumewatcher/volumes_watcher_test.go
+14
-2
nomad/volumewatcher/volumes_watcher_test.go
with
14 additions
and
2 deletions
+14
-2
nomad/volumewatcher/volumes_watcher_test.go
+
14
-
2
View file @
b6505c23
...
...
@@ -43,10 +43,12 @@ func TestVolumeWatch_EnableDisable(t *testing.T) {
err
=
srv
.
State
()
.
CSIVolumeClaim
(
index
,
vol
.
Namespace
,
vol
.
ID
,
claim
)
require
.
NoError
(
err
)
require
.
Eventually
(
func
()
bool
{
watcher
.
wlock
.
RLock
()
defer
watcher
.
wlock
.
RUnlock
()
return
1
==
len
(
watcher
.
watchers
)
},
time
.
Second
,
10
*
time
.
Millisecond
)
watcher
.
SetEnabled
(
false
,
srv
.
State
()
)
watcher
.
SetEnabled
(
false
,
nil
)
require
.
Equal
(
0
,
len
(
watcher
.
watchers
))
}
...
...
@@ -77,16 +79,20 @@ func TestVolumeWatch_Checkpoint(t *testing.T) {
// we should get or start up a watcher when we get an update for
// the volume from the state store
require
.
Eventually
(
func
()
bool
{
watcher
.
wlock
.
RLock
()
defer
watcher
.
wlock
.
RUnlock
()
return
1
==
len
(
watcher
.
watchers
)
},
time
.
Second
,
10
*
time
.
Millisecond
)
// step-down (this is sync, but step-up is async)
watcher
.
SetEnabled
(
false
,
srv
.
State
()
)
watcher
.
SetEnabled
(
false
,
nil
)
require
.
Equal
(
0
,
len
(
watcher
.
watchers
))
// step-up again
watcher
.
SetEnabled
(
true
,
srv
.
State
())
require
.
Eventually
(
func
()
bool
{
watcher
.
wlock
.
RLock
()
defer
watcher
.
wlock
.
RUnlock
()
return
1
==
len
(
watcher
.
watchers
)
&&
!
watcher
.
watchers
[
vol
.
ID
+
vol
.
Namespace
]
.
isRunning
()
},
time
.
Second
,
10
*
time
.
Millisecond
)
...
...
@@ -128,6 +134,8 @@ func TestVolumeWatch_StartStop(t *testing.T) {
// assert we get a watcher; there are no claims so it should immediately stop
require
.
Eventually
(
func
()
bool
{
watcher
.
wlock
.
RLock
()
defer
watcher
.
wlock
.
RUnlock
()
return
1
==
len
(
watcher
.
watchers
)
&&
!
watcher
.
watchers
[
vol
.
ID
+
vol
.
Namespace
]
.
isRunning
()
},
time
.
Second
*
2
,
10
*
time
.
Millisecond
)
...
...
@@ -177,6 +185,8 @@ func TestVolumeWatch_StartStop(t *testing.T) {
},
time
.
Second
*
2
,
10
*
time
.
Millisecond
)
require
.
Eventually
(
func
()
bool
{
watcher
.
wlock
.
RLock
()
defer
watcher
.
wlock
.
RUnlock
()
return
!
watcher
.
watchers
[
vol
.
ID
+
vol
.
Namespace
]
.
isRunning
()
},
time
.
Second
*
5
,
10
*
time
.
Millisecond
)
}
...
...
@@ -209,6 +219,8 @@ func TestVolumeWatch_RegisterDeregister(t *testing.T) {
// watcher should be started but immediately stopped
require
.
Eventually
(
func
()
bool
{
watcher
.
wlock
.
RLock
()
defer
watcher
.
wlock
.
RUnlock
()
return
1
==
len
(
watcher
.
watchers
)
},
time
.
Second
,
10
*
time
.
Millisecond
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help