MCPcopy Create free account
hub / github.com/coder/coder / Run

Method Run

scaletest/harness/run.go:98–126  ·  view source on GitHub ↗

Run executes the Run function with a self-managed log writer, panic handler, error recording and duration recording. The test error is returned.

(ctx context.Context)

Source from the content-addressed store, hash-verified

96// Run executes the Run function with a self-managed log writer, panic handler,
97// error recording and duration recording. The test error is returned.
98func (r *TestRun) Run(ctx context.Context) (err error) {
99 r.logs = &syncBuffer{
100 buf: new(bytes.Buffer),
101 }
102 r.done = make(chan struct{})
103 defer close(r.done)
104
105 r.started = time.Now()
106 defer func() {
107 r.duration = time.Since(r.started)
108 r.err = err
109 c, ok := r.runner.(Collectable)
110 if !ok {
111 return
112 }
113 r.metrics = c.GetMetrics()
114 }()
115 defer func() {
116 e := recover()
117 if e != nil {
118 err = xerrors.Errorf("panic: %v", e)
119 }
120 }()
121
122 err = r.runner.Run(ctx, r.id, r.logs)
123
124 //nolint:revive // we use named returns because we mutate it in a defer
125 return
126}
127
128func (r *TestRun) Cleanup(ctx context.Context) (err error) {
129 c, ok := r.runner.(Cleanable)

Callers 1

Test_TestRunFunction · 0.95

Calls 3

GetMetricsMethod · 0.65
RunMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

Test_TestRunFunction · 0.76