MCPcopy Create free account
hub / github.com/crytic/attacknet / RunTestPlan

Method RunTestPlan

pkg/test_executor/executor.go:26–68  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

24}
25
26func (te *TestExecutor) RunTestPlan(ctx context.Context) error {
27 if te.planCompleted {
28 return stacktrace.NewError("test executor %s has already been run", te.testName)
29 }
30 for i, genericStep := range te.planSteps {
31 marshalledSpec, err := yaml.Marshal(genericStep.Spec)
32 if err != nil {
33 return stacktrace.Propagate(err, "could not marshal plan step %s", genericStep.Spec)
34 }
35 log.Infof("Running test step (%d/%d): '%s'", i+1, len(te.planSteps), genericStep.StepDescription)
36 switch genericStep.StepType {
37 case types.InjectFault:
38 var s PlanStepSingleFault
39 err = yaml.Unmarshal(marshalledSpec, &s)
40 if err != nil {
41 return stacktrace.Propagate(err, "could not unmarshal injectFault step from plan")
42 }
43 err = te.runInjectFaultStep(ctx, s) // check err after switch
44 case types.WaitForFaultCompletion:
45 var s PlanStepWaitForFaultCompletion
46 err = yaml.Unmarshal(marshalledSpec, &s)
47 if err != nil {
48 return stacktrace.Propagate(err, "could not unmarshal waitForFaultCompletion step from plan")
49 }
50 err = te.runWaitForFaultCompletion(ctx, s)
51 case types.WaitForDuration:
52 var s PlanStepWait
53 err = yaml.Unmarshal(marshalledSpec, &s)
54 if err != nil {
55 return stacktrace.Propagate(err, "could not unmarshal waitForDuration step from plan")
56 }
57 err = te.runWaitForDuration(s)
58 default:
59 err = stacktrace.NewError("Unknown fault step type %s", genericStep.StepType)
60 }
61
62 if err != nil {
63 return err
64 }
65 }
66 te.planCompleted = true
67 return nil
68}
69
70func (te *TestExecutor) GetPodsUnderTest() ([]*chaos_mesh.PodUnderTest, error) {
71 if !te.planCompleted {

Callers 1

StartTestSuiteFunction · 0.80

Calls 3

runInjectFaultStepMethod · 0.95
runWaitForDurationMethod · 0.95

Tested by

no test coverage detected