Avoid filling range towards the past (that'd be TS-Interval < Start)

This commit is contained in:
Diana Corbacho 2017-02-21 15:05:46 +00:00
parent 6ae1b78044
commit 66490bb80d
2 changed files with 36 additions and 2 deletions

View File

@ -465,7 +465,7 @@ take_since([{DropTS, drop} | T], Now, Start, N, [{TS, Evt} | _] = Acc,
Interval, N)],
take_since(Rest, Now, Start, decr(N), [E | Fill ++ Acc], Interval);
[Prev | _] -> % next sample is out of range so needs to be filled from Start
Fill = [{TS1, Evt} || TS1 <- truncated_seq(Start, TS - Interval,
Fill = [{TS1, Evt} || TS1 <- truncated_seq(Start, max(Start, TS - Interval),
Interval, N)],
{Prev, Fill ++ Acc}
end;

View File

@ -46,7 +46,8 @@ groups() ->
sum_single,
to_normalized_list,
to_normalized_list_no_padding,
to_list_in_the_past
to_list_in_the_past,
sum_mgmt_352
]}
].
@ -498,8 +499,41 @@ to_list_in_the_past(_Config) ->
% this could happen if a node with and incorrect clock joins the cluster
[] = exometer_slide:to_list(50, 10, S).
sum_mgmt_352(_Config) ->
Slide = sum_mgmt_352_slide(),
Last = 1487689330000,
First = 1487689270000,
Incr = 5000,
Empty = {0},
Sum = exometer_slide:sum(Last, First, Incr, [Slide], Empty),
ct:pal("SUM is ~p~n", [Sum]),
ok.
%% -------------------------------------------------------------------
%% Util
%% -------------------------------------------------------------------
ele(TS, V) -> {TS, {V}}.
%% -------------------------------------------------------------------
%% Data
%% -------------------------------------------------------------------
sum_mgmt_352_slide() ->
%% Provide slide as is, from a debug session triggering mgmt-352 bug
{slide,610000,45,122,true,5000,1487689328468,1487689106834,
[{1487689328468,{1574200}},
{1487689323467,{1538800}},
{1487689318466,{1500800}},
{1487689313465,{1459138}},
{1487689308463,{1419200}},
{1487689303462,{1379600}},
{1487689298461,{1340000}},
{1487689293460,{1303400}},
{1487689288460,{1265600}},
{1487689283458,{1231400}},
{1487689278457,{1215800}},
{1487689273456,{1215200}},
{1487689262487,drop},
{1487689257486,{1205600}}],
[],
{1591000}}.