33-behavior (gen_fsm ).
44
55% % API
6- -export ([start_link /6 ,
6+ -export ([start_link /5 ,
77 send_event /1 ,
88 stop /0 ]).
99
2828 running_tests = [] :: [atom ()],
2929 waiting_tests = [] :: [atom ()],
3030 notify_pid :: pid (),
31- backend :: atom (),
3231 upgrade_list :: [string ()],
3332 test_properties :: [proplists :proplist ()],
3433 runner_pids = [] :: [pid ()],
4241% %%===================================================================
4342
4443% % @doc Start the test executor
45- -spec start_link (atom (), atom (), string (), string (), [string ()], pid ()) -> {ok , pid ()} | ignore | {error , term ()}.
46- start_link (Tests , Backend , LogDir , ReportInfo , UpgradeList , NotifyPid ) ->
47- Args = [Tests , Backend , LogDir , ReportInfo , UpgradeList , NotifyPid ],
44+ -spec start_link (atom (), string (), string (), [string ()], pid ()) -> {ok , pid ()} | ignore | {error , term ()}.
45+ start_link (Tests , LogDir , ReportInfo , UpgradeList , NotifyPid ) ->
46+ Args = [Tests , LogDir , ReportInfo , UpgradeList , NotifyPid ],
4847 gen_fsm :start_link ({local , ? MODULE }, ? MODULE , Args , []).
4948
5049send_event (Msg ) ->
@@ -59,19 +58,14 @@ stop() ->
5958% %% gen_fsm callbacks
6059% %%===================================================================
6160
62- init ([Tests , Backend , LogDir , ReportInfo , UpgradeList , NotifyPid ]) ->
61+ init ([Tests , LogDir , ReportInfo , UpgradeList , NotifyPid ]) ->
6362 % % TODO Change the default when parallel execution support is implemented -jsb
6463 ExecutionMode = rt_config :get (rt_execution_mode , serial ),
6564
66- % % TODO: Remove after all tests ported 2.0 -- workaround to support
67- % % backend command line argument fo v1 cluster provisioning -jsb
68- rt_config :set (rt_backend , Backend ),
69-
7065 ContinueOnFail = rt_config :get (continue_on_fail ),
7166
7267 lager :notice (" Starting the Riak Test executor in ~p execution mode" , [ExecutionMode ]),
7368 State = # state {pending_tests = Tests ,
74- backend = Backend ,
7569 log_dir = LogDir ,
7670 report_info = ReportInfo ,
7771 upgrade_list = UpgradeList ,
@@ -165,34 +159,34 @@ launch_test({nodes, Nodes, NodeMap}, State) ->
165159 % % Spawn a test runner for the head of pending. If pending is now
166160 % % empty transition to `wait_for_completion'; otherwise,
167161 % % transition to `request_nodes'.
168- # state {pending_tests = [NextTest | RestPending ],
162+ # state {pending_tests = [NextTestPlan | RestPending ],
169163 execution_mode = ExecutionMode ,
170- backend = Backend ,
171164 test_properties = PropertiesList ,
172165 runner_pids = Pids ,
173166 running_tests = Running ,
174167 continue_on_fail = ContinueOnFail } = State ,
175- lager :debug (" Executing test ~p in mode ~p " , [NextTest , ExecutionMode ]),
176- {NextTest , TestProps } = lists :keyfind (NextTest , 1 , PropertiesList ),
168+ NextTestModule = rt_test_plan :get_module (NextTestPlan ),
169+ lager :debug (" Executing test ~p in mode ~p " , [NextTestModule , ExecutionMode ]),
170+ {NextTestPlan , TestProps } = lists :keyfind (NextTestPlan , 1 , PropertiesList ),
177171 UpdTestProps = rt_properties :set ([{node_map , NodeMap }, {node_ids , Nodes }],
178172 TestProps ),
179- {RunnerPids , RunningTests } = run_test (ExecutionMode , NextTest , Backend , UpdTestProps ,
173+ {RunnerPids , RunningTests } = run_test (ExecutionMode , NextTestPlan , UpdTestProps ,
180174 Pids , Running , ContinueOnFail ),
181175 UpdState = State # state {pending_tests = RestPending ,
182176 execution_mode = ExecutionMode ,
183177 runner_pids = RunnerPids ,
184178 running_tests = RunningTests },
185179
186180 launch_test_transition (UpdState );
187- launch_test ({test_complete , Test , Pid , Results , Duration }, State ) ->
181+ launch_test ({test_complete , TestPlan , Pid , Results , Duration }, State ) ->
188182 # state {pending_tests = Pending ,
189183 waiting_tests = Waiting ,
190184 running_tests = Running ,
191185 runner_pids = Pids ,
192186 execution_mode = ExecutionMode } = State ,
193187 % % Report results
194- report_results (Test , Results , Duration , State ),
195- UpdState = State # state {running_tests = lists :delete (Test , Running ),
188+ report_results (TestPlan , Results , Duration , State ),
189+ UpdState = State # state {running_tests = lists :delete (TestPlan , Running ),
196190 runner_pids = lists :delete (Pid , Pids ),
197191 pending_tests = Pending ++ Waiting ,
198192 waiting_tests = [],
@@ -202,26 +196,26 @@ launch_test(Event, State) ->
202196 lager :error (" Unknown event ~p with state ~p ." , [Event , State ]),
203197 ok .
204198
205- maybe_reserve_nodes (NextTest , TestProps ) ->
199+ maybe_reserve_nodes (NextTestPlan , TestProps ) ->
206200 VersionsToTest = versions_to_test (TestProps ),
207- maybe_reserve_nodes (erlang :function_exported (NextTest , confirm , 1 ),
208- NextTest , VersionsToTest , TestProps ).
201+ maybe_reserve_nodes (erlang :function_exported (rt_test_plan : get_module ( NextTestPlan ) , confirm , 1 ),
202+ NextTestPlan , VersionsToTest , TestProps ).
209203
210204maybe_reserve_nodes (true , NextTest , VersionsToTest , TestProps ) ->
211205 NodeCount = rt_properties :get (node_count , TestProps ),
212206
213207 % % Send async request to node manager
214- lager :notice (" Requesting ~p nodes for the next test, ~p " , [NodeCount , NextTest ]),
208+ lager :notice (" Requesting ~p nodes for the next test, ~p " , [NodeCount , rt_test_plan : get_module ( NextTest ) ]),
215209 node_manager :reserve_nodes (NodeCount ,
216210 VersionsToTest ,
217211 reservation_notify_fun ());
218212maybe_reserve_nodes (false , NextTest , VersionsToTest , _TestProps ) ->
219- lager :warning (" ~p is an old style test that requires conversion." , [NextTest ]),
213+ lager :warning (" ~p is an old style test that requires conversion." , [rt_test_plan : get_module ( NextTest ) ]),
220214 node_manager :reserve_nodes (0 , VersionsToTest , reservation_notify_fun ()),
221215 ok .
222216
223217wait_for_completion ({test_complete , Test , Pid , Results , Duration }, State ) ->
224- lager :debug (" Test ~p complete" , [Test ]),
218+ lager :debug (" Test ~p complete" , [rt_test_plan : get_module ( Test ) ]),
225219 # state {pending_tests = Pending ,
226220 waiting_tests = Waiting ,
227221 running_tests = Running ,
@@ -256,8 +250,8 @@ wait_for_completion(_Event, _From, _State) ->
256250% %% Internal functions
257251% %%===================================================================
258252
259- report_results (Test , Results , Duration , # state {notify_pid = NotifyPid }) ->
260- NotifyPid ! {self (), {test_result , {Test , Results , Duration }}},
253+ report_results (TestPlan , Results , Duration , # state {notify_pid = NotifyPid }) ->
254+ NotifyPid ! {self (), {test_result , {TestPlan , Results , Duration }}},
261255 ok .
262256
263257report_done (# state {notify_pid = NotifyPid }) ->
@@ -276,7 +270,8 @@ wait_for_completion_transition(_Result, State) ->
276270
277271launch_test_transition (State = # state {pending_tests = PendingTests ,
278272 execution_mode = ExecutionMode }) when PendingTests == [] orelse ExecutionMode == serial ->
279- lager :debug (" Waiting for completion: execution mode ~p with pending tests ~p " , [ExecutionMode , PendingTests ]),
273+ PendingModules = [rt_test_plan :get_module (Test ) || Test <- PendingTests ],
274+ lager :debug (" Waiting for completion: execution mode ~p with pending tests ~p " , [ExecutionMode , PendingModules ]),
280275 {next_state , wait_for_completion , State };
281276launch_test_transition (State ) ->
282277 {next_state , request_nodes , State , 0 }.
@@ -293,13 +288,13 @@ test_properties(Tests, OverriddenProps) ->
293288 lists :foldl (test_property_fun (OverriddenProps ), [], Tests ).
294289
295290test_property_fun (OverrideProps ) ->
296- fun (TestModule , Acc ) ->
291+ fun (TestPlan , Acc ) ->
297292 {PropsMod , PropsFun } = riak_test_runner :function_name (properties ,
298- TestModule ,
293+ rt_test_plan : get_module ( TestPlan ) ,
299294 0 ,
300295 rt_cluster ),
301296 Properties = rt_properties :set (OverrideProps , PropsMod :PropsFun ()),
302- [{TestModule , Properties } | Acc ]
297+ [{TestPlan , Properties } | Acc ]
303298 end .
304299
305300versions_to_test (Properties ) ->
@@ -330,11 +325,11 @@ override_props(State) ->
330325 [{upgrade_path , UpgradeList }]
331326 end .
332327
333- -spec run_test (parallel | serial , atom (), atom (), proplists :proplist (), [pid ()], [atom ()], boolean ()) -> {[pid ()], [atom ()]}.
334- run_test (parallel , Test , Backend , Properties , RunningPids , RunningTests , ContinueOnFail ) ->
335- Pid = spawn_link (riak_test_runner , start , [Test , Backend , Properties , ContinueOnFail ]),
336- {[Pid | RunningPids ], [Test | RunningTests ]};
337- run_test (serial , Test , Backend , Properties , RunningPids , RunningTests , ContinueOnFail ) ->
338- riak_test_runner :start (Test , Backend , Properties , ContinueOnFail ),
328+ -spec run_test (parallel | serial , atom (), proplists :proplist (), [pid ()], [atom ()], boolean ()) -> {[pid ()], [atom ()]}.
329+ run_test (parallel , TestPlan , Properties , RunningPids , RunningTests , ContinueOnFail ) ->
330+ Pid = spawn_link (riak_test_runner , start , [TestPlan , Properties , ContinueOnFail ]),
331+ {[Pid | RunningPids ], [TestPlan | RunningTests ]};
332+ run_test (serial , TestPlan , Properties , RunningPids , RunningTests , ContinueOnFail ) ->
333+ riak_test_runner :start (TestPlan , Properties , ContinueOnFail ),
339334 {RunningPids , RunningTests }.
340335
0 commit comments