2017-12-18 21:16:23 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/mitchellh/cli"
|
2018-09-25 20:49:35 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2017-12-18 21:16:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOperator_Autopilot_SetConfig_Implements(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
var _ cli.Command = &OperatorRaftListCommand{}
|
|
|
|
}
|
|
|
|
|
2018-03-11 17:47:37 +00:00
|
|
|
func TestOperatorAutopilotSetConfigCommand(t *testing.T) {
|
2017-12-18 21:16:23 +00:00
|
|
|
t.Parallel()
|
2018-09-25 20:49:35 +00:00
|
|
|
require := require.New(t)
|
2017-12-18 21:16:23 +00:00
|
|
|
s, _, addr := testServer(t, false, nil)
|
|
|
|
defer s.Shutdown()
|
|
|
|
|
2020-10-05 14:07:41 +00:00
|
|
|
ui := cli.NewMockUi()
|
2017-12-18 21:16:23 +00:00
|
|
|
c := &OperatorAutopilotSetCommand{Meta: Meta{Ui: ui}}
|
|
|
|
args := []string{
|
|
|
|
"-address=" + addr,
|
|
|
|
"-cleanup-dead-servers=false",
|
|
|
|
"-max-trailing-logs=99",
|
2020-02-16 21:23:20 +00:00
|
|
|
"-min-quorum=3",
|
2017-12-18 21:16:23 +00:00
|
|
|
"-last-contact-threshold=123ms",
|
|
|
|
"-server-stabilization-time=123ms",
|
2018-09-25 20:49:35 +00:00
|
|
|
"-enable-redundancy-zones=true",
|
|
|
|
"-disable-upgrade-migration=true",
|
|
|
|
"-enable-custom-upgrades=true",
|
2017-12-18 21:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
code := c.Run(args)
|
2018-09-25 20:49:35 +00:00
|
|
|
require.EqualValues(0, code)
|
2017-12-18 21:16:23 +00:00
|
|
|
output := strings.TrimSpace(ui.OutputWriter.String())
|
2018-09-25 20:49:35 +00:00
|
|
|
require.Contains(output, "Configuration updated")
|
2017-12-18 21:16:23 +00:00
|
|
|
|
|
|
|
client, err := c.Client()
|
2018-09-25 20:49:35 +00:00
|
|
|
require.NoError(err)
|
2017-12-18 21:16:23 +00:00
|
|
|
|
2018-02-08 00:47:44 +00:00
|
|
|
conf, _, err := client.Operator().AutopilotGetConfiguration(nil)
|
2018-09-25 20:49:35 +00:00
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
require.False(conf.CleanupDeadServers)
|
|
|
|
require.EqualValues(99, conf.MaxTrailingLogs)
|
2020-02-16 21:23:20 +00:00
|
|
|
require.EqualValues(3, conf.MinQuorum)
|
2018-09-25 20:49:35 +00:00
|
|
|
require.EqualValues(123*time.Millisecond, conf.LastContactThreshold)
|
|
|
|
require.EqualValues(123*time.Millisecond, conf.ServerStabilizationTime)
|
|
|
|
require.True(conf.EnableRedundancyZones)
|
|
|
|
require.True(conf.DisableUpgradeMigration)
|
|
|
|
require.True(conf.EnableCustomUpgrades)
|
2017-12-18 21:16:23 +00:00
|
|
|
}
|