@@ -36,11 +36,19 @@ main(Args) ->
3636 ensure_dir (OutDir ),
3737 lager_setup (OutDir ),
3838
39- {Tests , NonTests } = generate_test_lists (ParsedArgs ),
39+ % % Do we use GiddyUp for this run?
40+ Platform = report_platform (ParsedArgs ),
41+ UseGiddyUp = case Platform of
42+ undefined -> false ;
43+ _ -> true
44+ end ,
45+ start_giddyup (Platform ),
46+ {Tests , NonTests } = generate_test_lists (UseGiddyUp , ParsedArgs ),
4047
4148 ok = prepare (ParsedArgs , Tests , NonTests ),
4249 Results = execute (Tests , OutDir , ParsedArgs ),
43- finalize (Results , ParsedArgs ).
50+ finalize (Results , ParsedArgs ),
51+ stop_giddyup (UseGiddyUp ).
4452
4553% @doc Validate the command-line options
4654parse_args (Args ) ->
@@ -64,14 +72,11 @@ cli_options() ->
6472 {help , $h , " help" , undefined , " Print this usage page" },
6573 {config , $c , " conf" , string , " specifies the project configuration" },
6674 {tests , $t , " tests" , string , " specifies which tests to run" },
67- {suites , $s , " suites" , string , " which suites to run" },
68- {groups , $g , " groups" , string , " specifiy a list of test groups to run" },
6975 {dir , $d , " dir" , string , " run all tests in the specified directory" },
7076 {skip , $x , " skip" , string , " list of tests to skip in a directory" },
7177 {verbose , $v , " verbose" , undefined , " verbose output" },
7278 {outdir , $o , " outdir" , string , " output directory" },
7379 {backend , $b , " backend" , atom , " backend to test [memory | bitcask | eleveldb]" },
74- {upgrade_path , $u , " upgrade-path" , atom , " comma-separated list representing an upgrade path (e.g. riak-1.3.4,riak_ee-1.4.12,riak_ee-2.0.0)" },
7580 {keep , undefined , " keep" , boolean , " do not teardown cluster" },
7681 {continue_on_fail , $n , " continue" , boolean , " continues executing tests on failure" },
7782 {report , $r , " report" , string , " you're reporting an official test run, provide platform info (e.g. ubuntu-1404-64)\n Use 'config' if you want to pull from ~/ .riak_test.config" },
@@ -93,13 +98,13 @@ report_platform(ParsedArgs) ->
9398 end .
9499
95100% % @doc Print help string if it's specified, otherwise parse the arguments
96- generate_test_lists (ParsedArgs ) ->
101+ generate_test_lists (UseGiddyUp , ParsedArgs ) ->
97102 % % Have to load the `riak_test' config prior to assembling the
98103 % % test metadata
99104
100105 TestData = compose_test_data (ParsedArgs ),
101- Backend = proplists :get_value (backend , ParsedArgs , bitcask ),
102- {Tests , NonTests } = wrap_test_in_test_plan (report_platform ( ParsedArgs ), Backend , TestData ),
106+ Backends = [ proplists :get_value (backend , ParsedArgs , bitcask )] ,
107+ {Tests , NonTests } = wrap_test_in_test_plan (UseGiddyUp , Backends , TestData ),
103108 Offset = rt_config :get (offset , undefined ),
104109 Workers = rt_config :get (workers , undefined ),
105110 shuffle_tests (Tests , NonTests , Offset , Workers ).
@@ -168,24 +173,6 @@ execute(TestPlans, OutDir, ParsedArgs) ->
168173 self ()),
169174 wait_for_results (Executor , [], length (TestPlans ), 0 ).
170175
171- % % TestResults = run_tests(Tests, Outdir, Report, HarnessArgs),
172- % % lists:filter(fun results_filter/1, TestResults).
173-
174- % % run_test(Test, Outdir, TestMetaData, Report, HarnessArgs, NumTests) ->
175- % % rt_cover:maybe_start(Test),
176- % % SingleTestResult = riak_test_runner:run(Test, Outdir, TestMetaData, HarnessArgs),
177-
178- % % case NumTests of
179- % % 1 -> keep_them_up;
180- % % _ -> rt_cluster:teardown()
181- % % end,
182-
183- % % TODO: Do this in the test runner
184- % % CoverDir = rt_config:get(cover_output, "coverage"),
185- % % CoverFile = rt_cover:maybe_export_coverage(Test, CoverDir, erlang:phash2(TestMetaData)),
186- % % publish_report(SingleTestResult, CoverFile, Report),
187-
188- % % [{coverdata, CoverFile} | SingleTestResult].
189176
190177% % TODO: Use `TestCount' and `Completed' to display progress output
191178wait_for_results (Executor , TestResults , TestCount , Completed ) ->
@@ -249,9 +236,6 @@ erlang_setup(_ParsedArgs) ->
249236 register (riak_test , self ()),
250237 maybe_add_code_path (" ./ebin" ),
251238
252- % % ibrowse
253- load_and_start (ibrowse ),
254-
255239 % % Sets up extra paths earlier so that tests can be loadable
256240 % % without needing the -d flag.
257241 code :add_paths (rt_config :get (test_paths , [])),
@@ -274,10 +258,6 @@ maybe_add_code_path(Path, true) ->
274258maybe_add_code_path (_ , false ) ->
275259 meh .
276260
277- load_and_start (Application ) ->
278- application :load (Application ),
279- application :start (Application ).
280-
281261ensure_dir (undefined ) ->
282262 ok ;
283263ensure_dir (Dir ) ->
@@ -358,21 +338,18 @@ extract_test_names(Test, {CodePaths, TestNames}) ->
358338% % @doc Determine which tests to run based on command-line argument
359339% % If the platform is defined, consult GiddyUp, otherwise just shovel
360340% % the whole thing into the Planner
361- -spec (load_up_test_planner (string () | undefined , string (), list ()) -> list ()).
362- load_up_test_planner (undefined , Backend , CommandLineTests ) ->
363- [rt_planner :add_test_plan (Name , undefined , Backend , undefined , undefined ) || Name <- CommandLineTests ];
364- % % GiddyUp Flavor
365- load_up_test_planner (Platform , Backend , CommandLineTests ) ->
366- rt_planner :load_from_giddyup (Platform , Backend , CommandLineTests ).
341+ -spec (load_up_test_planner (boolean (), [string ()], list ()) -> list ()).
342+ load_up_test_planner (true , Backends , CommandLineTests ) ->
343+ rt_planner :load_from_giddyup (Backends , CommandLineTests );
344+ load_up_test_planner (_ , Backends , CommandLineTests ) ->
345+ [rt_planner :add_test_plan (Name , undefined , Backends , undefined , undefined ) || Name <- CommandLineTests ].
367346
368347% % @doc Push all of the test into the Planner for now and wrap them in an `rt_test_plan'
369348% % TODO: Let the Planner do the work, not the riak_test_executor
370- -spec (wrap_test_in_test_plan (string (), string (), [atom ()]) -> {list (), list ()}).
371- wrap_test_in_test_plan (Platform , Backend , CommandLineTests ) ->
372- % % ibrowse neededfor GiddyUp
373- load_and_start (ibrowse ),
349+ -spec (wrap_test_in_test_plan (boolean (), [string ()], [atom ()]) -> {list (), list ()}).
350+ wrap_test_in_test_plan (UseGiddyUp , Backends , CommandLineTests ) ->
374351 {ok , _Pid } = rt_planner :start_link (),
375- load_up_test_planner (Platform , Backend , CommandLineTests ),
352+ load_up_test_planner (UseGiddyUp , Backends , CommandLineTests ),
376353 TestPlans = [rt_planner :fetch_test_plan () || _ <- lists :seq (1 , rt_planner :number_of_plans ())],
377354 NonRunnableTestPlans = [rt_planner :fetch_test_non_runnable_plan () || _ <- lists :seq (1 , rt_planner :number_of_non_runable_plans ())],
378355 rt_planner :stop (),
@@ -407,26 +384,6 @@ match_group_attributes(Attributes, Groups) ->
407384 || Group <- Groups , TestType <- TestTypes ])
408385 end .
409386
410- % % run_tests(Tests, Outdir, Report, HarnessArgs) ->
411- % % Need properties for tests prior to getting here Need server to
412- % % manage the aquisition of nodes and to handle comparison of test
413- % % `node_count' property with resources available. Also handle
414- % % notification of test completion. Hmm, maybe test execution
415- % % should be handled by a `gen_fsm' at this point to distinguish
416- % % the case when there are tests left to be tried with available
417- % % resources versus all have been tried or resources are
418- % % exhausted.
419-
420- % % [run_test(Test,
421- % % Outdir,
422- % % TestMetaData,
423- % % Report,
424- % % HarnessArgs,
425- % % TestCount) ||
426- % % {Test, TestMetaData} <- Tests],
427-
428-
429-
430387backend_list (Backend ) when is_atom (Backend ) ->
431388 atom_to_list (Backend );
432389backend_list (Backends ) when is_list (Backends ) ->
@@ -493,3 +450,22 @@ so_kill_riak_maybe() ->
493450 io :format (" Leaving Riak Up... " ),
494451 rt :whats_up ()
495452 end .
453+
454+ % % @doc Start the GiddyUp reporting service if the report is defined
455+ start_giddyup (undefined ) ->
456+ ok ;
457+ start_giddyup (Platform ) ->
458+ {ok , _Pid } = giddyup :start_link (Platform ,
459+ rt_config :get_default_version_product (),
460+ rt_config :get_default_version_number (),
461+ rt_config :get_default_version (),
462+ rt_config :get (giddyup_host ),
463+ rt_config :get (giddyup_user ),
464+ rt_config :get (giddyup_password )).
465+
466+ % % @doc Stop the GiddyUp reporting service if the report is defined
467+ stop_giddyup (true ) ->
468+ giddyup :stop ();
469+ stop_giddyup (_ ) ->
470+ ok .
471+
0 commit comments