diff --git a/api/autopilot.go b/api/autopilot.go index 7f2ee7b08..1dca769a1 100644 --- a/api/autopilot.go +++ b/api/autopilot.go @@ -86,6 +86,7 @@ type ( // AutopilotStateResponse is the response type for the /autopilot/state // endpoint. AutopilotStateResponse struct { + ID string `json:"id"` Configured bool `json:"configured"` Migrating bool `json:"migrating"` MigratingLastStart TimeRFC3339 `json:"migratingLastStart"` diff --git a/autopilot/autopilot.go b/autopilot/autopilot.go index 12f4c809e..7dbfdd2da 100644 --- a/autopilot/autopilot.go +++ b/autopilot/autopilot.go @@ -703,6 +703,7 @@ func (ap *Autopilot) stateHandlerGET(jc jape.Context) { } jc.Encode(api.AutopilotStateResponse{ + ID: ap.id, Configured: err == nil, Migrating: migrating, MigratingLastStart: api.TimeRFC3339(mLastStart), diff --git a/internal/test/e2e/cluster_test.go b/internal/test/e2e/cluster_test.go index 1b51b2fc1..b17dd7609 100644 --- a/internal/test/e2e/cluster_test.go +++ b/internal/test/e2e/cluster_test.go @@ -358,19 +358,17 @@ func TestNewTestCluster(t *testing.T) { // Fetch the autopilot state state, err := cluster.Autopilot.State() tt.OK(err) - if time.Time(state.StartTime).IsZero() { + if state.ID != api.DefaultAutopilotID { + t.Fatal("autopilot should have default id", state.ID) + } else if time.Time(state.StartTime).IsZero() { t.Fatal("autopilot should have start time") - } - if time.Time(state.MigratingLastStart).IsZero() { + } else if time.Time(state.MigratingLastStart).IsZero() { t.Fatal("autopilot should have completed a migration") - } - if time.Time(state.ScanningLastStart).IsZero() { + } else if time.Time(state.ScanningLastStart).IsZero() { t.Fatal("autopilot should have completed a scan") - } - if state.UptimeMS == 0 { + } else if state.UptimeMS == 0 { t.Fatal("uptime should be set") - } - if !state.Configured { + } else if !state.Configured { t.Fatal("autopilot should be configured") } }