def test_create_camp_assembly(self): """Test creating a CAMP assembly from a local plan resource. Creates a plan resource then uses that to create an assembly resource. """ if base.config_set_as('camp_enabled', False): self.skipTest('CAMP not enabled.') # create a plan using the CAMP API resp = self._create_camp_plan(data=test_plans.sample_data) self.assertEqual(resp.status, 201) uri = (resp.data['uri'][len(self.client.base_url):]) ref_obj = json.dumps({'plan_uri': uri}) resp, body = self.client.post( 'camp/v1_1/assemblies', ref_obj, headers={'content-type': 'application/json'}) self.assertEqual(resp.status, 201) assem_resp = base.SolumResponse(resp=resp, body=body, body_type='json') uuid = assem_resp.uuid if uuid is not None: # share the Solum client's list of created assemblies self.client.created_assemblies.append(uuid)
def test_delete_plan_with_assemblies(self): """Test deleting a plan that has assemblies associated with it. Creates a plan, an assembly, then tries to delete the plan. """ if base.config_set_as('camp_enabled', False): self.skipTest('CAMP not enabled.') # create a plan using the CAMP API resp = self._create_camp_plan(data=test_plans.sample_data) self.assertEqual(resp.status, 201) plan_uri = (resp.data['uri'][len(self.client.base_url):]) ref_obj = json.dumps({'plan_uri': plan_uri}) resp, body = self.client.post( 'camp/v1_1/assemblies', ref_obj, headers={'content-type': 'application/json'}) self.assertEqual(resp.status, 201) assem_resp = base.SolumResponse(resp=resp, body=body, body_type='json') uuid = assem_resp.uuid if uuid is not None: # share the Solum client's list of created assemblies self.client.created_assemblies.append(uuid) # try to delete the plan before deleting the assembly # resp, body = self.client.delete(plan_uri[1:]) # self.assertEqual(409, resp.status) self.assertRaises(tempest_exceptions.Conflict, self.client.delete, plan_uri[1:])
def _create_camp_plan(self, data): yaml_data = yaml.dump(data) resp, body = self.client.post( 'camp/v1_1/plans', yaml_data, headers={'content-type': 'application/x-yaml'}) plan_resp = base.SolumResponse(resp=resp, body=body, body_type='json') uuid = plan_resp.uuid if uuid is not None: # share the Solum client's list of created plans self.client.created_plans.append(uuid) return plan_resp