@@ -50,10 +50,10 @@ func (lp *loopArgs) iterationsStored() bool {
50
50
return lp .IterationsEntityID != ""
51
51
}
52
52
53
- func executeTestRunnerOperation (ctx context.Context , operation * operation , loopDone <- chan struct {}) error {
54
- args := operation .Arguments
53
+ func executeTestRunnerOperation (ctx context.Context , op * operation , loopDone <- chan struct {}) error {
54
+ args := op .Arguments
55
55
56
- switch operation .Name {
56
+ switch op .Name {
57
57
case "failPoint" :
58
58
clientID := lookupString (args , "client" )
59
59
client , err := entities (ctx ).client (clientID )
@@ -187,9 +187,34 @@ func executeTestRunnerOperation(ctx context.Context, operation *operation, loopD
187
187
}
188
188
}
189
189
return nil
190
+ case "runOnThread" :
191
+ operationRaw , err := args .LookupErr ("operation" )
192
+ if err != nil {
193
+ return fmt .Errorf ("'operation' argument not found in runOnThread operation" )
194
+ }
195
+ threadOp := new (operation )
196
+ if err := operationRaw .Unmarshal (threadOp ); err != nil {
197
+ return fmt .Errorf ("error unmarshaling 'operation' argument: %v" , err )
198
+ }
199
+ thread := lookupString (args , "thread" )
200
+ routine , ok := entities (ctx ).routinesMap .Load (thread )
201
+ if ! ok {
202
+ return fmt .Errorf ("run on unknown thread: %s" , thread )
203
+ }
204
+ routine .(* backgroundRoutine ).addTask (threadOp .Name , func () error {
205
+ return threadOp .execute (ctx , loopDone )
206
+ })
207
+ return nil
208
+ case "waitForThread" :
209
+ thread := lookupString (args , "thread" )
210
+ routine , ok := entities (ctx ).routinesMap .Load (thread )
211
+ if ! ok {
212
+ return fmt .Errorf ("wait for unknown thread: %s" , thread )
213
+ }
214
+ return routine .(* backgroundRoutine ).stop ()
190
215
case "waitForEvent" :
191
216
var wfeArgs waitForEventArguments
192
- if err := bson .Unmarshal (operation .Arguments , & wfeArgs ); err != nil {
217
+ if err := bson .Unmarshal (op .Arguments , & wfeArgs ); err != nil {
193
218
return fmt .Errorf ("error unmarshalling event to waitForEventArguments: %v" , err )
194
219
}
195
220
@@ -198,7 +223,7 @@ func executeTestRunnerOperation(ctx context.Context, operation *operation, loopD
198
223
199
224
return waitForEvent (wfeCtx , wfeArgs )
200
225
default :
201
- return fmt .Errorf ("unrecognized testRunner operation %q" , operation .Name )
226
+ return fmt .Errorf ("unrecognized testRunner operation %q" , op .Name )
202
227
}
203
228
}
204
229
0 commit comments