Parse test for spread

This commit is contained in:
Preetha Appan
2018-07-18 12:28:26 -05:00
parent ed4ed16b5d
commit 0e2fefad36
2 changed files with 63 additions and 0 deletions

View File

@@ -55,6 +55,23 @@ func TestParse(t *testing.T) {
},
},
Spreads: []*api.Spread{
{
Attribute: "${meta.rack}",
Weight: 100,
SpreadTarget: []*api.SpreadTarget{
{
Value: "r1",
Percent: 40,
},
{
Value: "r2",
Percent: 60,
},
},
},
},
Update: &api.UpdateStrategy{
Stagger: helper.TimeToPtr(60 * time.Second),
MaxParallel: helper.IntToPtr(2),
@@ -112,6 +129,26 @@ func TestParse(t *testing.T) {
Delay: helper.TimeToPtr(15 * time.Second),
Mode: helper.StringToPtr("delay"),
},
Spreads: []*api.Spread{
{
Attribute: "${node.datacenter}",
Weight: 50,
SpreadTarget: []*api.SpreadTarget{
{
Value: "dc1",
Percent: 50,
},
{
Value: "dc2",
Percent: 25,
},
{
Value: "dc3",
Percent: 25,
},
},
},
},
ReschedulePolicy: &api.ReschedulePolicy{
Interval: helper.TimeToPtr(12 * time.Hour),
Attempts: helper.IntToPtr(5),

View File

@@ -23,6 +23,17 @@ job "binstore-storagelocker" {
weight = 50
}
spread {
attribute = "${meta.rack}"
weight = 100
target "r1" {
percent = 40
}
target "r2" {
percent = 60
}
}
update {
stagger = "60s"
max_parallel = 2
@@ -89,6 +100,21 @@ job "binstore-storagelocker" {
operator = "="
weight = 100
}
spread {
attribute = "${node.datacenter}"
weight = 50
target "dc1" {
percent = 50
}
target "dc2" {
percent = 25
}
target "dc3" {
percent = 25
}
}
task "binstore" {
driver = "docker"