<s> from bzt . modules . aggregator import ConsolidatingAggregator , DataPoint , KPISet <EOL> from tests import BZTestCase , r <EOL> from tests . mocks import MockReader <EOL> class TestConsolidatingAggregator ( BZTestCase ) : <EOL> def test_mock ( self ) : <EOL> reader = self . get_reader ( ) <EOL> reader . buffer_scale_idx = '<STR_LIT>' <EOL> first = list ( reader . datapoints ( ) ) <EOL> second = list ( reader . datapoints ( True ) ) <EOL> self . assertEquals ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ x [ DataPoint . TIMESTAMP ] for x in first ] ) <EOL> self . assertEquals ( [ <NUM_LIT:5> , <NUM_LIT:6> ] , [ x [ DataPoint . TIMESTAMP ] for x in second ] ) <EOL> for point in first + second : <EOL> val = point [ DataPoint . CURRENT ] [ '<STR_LIT>' ] <EOL> def test_merging ( self ) : <EOL> dst = DataPoint ( <NUM_LIT:0> ) <EOL> src = DataPoint ( <NUM_LIT:0> ) <EOL> src [ DataPoint . CUMULATIVE ] . get ( '<STR_LIT>' , KPISet ( ) ) <EOL> src [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] . sum_rt = <NUM_LIT:0.5> <EOL> src [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . SAMPLE_COUNT ] = <NUM_LIT:1> <EOL> dst . merge_point ( src ) <EOL> self . assertEquals ( <NUM_LIT:0.5> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] . sum_rt ) <EOL> self . assertEquals ( <NUM_LIT:0.5> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . AVG_RESP_TIME ] ) <EOL> src [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . SAMPLE_COUNT ] = <NUM_LIT:3> <EOL> dst . merge_point ( src ) <EOL> self . assertEquals ( <NUM_LIT:4> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . SAMPLE_COUNT ] ) <EOL> self . assertEquals ( <NUM_LIT:1> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] . sum_rt ) <EOL> self . assertEquals ( <NUM_LIT> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . AVG_RESP_TIME ] ) <EOL> src [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . SAMPLE_COUNT ] = <NUM_LIT:6> <EOL> dst . merge_point ( src ) <EOL> self . assertEquals ( <NUM_LIT:10> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . SAMPLE_COUNT ] ) <EOL> self . assertEquals ( <NUM_LIT> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] . sum_rt ) <EOL> self . assertEquals ( <NUM_LIT> , dst [ DataPoint . CUMULATIVE ] [ '<STR_LIT>' ] [ KPISet . AVG_RESP_TIME ] ) <EOL> def test_two_executions ( self ) : <EOL> obj = ConsolidatingAggregator ( ) <EOL> obj . track_percentiles = [ <NUM_LIT:0> , <NUM_LIT:50> , <NUM_LIT:100> ] <EOL> obj . prepare ( ) <EOL> underling1 = self . get_reader ( ) <EOL> underling2 = self . get_reader ( ) <EOL> obj . add_underling ( underling1 ) <EOL> obj . add_underling ( underling2 ) <EOL> cnt = <NUM_LIT:0> <EOL> for _ in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> for point in obj . datapoints ( ) : <EOL> overall = point [ DataPoint . CURRENT ] [ '<STR_LIT>' ] <EOL> self . assertEquals ( <NUM_LIT:2> , overall [ KPISet . CONCURRENCY ] ) <EOL> self . assertGreater ( overall [ KPISet . PERCENTILES ] [ "<STR_LIT>" ] , <NUM_LIT:0> ) <EOL> self . assertGreater ( overall [ KPISet . AVG_RESP_TIME ] , <NUM_LIT:0> ) <EOL> cnt += <NUM_LIT:1> <EOL> self . assertEquals ( <NUM_LIT:2> , cnt ) <EOL> def get_reader ( self , offset = <NUM_LIT:0> ) : <EOL> mock = MockReader ( ) <EOL> mock . data . append ( ( <NUM_LIT:1> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:2> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:2> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:3> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:3> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:4> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:4> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:6> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:6> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:6> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> mock . data . append ( ( <NUM_LIT:5> + offset , "<STR_LIT>" , <NUM_LIT:1> , r ( ) , r ( ) , r ( ) , <NUM_LIT:200> , None , '<STR_LIT>' ) ) <EOL> return mock </s>
