mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 09:55:44 +03:00
nomad: allow testing if plan queue enabled
This commit is contained in:
@@ -73,6 +73,13 @@ func (p *pendingPlan) respond(result *structs.PlanResult, err error) {
|
||||
// priority queue
|
||||
type PendingPlans []*pendingPlan
|
||||
|
||||
// Enabled is used to check if the queue is enabled.
|
||||
func (q *PlanQueue) Enabled() bool {
|
||||
q.l.RLock()
|
||||
defer q.l.RUnlock()
|
||||
return q.enabled
|
||||
}
|
||||
|
||||
// SetEnabled is used to control if the queue is enabled. The queue
|
||||
// should only be enabled on the active leader.
|
||||
func (q *PlanQueue) SetEnabled(enabled bool) {
|
||||
|
||||
@@ -27,7 +27,13 @@ func mockPlanResult() *structs.PlanResult {
|
||||
|
||||
func TestPlanQueue_Enqueue_Dequeue(t *testing.T) {
|
||||
pq := testPlanQueue(t)
|
||||
if pq.Enabled() {
|
||||
t.Fatalf("should not be enabled")
|
||||
}
|
||||
pq.SetEnabled(true)
|
||||
if !pq.Enabled() {
|
||||
t.Fatalf("should be enabled")
|
||||
}
|
||||
|
||||
plan := mockPlan()
|
||||
future, err := pq.Enqueue(plan)
|
||||
|
||||
Reference in New Issue
Block a user