@@ -860,7 +860,8 @@ def setUp(self):
860860
861861 def tearDown (self ):
862862 valve_util .close_logger (self .ryu_app .logger )
863- # shutil.rmtree(self.tmpdir)
863+ valve_util .close_logger (self .ryu_app .exc_logger )
864+ shutil .rmtree (self .tmpdir )
864865
865866 @staticmethod
866867 def _fake_dp ():
@@ -922,8 +923,7 @@ def test_gauge_config(self):
922923 os .environ ['FAUCET_CONFIG' ] = os .path .join (self .tmpdir , 'faucet.yaml' )
923924 self ._write_config (os .environ ['FAUCET_CONFIG' ], faucet_conf1 )
924925 os .environ ['GAUGE_CONFIG' ] = os .path .join (self .tmpdir , 'gauge.yaml' )
925- self ._write_config (os .environ ['GAUGE_CONFIG' ],
926- """
926+ gauge_conf = """
927927faucet_configs:
928928 - '%s'
929929watchers:
@@ -946,7 +946,8 @@ def test_gauge_config(self):
946946 type: 'prometheus'
947947 prometheus_addr: '0.0.0.0'
948948 prometheus_port: 0
949- """ % os .environ ['FAUCET_CONFIG' ])
949+ """ % os .environ ['FAUCET_CONFIG' ]
950+ self ._write_config (os .environ ['GAUGE_CONFIG' ], gauge_conf )
950951 self .ryu_app = gauge .Gauge (
951952 dpset = {},
952953 reg = CollectorRegistry ())
@@ -956,11 +957,25 @@ def test_gauge_config(self):
956957 self .ryu_app .reload_config (None )
957958 self .assertTrue (self .ryu_app .watchers )
958959 self .assertFalse (self .ryu_app ._config_files_changed ())
960+ # Load a new FAUCET config.
959961 self ._write_config (os .environ ['FAUCET_CONFIG' ], faucet_conf2 )
960962 self .assertTrue (self .ryu_app ._config_files_changed ())
961963 self .ryu_app .reload_config (None )
962964 self .assertTrue (self .ryu_app .watchers )
963965 self .assertFalse (self .ryu_app ._config_files_changed ())
966+ # Load an invalid Gauge config
967+ self ._write_config (os .environ ['GAUGE_CONFIG' ], 'invalid' )
968+ self .assertTrue (self .ryu_app ._config_files_changed ())
969+ self .ryu_app .reload_config (None )
970+ self .assertTrue (self .ryu_app .watchers )
971+ # Keep trying to load a valid version.
972+ self .assertTrue (self .ryu_app ._config_files_changed ())
973+ # Load good Gauge config back
974+ self ._write_config (os .environ ['GAUGE_CONFIG' ], gauge_conf )
975+ self .assertTrue (self .ryu_app ._config_files_changed ())
976+ self .ryu_app .reload_config (None )
977+ self .assertTrue (self .ryu_app .watchers )
978+ self .assertFalse (self .ryu_app ._config_files_changed ())
964979
965980
966981if __name__ == "__main__" :
0 commit comments