2017-12-18 21:16:23 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAutopilotConfig_Merge(t *testing.T) {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|