2017-12-18 21:16:23 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
"time"
|
2022-03-15 12:42:43 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
2017-12-18 21:16:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAutopilotConfig_Merge(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
|
|
|
|
2017-12-18 21:16:23 +00:00
|
|
|
trueValue, falseValue := true, false
|
|
|
|
|
|
|
|
c1 := &AutopilotConfig{
|
|
|
|
CleanupDeadServers: &falseValue,
|
|
|
|
ServerStabilizationTime: 1 * time.Second,
|
|
|
|
LastContactThreshold: 1 * time.Second,
|
|
|
|
MaxTrailingLogs: 1,
|
2020-02-16 21:23:20 +00:00
|
|
|
MinQuorum: 1,
|
2018-01-30 03:53:34 +00:00
|
|
|
EnableRedundancyZones: &trueValue,
|
2017-12-18 21:16:23 +00:00
|
|
|
DisableUpgradeMigration: &falseValue,
|
2018-01-30 03:53:34 +00:00
|
|
|
EnableCustomUpgrades: &trueValue,
|
2017-12-18 21:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c2 := &AutopilotConfig{
|
|
|
|
CleanupDeadServers: &trueValue,
|
|
|
|
ServerStabilizationTime: 2 * time.Second,
|
|
|
|
LastContactThreshold: 2 * time.Second,
|
|
|
|
MaxTrailingLogs: 2,
|
2020-02-16 21:23:20 +00:00
|
|
|
MinQuorum: 2,
|
2018-01-30 03:53:34 +00:00
|
|
|
EnableRedundancyZones: nil,
|
2017-12-18 21:16:23 +00:00
|
|
|
DisableUpgradeMigration: nil,
|
2018-01-30 03:53:34 +00:00
|
|
|
EnableCustomUpgrades: nil,
|
2017-12-18 21:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
e := &AutopilotConfig{
|
|
|
|
CleanupDeadServers: &trueValue,
|
|
|
|
ServerStabilizationTime: 2 * time.Second,
|
|
|
|
LastContactThreshold: 2 * time.Second,
|
|
|
|
MaxTrailingLogs: 2,
|
2020-02-16 21:23:20 +00:00
|
|
|
MinQuorum: 2,
|
2018-01-30 03:53:34 +00:00
|
|
|
EnableRedundancyZones: &trueValue,
|
2017-12-18 21:16:23 +00:00
|
|
|
DisableUpgradeMigration: &falseValue,
|
2018-01-30 03:53:34 +00:00
|
|
|
EnableCustomUpgrades: &trueValue,
|
2017-12-18 21:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
result := c1.Merge(c2)
|
|
|
|
if !reflect.DeepEqual(result, e) {
|
|
|
|
t.Fatalf("bad:\n%#v\n%#v", result, e)
|
|
|
|
}
|
|
|
|
}
|