Skip to content

Commit

Permalink
more hacking ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Feb 9, 2023
1 parent 70f01fc commit 64c3887
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nomad/eval_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ func (b *EvalBroker) Cancelable(batchSize int) []*structs.Evaluation {
b.l.Lock()
defer b.l.Unlock()

fmt.Printf("EvalBroker.Cancelable found %d cancelable\n", len(b.cancelable))
fmt.Printf("EvalBroker.Cancelable(%d) found %d cancelable\n", batchSize, len(b.cancelable))

if batchSize > len(b.cancelable) {
batchSize = len(b.cancelable)
Expand All @@ -881,7 +881,7 @@ func (b *EvalBroker) Cancelable(batchSize int) []*structs.Evaluation {
b.cancelable = b.cancelable[batchSize:]

b.stats.TotalCancelable = len(b.cancelable)
fmt.Printf("EvalBroker.Cancelable returning %d cancelable\n", len(cancelable))
fmt.Printf("EvalBroker.Cancelable(%d) returning %d cancelable\n", batchSize, len(cancelable))
return cancelable
}

Expand Down
25 changes: 25 additions & 0 deletions nomad/eval_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,31 @@ func TestEvalBroker_PendingEvals_MarkForCancel(t *testing.T) {
must.Eq(t, 100, eval.ModifyIndex)
}

func TestEvalBroker_Cancelable(t *testing.T) {
ci.Parallel(t)

b := testBroker(t, time.Minute)

evals := []*structs.Evaluation{}
for i := 0; i < 20; i++ {
eval := mock.Eval()
evals = append(evals, eval)
}
b.cancelable = evals
b.stats.TotalCancelable = len(b.cancelable)

must.Len(t, 20, b.cancelable)
cancelable := b.Cancelable(10)
must.Len(t, 10, cancelable)
must.Len(t, 10, b.cancelable)
must.Eq(t, 10, b.stats.TotalCancelable)

cancelable = b.Cancelable(20)
must.Len(t, 10, cancelable)
must.Len(t, 0, b.cancelable)
must.Eq(t, 0, b.stats.TotalCancelable)
}

// TestEvalBroker_IntegrationTest exercises the eval broker with realistic
// workflows
func TestEvalBroker_IntegrationTest(t *testing.T) {
Expand Down

0 comments on commit 64c3887

Please sign in to comment.