Skip to content

Commit

Permalink
chore: [#4400]: Updated experiment run status enums and removed hard-…
Browse files Browse the repository at this point in the history
…coded statuses (#4494)

Signed-off-by: Amit Kumar Das <[email protected]>
  • Loading branch information
amityt authored Mar 7, 2024
1 parent dc5c36a commit 207676e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ enum ExperimentRunStatus {
Skipped
Error
Timeout
Terminated
Queued
NA
}

Expand Down
2 changes: 2 additions & 0 deletions chaoscenter/graphql/server/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion chaoscenter/graphql/server/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec

executionData := types.ExecutionData{
Name: workflowManifest.Name,
Phase: "Queued",
Phase: string(model.ExperimentRunStatusQueued),
ExperimentID: workflow.ExperimentID,
}

Expand Down Expand Up @@ -856,7 +856,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
err = c.chaosExperimentRunOperator.CreateExperimentRun(sessionContext, dbChaosExperimentRun.ChaosExperimentRun{
InfraID: workflow.InfraID,
ExperimentID: workflow.ExperimentID,
Phase: "Queued",
Phase: string(model.ExperimentRunStatusQueued),
RevisionID: workflow.Revision[0].RevisionID,
ProjectID: projectID,
Audit: mongodb.Audit{
Expand Down Expand Up @@ -1042,27 +1042,27 @@ func (c *ChaosExperimentRunHandler) GetExperimentRunStats(ctx context.Context, p
return nil, err
}

resMap := map[string]int{
"Completed": 0,
"Stopped": 0,
"Running": 0,
"Terminated": 0,
"Error": 0,
resMap := map[model.ExperimentRunStatus]int{
model.ExperimentRunStatusCompleted: 0,
model.ExperimentRunStatusStopped: 0,
model.ExperimentRunStatusRunning: 0,
model.ExperimentRunStatusTerminated: 0,
model.ExperimentRunStatusError: 0,
}

totalExperimentRuns := 0
for _, phase := range res {
resMap[phase.Id] = phase.Count
resMap[model.ExperimentRunStatus(phase.Id)] = phase.Count
totalExperimentRuns = totalExperimentRuns + phase.Count
}

return &model.GetExperimentRunStatsResponse{
TotalExperimentRuns: totalExperimentRuns,
TotalCompletedExperimentRuns: resMap["Completed"],
TotalTerminatedExperimentRuns: resMap["Terminated"],
TotalRunningExperimentRuns: resMap["Running"],
TotalStoppedExperimentRuns: resMap["Stopped"],
TotalErroredExperimentRuns: resMap["Error"],
TotalCompletedExperimentRuns: resMap[model.ExperimentRunStatusCompleted],
TotalTerminatedExperimentRuns: resMap[model.ExperimentRunStatusTerminated],
TotalRunningExperimentRuns: resMap[model.ExperimentRunStatusRunning],
TotalStoppedExperimentRuns: resMap[model.ExperimentRunStatusStopped],
TotalErroredExperimentRuns: resMap[model.ExperimentRunStatusError],
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *ChaosWorkflowHandler) TerminateChaosWorkflow(ctx context.Context, proje
for _, workflowRun := range workflow.WorkflowRuns {
if workflowRun.WorkflowRunID == *workflowRunID {
workflowRun.Completed = true
workflowRun.Phase = "Terminated"
workflowRun.Phase = string(model.WorkflowRunStatusTerminated)
}
}

Expand Down

0 comments on commit 207676e

Please sign in to comment.