<s> from collections import defaultdict <EOL> import time <EOL> from nose . plugins . attrib import attr <EOL> from tests . checks . common import AgentCheckTest <EOL> @ attr ( requires = '<STR_LIT>' ) <EOL> class TestGoExpVar ( AgentCheckTest ) : <EOL> CHECK_NAME = '<STR_LIT>' <EOL> CHECK_GAUGES = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> CHECK_GAUGES_DEFAULT = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> CHECK_GAUGES_CUSTOM = { '<STR_LIT>' : '<STR_LIT>' } <EOL> CHECK_RATES = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> CHECK_RATES_CUSTOM = { '<STR_LIT>' : <NUM_LIT:0> } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> AgentCheckTest . __init__ ( self , * args , ** kwargs ) <EOL> self . config = { <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT:path>' : '<STR_LIT>' <EOL> } , <EOL> { <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> "<STR_LIT:type>" : "<STR_LIT>" <EOL> } , <EOL> ] <EOL> } ] <EOL> } <EOL> def _run_check_twice ( self ) : <EOL> mocks = { } <EOL> config = self . config <EOL> expvar_url = self . config [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> fake_last_gc_count = defaultdict ( int ) <EOL> mocks [ '<STR_LIT>' ] = fake_last_gc_count <EOL> self . run_check ( config , mocks = mocks ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> del fake_last_gc_count [ expvar_url ] <EOL> self . run_check ( config , mocks = mocks ) <EOL> def test_go_expvar ( self ) : <EOL> self . _run_check_twice ( ) <EOL> shared_tags = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' . format ( self . config [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) <EOL> ] <EOL> for gauge in self . CHECK_GAUGES + self . CHECK_GAUGES_DEFAULT : <EOL> self . assertMetric ( gauge , count = <NUM_LIT:1> , tags = shared_tags ) <EOL> for rate in self . CHECK_RATES : <EOL> self . assertMetric ( rate , count = <NUM_LIT:1> , tags = shared_tags ) <EOL> for gauge , value in self . CHECK_GAUGES_CUSTOM . iteritems ( ) : <EOL> self . assertMetric ( gauge , count = <NUM_LIT:1> , value = value , tags = shared_tags ) <EOL> for rate , value in self . CHECK_RATES_CUSTOM . iteritems ( ) : <EOL> self . assertMetric ( rate , count = <NUM_LIT:1> , value = value , tags = shared_tags ) <EOL> self . coverage_report ( ) </s>
