(ctx context.Context, session *chaos_mesh.FaultSession)
| 187 | } |
| 188 | |
| 189 | func waitForFaultRecovery(ctx context.Context, session *chaos_mesh.FaultSession) error { |
| 190 | for { |
| 191 | status, err := session.GetStatus(ctx) |
| 192 | if err != nil { |
| 193 | return err |
| 194 | } |
| 195 | |
| 196 | switch status { |
| 197 | case chaos_mesh.InProgress: |
| 198 | log.Infof("The fault is still finishing up. Sleeping for 10s") |
| 199 | time.Sleep(10 * time.Second) |
| 200 | case chaos_mesh.Stopping: |
| 201 | log.Infof("The fault is being stopped. Sleeping for 10s") |
| 202 | time.Sleep(10 * time.Second) |
| 203 | case chaos_mesh.Error: |
| 204 | log.Errorf("there was an error returned by chaos-mesh") |
| 205 | return errors.New("there was an unspecified error returned by chaos-mesh. inspect the fault resource") |
| 206 | case chaos_mesh.Completed: |
| 207 | log.Infof("The fault terminated successfully!") |
| 208 | return nil |
| 209 | default: |
| 210 | return stacktrace.NewError("unknown chaos session state %s", status) |
| 211 | } |
| 212 | } |
| 213 | } |
no test coverage detected