mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
nomad: method to test if outstanding evaluation
This commit is contained in:
@@ -281,6 +281,14 @@ func (b *EvalBroker) waitForSchedulers(schedulers []string, timeoutCh <-chan tim
|
||||
}
|
||||
}
|
||||
|
||||
// Outstanding checks if an EvalID has been delivered but not acknowledged
|
||||
func (b *EvalBroker) Outstanding(evalID string) bool {
|
||||
b.l.RLock()
|
||||
defer b.l.RUnlock()
|
||||
_, ok := b.unack[evalID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Ack is used to positively acknowledge handling an evaluation
|
||||
func (b *EvalBroker) Ack(evalID string) error {
|
||||
b.l.Lock()
|
||||
|
||||
@@ -66,6 +66,10 @@ func TestEvalBroker_Enqueue_Dequeue_Nack_Ack(t *testing.T) {
|
||||
t.Fatalf("bad : %#v", out)
|
||||
}
|
||||
|
||||
if !b.Outstanding(out.ID) {
|
||||
t.Fatalf("should be outstanding")
|
||||
}
|
||||
|
||||
// Check the stats
|
||||
stats = b.Stats()
|
||||
if stats.TotalReady != 0 {
|
||||
@@ -87,6 +91,10 @@ func TestEvalBroker_Enqueue_Dequeue_Nack_Ack(t *testing.T) {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if b.Outstanding(out.ID) {
|
||||
t.Fatalf("should not be outstanding")
|
||||
}
|
||||
|
||||
// Check the stats
|
||||
stats = b.Stats()
|
||||
if stats.TotalReady != 1 {
|
||||
@@ -111,12 +119,20 @@ func TestEvalBroker_Enqueue_Dequeue_Nack_Ack(t *testing.T) {
|
||||
t.Fatalf("bad : %#v", out2)
|
||||
}
|
||||
|
||||
if !b.Outstanding(out.ID) {
|
||||
t.Fatalf("should be outstanding")
|
||||
}
|
||||
|
||||
// Ack finally
|
||||
err = b.Ack(eval.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if b.Outstanding(out.ID) {
|
||||
t.Fatalf("should not be outstanding")
|
||||
}
|
||||
|
||||
// Check the stats
|
||||
stats = b.Stats()
|
||||
if stats.TotalReady != 0 {
|
||||
|
||||
Reference in New Issue
Block a user