Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
68c1454c
Commit
68c1454c
authored
5 years ago
by
Danielle Lancashire
Browse files
Options
Download
Email Patches
Plain Diff
evalbroker: test for no enqueue on disabled
parent
c67fb621
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/eval_broker_test.go
+58
-0
nomad/eval_broker_test.go
with
58 additions
and
0 deletions
+58
-0
nomad/eval_broker_test.go
+
58
-
0
View file @
68c1454c
...
...
@@ -647,6 +647,64 @@ func TestEvalBroker_Enqueue_Disable(t *testing.T) {
}
}
func
TestEvalBroker_Enqueue_Disable_Delay
(
t
*
testing
.
T
)
{
t
.
Parallel
()
b
:=
testBroker
(
t
,
0
)
baseEval
:=
mock
.
Eval
()
b
.
SetEnabled
(
true
)
{
// Enqueue
b
.
Enqueue
(
baseEval
.
Copy
())
delayedEval
:=
baseEval
.
Copy
()
delayedEval
.
Wait
=
30
b
.
Enqueue
(
delayedEval
)
waitEval
:=
baseEval
.
Copy
()
waitEval
.
WaitUntil
=
time
.
Now
()
.
Add
(
30
*
time
.
Second
)
b
.
Enqueue
(
waitEval
)
}
// Flush via SetEnabled
b
.
SetEnabled
(
false
)
{
// Check the stats
stats
:=
b
.
Stats
()
require
.
Equal
(
t
,
0
,
stats
.
TotalReady
,
"Expected ready to be flushed"
)
require
.
Equal
(
t
,
0
,
stats
.
TotalWaiting
,
"Expected waiting to be flushed"
)
require
.
Equal
(
t
,
0
,
stats
.
TotalBlocked
,
"Expected blocked to be flushed"
)
require
.
Equal
(
t
,
0
,
stats
.
TotalUnacked
,
"Expected unacked to be flushed"
)
_
,
ok
:=
stats
.
ByScheduler
[
baseEval
.
Type
]
require
.
False
(
t
,
ok
,
"Expected scheduler to have no stats"
)
}
{
// Enqueue again now we're disabled
b
.
Enqueue
(
baseEval
.
Copy
())
delayedEval
:=
baseEval
.
Copy
()
delayedEval
.
Wait
=
30
*
time
.
Second
b
.
Enqueue
(
delayedEval
)
waitEval
:=
baseEval
.
Copy
()
waitEval
.
WaitUntil
=
time
.
Now
()
.
Add
(
30
*
time
.
Second
)
b
.
Enqueue
(
waitEval
)
}
{
// Check the stats again
stats
:=
b
.
Stats
()
require
.
Equal
(
t
,
0
,
stats
.
TotalReady
,
"Expected ready to be flushed"
)
require
.
Equal
(
t
,
0
,
stats
.
TotalWaiting
,
"Expected waiting to be flushed"
)
require
.
Equal
(
t
,
0
,
stats
.
TotalBlocked
,
"Expected blocked to be flushed"
)
require
.
Equal
(
t
,
0
,
stats
.
TotalUnacked
,
"Expected unacked to be flushed"
)
_
,
ok
:=
stats
.
ByScheduler
[
baseEval
.
Type
]
require
.
False
(
t
,
ok
,
"Expected scheduler to have no stats"
)
}
}
func
TestEvalBroker_Dequeue_Timeout
(
t
*
testing
.
T
)
{
t
.
Parallel
()
b
:=
testBroker
(
t
,
0
)
...
...
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