force to validate min and max refresh interval to be positive

Signed-off-by: Sun Hongliang <allen.sun@daocloud.io>
This commit is contained in:
Sun Hongliang 2016-03-13 18:33:04 +08:00
parent 4b2f0fe637
commit b9d0d8927f
2 changed files with 17 additions and 4 deletions

View File

@ -244,8 +244,8 @@ func manage(c *cli.Context) {
refreshMinInterval := c.Duration("engine-refresh-min-interval")
refreshMaxInterval := c.Duration("engine-refresh-max-interval")
if refreshMinInterval == time.Duration(0)*time.Second {
log.Fatal("minimum refresh interval should be a positive number")
if refreshMinInterval <= time.Duration(0)*time.Second {
log.Fatal("min refresh interval should be a positive number")
}
if refreshMaxInterval < refreshMinInterval {
log.Fatal("max refresh interval cannot be less than min refresh interval")

View File

@ -6,9 +6,22 @@ load ../helpers
# minimum refresh interval
run swarm manage --engine-refresh-min-interval "0s" --advertise 127.0.0.1:$SWARM_BASE_PORT 192.168.56.202:4444
[ "$status" -ne 0 ]
[[ "${output}" == *"minimum refresh interval should be a positive number"* ]]
[[ "${output}" == *"min refresh interval should be a positive number"* ]]
# max refresh interval
run swarm manage --engine-refresh-min-interval "-10s" --advertise 127.0.0.1:$SWARM_BASE_PORT 192.168.56.202:4444
[ "$status" -ne 0 ]
[[ "${output}" == *"min refresh interval should be a positive number"* ]]
# maximum refresh interval, minimum refresh interval is 30s as default
run swarm manage --engine-refresh-max-interval "0s" --advertise 127.0.0.1:$SWARM_BASE_PORT 192.168.56.202:4444
[ "$status" -ne 0 ]
[[ "${output}" == *"max refresh interval cannot be less than min refresh interval"* ]]
run swarm manage --engine-refresh-max-interval "-30s" --advertise 127.0.0.1:$SWARM_BASE_PORT 192.168.56.202:4444
[ "$status" -ne 0 ]
[[ "${output}" == *"max refresh interval cannot be less than min refresh interval"* ]]
# max refresh interval is larger than min refresh interval
run swarm manage --engine-refresh-min-interval "30s" -engine-refresh-max-interval "20s" --advertise 127.0.0.1:$SWARM_BASE_PORT 192.168.56.202:4444
[ "$status" -ne 0 ]
[[ "${output}" == *"max refresh interval cannot be less than min refresh interval"* ]]