Skip to content

Commit

Permalink
autopilot: add id to autopilot state response
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Sep 16, 2024
1 parent e84274b commit e9a9339
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions api/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions autopilot/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
16 changes: 7 additions & 9 deletions internal/test/e2e/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down

0 comments on commit e9a9339

Please sign in to comment.