2015-08-13 18:33:58 +00:00
|
|
|
package scheduler
|
|
|
|
|
|
|
|
import (
|
2015-08-13 18:54:59 +00:00
|
|
|
"log"
|
2015-08-13 18:33:58 +00:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/nomad/state"
|
2015-08-13 18:54:59 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
2015-08-13 18:33:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func testContext(t *testing.T) (*state.StateStore, *EvalContext) {
|
|
|
|
state, err := state.NewStateStore(os.Stderr)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
2015-08-13 20:08:15 +00:00
|
|
|
plan := &structs.Plan{
|
|
|
|
NodeEvict: make(map[string][]string),
|
|
|
|
NodeAllocation: make(map[string][]*structs.Allocation),
|
|
|
|
}
|
2015-08-13 18:33:58 +00:00
|
|
|
|
2015-08-13 18:54:59 +00:00
|
|
|
logger := log.New(os.Stderr, "", log.LstdFlags)
|
|
|
|
|
|
|
|
ctx := NewEvalContext(state, plan, logger)
|
2015-08-13 18:33:58 +00:00
|
|
|
return state, ctx
|
|
|
|
}
|