Skip to content

Commit 73569f9

Browse files
Fix tests
1 parent 9eee484 commit 73569f9

File tree

6 files changed

+23
-37
lines changed

6 files changed

+23
-37
lines changed

acceptance_tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ local-tests:
88

99
.PHONY: basic-tests
1010
basic-tests:
11-
./mzb_basic_tests.py -v --process-timeout=1200
1211
./check_default_conf.erl
12+
./mzb_basic_tests.py -v --process-timeout=1200
1313

1414
.PHONY: migrations-tests
1515
migrations-tests:

bin/migrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def migrate(data_dir, jobs):
8282

8383
def benchmarks(data_dir):
8484
for d in os.listdir(data_dir):
85-
if d[0] != '.':
85+
if d[0] != '.' and os.path.isdir(os.path.join(data_dir, d)):
8686
yield d
8787

8888
def apply_migration(script_path, data_dir, jobs):

server/server.config.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
{metric_update_interval_ms, 10000},
4949
{max_bench_num, 1000},
5050
{final_metrics_percentiles, [min,50,90,95,max]},
51-
{gc_sleep, 1000},
51+
{gc_sleep, 10},
5252

5353
% benchmark will crash if ntp time diff in cluster is greater than this value
5454
{ntp_max_timediff_s, undefined}, % in sec but if undefined - run ntp but do not crash in any case

server/src/mzb_api_endpoints.erl

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,29 +143,11 @@ handle(<<"GET">>, <<"/graphs">>, Req) ->
143143
{ok, cowboy_req:reply(302, Headers, <<>>, Req), #{}}
144144
end);
145145

146+
%% obsolete endpoint, to be removed soon
146147
handle(<<"GET">>, <<"/report.json">>, Req) ->
147-
BenchInfo = mzb_api_server:get_info(),
148-
SortedBenchInfo = lists:sort(fun ({IdA, _}, {IdB, _}) ->
149-
IdA >= IdB
150-
end, BenchInfo),
151-
Body = lists:map(
152-
fun({Id, #{status:= Status, config:= Config, start_time:= StartTime, finish_time:= FinishTime}}) ->
153-
ScriptName = case Config of
154-
#{script:= #{name:= SN}} -> SN;
155-
#{script:= SN} -> SN
156-
end,
157-
Duration = case FinishTime of
158-
undefined ->
159-
mzb_api_bench:seconds() - StartTime;
160-
Time when is_number(Time) ->
161-
FinishTime - StartTime
162-
end,
163-
[Id, list_to_binary(iso_8601_fmt(StartTime)), list_to_binary(ScriptName),
164-
Status, Duration];
165-
({Id, #{status:= failed, reason:= {crashed, _}}}) ->
166-
[Id, <<"n/a">>, <<"n/a">>, crashed, 0]
167-
end, SortedBenchInfo),
168-
{ok, reply_json(200, #{data => Body}, Req), #{}};
148+
Filter = fun (I) -> mzb_api_ws_handler:normalize([I]) end,
149+
{_BenchInfo, _, _} = mzb_api_server:get_info(Filter, undefined, undefined, undefined, 1),
150+
{ok, reply_json(200, #{}, Req), #{}};
169151

170152
handle(<<"GET">>, <<"/clusters_info">>, Req) ->
171153
List = mzb_api_cloud:clusters_info(),

server/src/mzb_api_ws_handler.erl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ dispatch_request(#{<<"cmd">> := <<"get_benchset">>} = Cmd, State) ->
234234
{BenchInfos0, Min, _} = mzb_api_server:get_info(Filter, undefined, undefined, undefined, _MaxBenchsetSize = 200),
235235

236236
Sets = lists:map(fun(Chart) ->
237-
Kind = binary_to_list(mzb_bc:maps_get(<<"kind">>, Chart, undefined)),
238-
Metric = binary_to_list(mzb_bc:maps_get(<<"metric">>, Chart, undefined)),
237+
Kind = binary_to_list(mzb_bc:maps_get(<<"kind">>, Chart, <<"undefined">>)),
238+
Metric = binary_to_list(mzb_bc:maps_get(<<"metric">>, Chart, <<"undefined">>)),
239239
Size = list_to_integer(binary_to_list(mzb_bc:maps_get(<<"size">>, Chart, <<"0">>))),
240-
GroupEnv = binary_to_list(mzb_bc:maps_get(<<"group_env">>, Chart, undefined)),
241-
XEnv = binary_to_list(mzb_bc:maps_get(<<"x_env">>, Chart, undefined)),
240+
GroupEnv = binary_to_list(mzb_bc:maps_get(<<"group_env">>, Chart, <<"undefined">>)),
241+
XEnv = binary_to_list(mzb_bc:maps_get(<<"x_env">>, Chart, <<"undefined">>)),
242242
benchset(BenchInfos0, Metric, Kind, Size, GroupEnv, XEnv)
243243
end, mzb_bc:maps_get(<<"charts">>, Cmd, [])),
244244

@@ -441,8 +441,8 @@ get_all_tags() ->
441441
benchset(BenchInfos, Metric, Kind, Size, GroupEnv, XEnv) ->
442442
benchset(BenchInfos, Metric, Kind, Size, GroupEnv, XEnv, []).
443443

444-
benchset(_, Metric, Kind, _, _, _, Acc) when (Metric == undefined) or (Kind == undefined) -> Acc;
445-
benchset(_, _, _, Size, _, _, Acc) when (Size > 0) and (size(Acc) >= Size) -> Acc;
444+
benchset(_, Metric, Kind, _, _, _, Acc) when (Metric == "undefined") or (Kind == "undefined") -> Acc;
445+
benchset(_, _, _, Size, _, _, Acc) when (Size > 0) and (length(Acc) >= Size) -> Acc;
446446
benchset([], _, _, _, _, _, Acc) -> Acc;
447447
benchset([BenchInfo | Rest], Metric, Kind, Size, GroupEnv, XEnv, Acc) ->
448448
NewAcc = case has_metric(Metric, Kind, BenchInfo) of
@@ -602,7 +602,7 @@ apply_filter(Query, BenchInfos) ->
602602
end.
603603

604604
get_searchable_fields(BenchInfo) ->
605-
SearchFields = mzb_bc:maps_with([id, status, benchmark_name, script_name, start_time, finish_time], BenchInfo),
605+
SearchFields = mzb_bc:maps_with([id, status, name, script_name, start_time, finish_time], BenchInfo),
606606
Values = maps:values(SearchFields),
607607
Tags = [ "#" ++ erlang:atom_to_list(T) || T <- mzb_bc:maps_get(tags, BenchInfo, [])],
608608
lists:map(fun (X) when is_atom(X) -> atom_to_list(X);

server/test/mzb_api_ws_handler_tests.erl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ normalize_test() ->
1717
start_time => 1437549842,
1818
finish_time => 1437549842,
1919
config => #{script => #{body => script_body1, name => "another_name.erl"},
20-
benchmark_name => "Test bench", nodes_arg => "1", cloud => "", vm_args => [], env => [], tags => ["tag1", "tag2"]}}}
20+
benchmark_name => "Test bench", nodes_arg => "1", cloud => "",
21+
vm_args => [], env => [], tags => ["tag1", "tag2"]},
22+
results => [{key, value}]}}
2123
],
2224

2325
Normalized = mzb_api_ws_handler:normalize(BenchInfos),
2426

2527
?assertEqual([
2628
#{finish_time => "2015-07-22T07:24:02Z",
2729
id => 2,
28-
benchmark_name => "Test bench",
30+
name => "Test bench",
2931
metrics => metrics,
3032
script_body => script_body1,
3133
script_name => "another_name.erl",
@@ -34,9 +36,10 @@ normalize_test() ->
3436
cloud => "",
3537
env => #{vm_args => []},
3638
status => success,
37-
tags => [tag1, tag2]},
39+
tags => [tag1, tag2],
40+
results => #{key => value}},
3841
#{id => 1,
39-
benchmark_name => "Test bench",
42+
name => "Test bench",
4043
metrics => metrics,
4144
script_body => script_body,
4245
script_name => "script_name.erl",
@@ -45,7 +48,8 @@ normalize_test() ->
4548
cloud => "",
4649
env => #{vm_args => []},
4750
status => failed,
48-
tags => []}],
51+
tags => [],
52+
results => #{}}],
4953
Normalized).
5054

5155
filter_test() ->

0 commit comments

Comments
 (0)