Exemplo n.º 1
0
 def test_validate_allow_autocorrect_moves_infrastructure_templates_to_lifecycle(
         self):
     project_sim = self.simlab.simulate_brent_with_infrastructure_templates(
     )
     project = Project(project_sim.path)
     find_yaml_path = os.path.join(project_sim.path, BRENT_DEFINITIONS_DIR,
                                   BRENT_INFRASTRUCTURE_DIR, 'find.yaml')
     with open(find_yaml_path, 'r') as f:
         find_yaml_content = f.read()
     heat_yaml_path = os.path.join(project_sim.path, BRENT_DEFINITIONS_DIR,
                                   BRENT_INFRASTRUCTURE_DIR,
                                   'openstack.yaml')
     with open(heat_yaml_path, 'r') as f:
         heat_yaml_content = f.read()
     kube_yaml_path = os.path.join(project_sim.path, BRENT_DEFINITIONS_DIR,
                                   BRENT_INFRASTRUCTURE_DIR, 'kube.yaml')
     with open(kube_yaml_path, 'r') as f:
         kube_yaml_content = f.read()
     validate_options = ValidateOptions()
     validate_options.allow_autocorrect = True
     result = project.validate(validate_options)
     self.assertFalse(result.has_errors())
     self.assertFalse(result.has_warnings())
     project = Project(project_sim.path)
     tester = self.assert_project(project)
     inf_manifest_path = os.path.join(project_sim.path,
                                      BRENT_DEFINITIONS_DIR,
                                      BRENT_INFRASTRUCTURE_DIR,
                                      BRENT_INFRASTRUCTURE_MANIFEST_FILE)
     tester.assert_has_no_file(find_yaml_path)
     tester.assert_has_no_file(heat_yaml_path)
     tester.assert_has_no_file(kube_yaml_path)
     tester.assert_has_file(
         os.path.join(project_sim.path, BRENT_LIFECYCLE_DIR,
                      BRENT_OPENSTACK_DIR, BRENT_OPENSTACK_HEAT_YAML_FILE),
         heat_yaml_content)
     tester.assert_has_file(
         os.path.join(project_sim.path, BRENT_LIFECYCLE_DIR,
                      BRENT_OPENSTACK_DIR,
                      BRENT_OPENSTACK_DISCOVER_YAML_FILE),
         find_yaml_content)
     tester.assert_has_file(
         os.path.join(project_sim.path, BRENT_LIFECYCLE_DIR,
                      BRENT_KUBERNETES_DIR, 'kube.yaml'), kube_yaml_content)
     lm_dir = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_DESCRIPTOR_DIR)
     descriptor_path = os.path.join(lm_dir, BRENT_DESCRIPTOR_YML_FILE)
     tester.assert_has_file(descriptor_path,
                            EXPECTED_AUTOCORRECT_INFRASTRUCTURE_DESCRIPTOR)
Exemplo n.º 2
0
 def test_validate_allow_autocorrect_adds_selector_to_driver_entries_in_descriptor(
         self):
     project_sim = self.simlab.simulate_brent_with_missing_driver_selector()
     project = Project(project_sim.path)
     validate_options = ValidateOptions()
     validate_options.allow_autocorrect = True
     result = project.validate(validate_options)
     self.assertFalse(result.has_errors())
     self.assertFalse(result.has_warnings())
     project = Project(project_sim.path)
     tester = self.assert_project(project)
     lm_dir = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_DESCRIPTOR_DIR)
     descriptor_path = os.path.join(lm_dir, BRENT_DESCRIPTOR_YML_FILE)
     tester.assert_has_file(
         descriptor_path,
         EXPECTED_AUTOCORRECT_WITH_MISSING_DRIVER_SELECTORS_DESCRIPTOR)
Exemplo n.º 3
0
 def test_validate_allow_autocorrect_fixes_manifests(self):
     project_sim = self.simlab.simulate_brent_2dot1_with_prealpha_style()
     project = Project(project_sim.path)
     validate_options = ValidateOptions()
     validate_options.allow_autocorrect = True
     result = project.validate(validate_options)
     self.assertFalse(result.has_errors())
     self.assertFalse(result.has_warnings())
     project = Project(project_sim.path)
     tester = self.assert_project(project)
     inf_manifest_path = os.path.join(project_sim.path,
                                      BRENT_DEFINITIONS_DIR,
                                      BRENT_INFRASTRUCTURE_DIR,
                                      BRENT_INFRASTRUCTURE_MANIFEST_FILE)
     tester.assert_has_no_file(inf_manifest_path)
     lifeycle_manifest_path = os.path.join(project_sim.path,
                                           BRENT_LIFECYCLE_DIR,
                                           BRENT_LIFECYCLE_MANIFEST_FILE)
     tester.assert_has_no_file(lifeycle_manifest_path)
     lm_dir = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_DESCRIPTOR_DIR)
     descriptor_path = os.path.join(lm_dir, BRENT_DESCRIPTOR_YML_FILE)
     tester.assert_has_file(descriptor_path,
                            EXPECTED_AUTOCORRECT_DESCRIPTOR)