From 9296f611de2055c65bdae9425ce80e63fba6610f Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Sat, 10 Jun 2017 15:33:49 +0200 Subject: Randomly select traffic testcases Since the number of configuration variants tested makes for (too) many. Randomly select a subset of testcases in each configuration group. --- lib/diameter/test/diameter_traffic_SUITE.erl | 10 +++++++++- lib/diameter/test/diameter_util.erl | 13 +------------ 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'lib/diameter/test') diff --git a/lib/diameter/test/diameter_traffic_SUITE.erl b/lib/diameter/test/diameter_traffic_SUITE.erl index 6aa3ffb7af..bb10638cd2 100644 --- a/lib/diameter/test/diameter_traffic_SUITE.erl +++ b/lib/diameter/test/diameter_traffic_SUITE.erl @@ -341,7 +341,11 @@ init_per_group(Name, Config) -> server_strings = SD, server_sender = SS, server_throttle = ST}, - [{group, G} | Config]; + %% Limit the number of testcase, since the number of + %% groups is large. + All = ?util:scramble(tc()), + TCs = lists:sublist(All, rand:uniform(32)), + [{group, G}, {runlist, TCs} | Config]; _ -> Config end. @@ -359,12 +363,16 @@ end_per_group(_, _) -> %% Skip testcases that can reasonably fail under SCTP. init_per_testcase(Name, Config) -> + TCs = proplists:get_value(runlist, Config, []), + Run = [] == TCs orelse lists:member(Name, TCs), case [G || #group{transport = sctp} = G <- [proplists:get_value(group, Config)]] of [_] when Name == send_maxlen; Name == send_long -> {skip, sctp}; + _ when not Run -> + {skip, random}; _ -> [{testcase, Name} | Config] end. diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl index 81b43913de..7266d3678c 100644 --- a/lib/diameter/test/diameter_util.erl +++ b/lib/diameter/test/diameter_util.erl @@ -173,18 +173,7 @@ recvl([{MRef, F} | L], Ref, Fun, Acc) -> %% Sort a list into random order. scramble(L) -> - foldl(fun(true, _, S, false) -> S end, - false, - [[fun s/1, L]]). - -s(L) -> - s([], L). - -s(Acc, []) -> - Acc; -s(Acc, L) -> - {H, [T|Rest]} = lists:split(rand:uniform(length(L)) - 1, L), - s([T|Acc], H ++ Rest). + [X || {_,X} <- lists:sort([{rand:uniform(), T} || T <- L])]. %% --------------------------------------------------------------------------- %% unique_string/0 -- cgit v1.2.3