Parsing and API layer for spread stanza

This commit is contained in:
Preetha Appan
2018-07-18 10:53:03 -05:00
parent 72570e0698
commit ed4ed16b5d
9 changed files with 350 additions and 495 deletions

View File

@@ -29,9 +29,13 @@ func TestCompose(t *testing.T) {
})
// Compose a task group
st1 := NewSpreadTarget("dc1", 80)
st2 := NewSpreadTarget("dc2", 20)
grp := NewTaskGroup("grp1", 2).
Constrain(NewConstraint("kernel.name", "=", "linux")).
AddAffinity(NewAffinity("${node.class}", "=", "large", 50)).
AddSpread(NewSpread("${node.datacenter}", 30, []*SpreadTarget{st1, st2})).
SetMeta("foo", "bar").
AddTask(task)
@@ -81,6 +85,22 @@ func TestCompose(t *testing.T) {
Weight: 50,
},
},
Spreads: []*Spread{
{
Attribute: "${node.datacenter}",
Weight: 30,
SpreadTarget: []*SpreadTarget{
{
Value: "dc1",
Percent: 80,
},
{
Value: "dc2",
Percent: 20,
},
},
},
},
Tasks: []*Task{
{
Name: "task1",