def test_init_from_xml_health_checks_on(self): xml_files = [ textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <vm>true</vm> <health-check> <enable-health-check>true</enable-health-check> </health-check> </appengine-web-app>"""), textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <vm>true</vm> <health-check> <enable-health-check></enable-health-check> </health-check> </appengine-web-app>"""), textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <vm>true</vm> </appengine-web-app>""") ] for xml_file in xml_files: conf_file_name = self._make_xml_configs(xml_file) conf = configuration.ApplicationConfiguration(conf_file_name) self.assertTrue( conf.health_checks_enabled, 'Health checks should be ' 'enabled in file:\n{0}'.format(xml_file))
def test_init_from_yaml_health_checks_off(self): yaml_file = textwrap.dedent("""\ vm: true health_check: enable_health_check: False""") conf_file_name = self._make_yaml_config(yaml_file) conf = configuration.ApplicationConfiguration(conf_file_name) self.assertFalse(conf.health_checks_enabled)
def test_init_from_xml_health_checks_off(self): xml_file = textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <vm>true</vm> <health-check> <enable-health-check>false</enable-health-check> </health-check> </appengine-web-app>""") conf_file_name = self._make_xml_configs(xml_file) conf = configuration.ApplicationConfiguration(conf_file_name) self.assertFalse(conf.health_checks_enabled)
def test_init_from_yaml_vm_false(self): yaml_files = [ textwrap.dedent("""\ health_check: enable_health_check: True check_interval_sec: 5 timeout_sec: 4 unhealthy_threshold: 2 healthy_threshold: 2 restart_threshold: 60"""), textwrap.dedent("""vm: false""") ] for yaml_file in yaml_files: conf_file_name = self._make_yaml_config(yaml_file) with self.assertRaises(utils.AppstartAbort): configuration.ApplicationConfiguration(conf_file_name)
def test_init_from_yaml_health_checks_on(self): yaml_files = [ textwrap.dedent("""\ vm: true health_check: enable_health_check: True check_interval_sec: 5 timeout_sec: 4 unhealthy_threshold: 2 healthy_threshold: 2 restart_threshold: 60"""), textwrap.dedent("""vm: true""") ] for yaml_file in yaml_files: conf_file_name = self._make_yaml_config(yaml_file) conf = configuration.ApplicationConfiguration(conf_file_name) self.assertTrue(conf.health_checks_enabled)
def test_init_from_xml_vm_false(self): xml_files = [ textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> </appengine-web-app>"""), textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <vm></vm> </appengine-web-app>"""), textwrap.dedent("""\ <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <vm>false</vm> </appengine-web-app>""") ] for xml_file in xml_files: conf_file_name = self._make_xml_configs(xml_file) with self.assertRaises(utils.AppstartAbort): configuration.ApplicationConfiguration(conf_file_name)
def test_malformed_yaml(self): yaml_file = 'malformed yaml file' conf_file_name = self._make_yaml_config(yaml_file) with self.assertRaises(utils.AppstartAbort): configuration.ApplicationConfiguration(conf_file_name)