nomad: allow testing if plan queue enabled

This commit is contained in:
Armon Dadgar
2015-08-05 16:30:57 -07:00
parent 1d9fa04ece
commit 4f3276bcde
2 changed files with 13 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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)