nomad: testing worker acking
This commit is contained in:
parent
c65b2c472b
commit
0cfb67e918
|
@ -17,7 +17,7 @@ func TestWorker_dequeueEvaluation(t *testing.T) {
|
|||
defer s1.Shutdown()
|
||||
testutil.WaitForLeader(t, s1.RPC)
|
||||
|
||||
// Create the register request
|
||||
// Create the evaluation
|
||||
eval1 := mockEval()
|
||||
s1.evalBroker.Enqueue(eval1)
|
||||
|
||||
|
@ -63,3 +63,49 @@ func TestWorker_dequeueEvaluation_shutdown(t *testing.T) {
|
|||
t.Fatalf("bad: %#v", eval)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorker_sendAck(t *testing.T) {
|
||||
s1 := testServer(t, func(c *Config) {
|
||||
c.NumSchedulers = 0
|
||||
c.EnabledSchedulers = []string{structs.JobTypeService}
|
||||
})
|
||||
defer s1.Shutdown()
|
||||
testutil.WaitForLeader(t, s1.RPC)
|
||||
|
||||
// Create the evaluation
|
||||
eval1 := mockEval()
|
||||
s1.evalBroker.Enqueue(eval1)
|
||||
|
||||
// Create a worker
|
||||
w := &Worker{srv: s1, logger: s1.logger}
|
||||
|
||||
// Attempt dequeue
|
||||
eval, _ := w.dequeueEvaluation(10 * time.Millisecond)
|
||||
|
||||
// Check the depth is 0, 1 unacked
|
||||
stats := s1.evalBroker.Stats()
|
||||
if stats.TotalReady != 0 && stats.TotalUnacked != 1 {
|
||||
t.Fatalf("bad: %#v", stats)
|
||||
}
|
||||
|
||||
// Send the Nack
|
||||
w.sendAck(eval.ID, false)
|
||||
|
||||
// Check the depth is 1, nothing unacked
|
||||
stats = s1.evalBroker.Stats()
|
||||
if stats.TotalReady != 1 && stats.TotalUnacked != 0 {
|
||||
t.Fatalf("bad: %#v", stats)
|
||||
}
|
||||
|
||||
// Attempt dequeue
|
||||
eval, _ = w.dequeueEvaluation(10 * time.Millisecond)
|
||||
|
||||
// Send the Ack
|
||||
w.sendAck(eval.ID, true)
|
||||
|
||||
// Check the depth is 0
|
||||
stats = s1.evalBroker.Stats()
|
||||
if stats.TotalReady != 0 && stats.TotalUnacked != 0 {
|
||||
t.Fatalf("bad: %#v", stats)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue