def test_deployment_update_several(self): # Create a deployment and update it deploy_one = db.deployment_create({}) self.assertEqual(deploy_one['config'], {}) update_deploy_one = db.deployment_update( deploy_one['uuid'], {'config': { 'opt1': 'val1' }}, ) self.assertEqual(update_deploy_one['uuid'], deploy_one['uuid']) self.assertEqual(update_deploy_one['config'], {'opt1': 'val1'}) get_deploy_one = db.deployment_get(deploy_one['uuid']) self.assertEqual(get_deploy_one['uuid'], deploy_one['uuid']) self.assertEqual(get_deploy_one['config'], {'opt1': 'val1'}) # Create another deployment deploy_two = db.deployment_create({}) update_deploy_two = db.deployment_update( deploy_two['uuid'], {'config': { 'opt2': 'val2' }}, ) self.assertEqual(update_deploy_two['uuid'], deploy_two['uuid']) self.assertEqual(update_deploy_two['config'], {'opt2': 'val2'}) get_deploy_one_again = db.deployment_get(deploy_one['uuid']) self.assertEqual(get_deploy_one_again['uuid'], deploy_one['uuid']) self.assertEqual(get_deploy_one_again['config'], {'opt1': 'val1'})
def test_deployment_delete(self): deploy_one = db.deployment_create({}) deploy_two = db.deployment_create({}) db.deployment_delete(deploy_two['uuid']) deploys = db.deployment_list() self.assertEqual(len(deploys), 1) self.assertEqual(deploys[0]['uuid'], deploy_one['uuid'])
def test_deployment_update_several(self): # Create a deployment and update it deploy_one = db.deployment_create({}) self.assertEqual(deploy_one['config'], {}) update_deploy_one = db.deployment_update( deploy_one['uuid'], {'config': {'opt1': 'val1'}}, ) self.assertEqual(update_deploy_one['uuid'], deploy_one['uuid']) self.assertEqual(update_deploy_one['config'], {'opt1': 'val1'}) get_deploy_one = db.deployment_get(deploy_one['uuid']) self.assertEqual(get_deploy_one['uuid'], deploy_one['uuid']) self.assertEqual(get_deploy_one['config'], {'opt1': 'val1'}) # Create another deployment deploy_two = db.deployment_create({}) update_deploy_two = db.deployment_update( deploy_two['uuid'], {'config': {'opt2': 'val2'}}, ) self.assertEqual(update_deploy_two['uuid'], deploy_two['uuid']) self.assertEqual(update_deploy_two['config'], {'opt2': 'val2'}) get_deploy_one_again = db.deployment_get(deploy_one['uuid']) self.assertEqual(get_deploy_one_again['uuid'], deploy_one['uuid']) self.assertEqual(get_deploy_one_again['config'], {'opt1': 'val1'})
def test_deployment_update_several(self): # Create a deployment and update it deploy_one = db.deployment_create({}) self.assertEqual(deploy_one["config"], {}) update_deploy_one = db.deployment_update(deploy_one["uuid"], {"config": { "opt1": "val1" }}) self.assertEqual(update_deploy_one["uuid"], deploy_one["uuid"]) self.assertEqual(update_deploy_one["config"], {"opt1": "val1"}) get_deploy_one = db.deployment_get(deploy_one["uuid"]) self.assertEqual(get_deploy_one["uuid"], deploy_one["uuid"]) self.assertEqual(get_deploy_one["config"], {"opt1": "val1"}) # Create another deployment deploy_two = db.deployment_create({}) update_deploy_two = db.deployment_update(deploy_two["uuid"], {"config": { "opt2": "val2" }}) self.assertEqual(update_deploy_two["uuid"], deploy_two["uuid"]) self.assertEqual(update_deploy_two["config"], {"opt2": "val2"}) get_deploy_one_again = db.deployment_get(deploy_one["uuid"]) self.assertEqual(get_deploy_one_again["uuid"], deploy_one["uuid"]) self.assertEqual(get_deploy_one_again["config"], {"opt1": "val1"})
def test_deployment_get(self): deploy_one = db.deployment_create({"config": {"opt1": "val1"}}) deploy_two = db.deployment_create({"config": {"opt2": "val2"}}) get_deploy_one = db.deployment_get(deploy_one["uuid"]) get_deploy_two = db.deployment_get(deploy_two["uuid"]) self.assertNotEqual(get_deploy_one["uuid"], get_deploy_two["uuid"]) self.assertEqual(get_deploy_one["config"], {"opt1": "val1"}) self.assertEqual(get_deploy_two["config"], {"opt2": "val2"})
def test_deployment_list_parent(self): deploy = db.deployment_create({}) subdeploy1 = db.deployment_create({'parent_uuid': deploy.uuid}) subdeploy2 = db.deployment_create({'parent_uuid': deploy.uuid}) self.assertEqual([deploy.uuid], [d.uuid for d in db.deployment_list()]) subdeploys = db.deployment_list(parent_uuid=deploy.uuid) self.assertEqual(set([subdeploy1.uuid, subdeploy2.uuid]), set([d.uuid for d in subdeploys]))
def test_deployment_get(self): deploy_one = db.deployment_create({'config': {'opt1': 'val1'}}) deploy_two = db.deployment_create({'config': {'opt2': 'val2'}}) get_deploy_one = db.deployment_get(deploy_one['uuid']) get_deploy_two = db.deployment_get(deploy_two['uuid']) self.assertNotEqual(get_deploy_one['uuid'], get_deploy_two['uuid']) self.assertEqual(get_deploy_one['config'], {'opt1': 'val1'}) self.assertEqual(get_deploy_two['config'], {'opt2': 'val2'})
def test_get_all(self): deployment0 = db.deployment_create({}) deployment1 = db.deployment_create({}) res0 = db.resource_create({"deployment_uuid": deployment0["uuid"]}) res1 = db.resource_create({"deployment_uuid": deployment1["uuid"]}) res2 = db.resource_create({"deployment_uuid": deployment1["uuid"]}) resources = db.resource_get_all(deployment1["uuid"]) self.assertEqual(sorted([res1["id"], res2["id"]]), sorted([r["id"] for r in resources])) resources = db.resource_get_all(deployment0["uuid"]) self.assertEqual(len(resources), 1) self.assertEqual(res0["id"], resources[0]["id"])
def test_get_all(self): deployment0 = db.deployment_create({}) deployment1 = db.deployment_create({}) res0 = db.resource_create({'deployment_uuid': deployment0['uuid']}) res1 = db.resource_create({'deployment_uuid': deployment1['uuid']}) res2 = db.resource_create({'deployment_uuid': deployment1['uuid']}) resources = db.resource_get_all(deployment1['uuid']) self.assertEqual(sorted([res1['id'], res2['id']]), sorted([r['id'] for r in resources])) resources = db.resource_get_all(deployment0['uuid']) self.assertEqual(len(resources), 1) self.assertEqual(res0['id'], resources[0]['id'])
def test_deployment_list_with_status(self): deploy_one = db.deployment_create({}) deploy_two = db.deployment_create({ 'config': {}, 'status': consts.DeployStatus.DEPLOY_FAILED, }) deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_INIT) self.assertEqual(len(deploys), 1) self.assertEqual(deploys[0]['uuid'], deploy_one['uuid']) deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_FAILED) self.assertEqual(len(deploys), 1) self.assertEqual(deploys[0]['uuid'], deploy_two['uuid']) deploys = db.deployment_list( status=consts.DeployStatus.DEPLOY_FINISHED) self.assertEqual(len(deploys), 0)
def test_deployment_create(self): deploy = db.deployment_create({'config': {'opt': 'val'}}) deploys = db.deployment_list() self.assertEqual(len(deploys), 1) self.assertEqual(deploy['uuid'], deploys[0]['uuid']) self.assertEqual(deploy['status'], consts.DeployStatus.DEPLOY_INIT) self.assertEqual(deploy['config'], {'opt': 'val'})
def test_deployment_create(self): deploy = db.deployment_create({"config": {"opt": "val"}}) deploys = db.deployment_list() self.assertEqual(len(deploys), 1) self.assertEqual(deploy["uuid"], deploys[0]["uuid"]) self.assertEqual(deploy["status"], consts.DeployStatus.DEPLOY_INIT) self.assertEqual(deploy["config"], {"opt": "val"})
def test_deployment_update(self): deploy = db.deployment_create({}) self.assertEqual(deploy['config'], {}) update_deploy = db.deployment_update(deploy['uuid'], {'config': {'opt': 'val'}}) self.assertEqual(update_deploy['uuid'], deploy['uuid']) self.assertEqual(update_deploy['config'], {'opt': 'val'}) get_deploy = db.deployment_get(deploy['uuid']) self.assertEqual(get_deploy['uuid'], deploy['uuid']) self.assertEqual(get_deploy['config'], {'opt': 'val'})
def test_deployment_list_with_status_and_name(self): deploy_one = db.deployment_create({}) deploy_two = db.deployment_create({ 'config': {}, 'status': consts.DeployStatus.DEPLOY_FAILED, }) deploy_three = db.deployment_create({'name': 'deployment_name'}) deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_INIT) self.assertEqual(len(deploys), 2) self.assertEqual(deploys[0]['uuid'], deploy_one['uuid']) deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_FAILED) self.assertEqual(len(deploys), 1) self.assertEqual(deploys[0]['uuid'], deploy_two['uuid']) deploys = db.deployment_list( status=consts.DeployStatus.DEPLOY_FINISHED) self.assertEqual(len(deploys), 0) deploys = db.deployment_list(name='deployment_name') self.assertEqual(deploys[0]['uuid'], deploy_three['uuid']) self.assertEqual(len(deploys), 1)
def test_deployment_update(self): deploy = db.deployment_create({}) self.assertEqual(deploy["config"], {}) update_deploy = db.deployment_update(deploy["uuid"], {"config": {"opt": "val"}}) self.assertEqual(update_deploy["uuid"], deploy["uuid"]) self.assertEqual(update_deploy["config"], {"opt": "val"}) get_deploy = db.deployment_get(deploy["uuid"]) self.assertEqual(get_deploy["uuid"], deploy["uuid"]) self.assertEqual(get_deploy["config"], {"opt": "val"})
def test_deployment_create_several(self): # Create a deployment deploys = db.deployment_list() self.assertEqual(len(deploys), 0) deploy_one = db.deployment_create({"config": {"opt1": "val1"}}) deploys = db.deployment_list() self.assertEqual(len(deploys), 1) self.assertEqual(deploy_one["uuid"], deploys[0]["uuid"]) self.assertEqual(deploy_one["status"], consts.DeployStatus.DEPLOY_INIT) self.assertEqual(deploy_one["config"], {"opt1": "val1"}) # Create another deployment and sure that they are different deploy_two = db.deployment_create({"config": {"opt2": "val2"}}) deploys = db.deployment_list() self.assertEqual(len(deploys), 2) self.assertEqual(set([deploy_one["uuid"], deploy_two["uuid"]]), set([deploy["uuid"] for deploy in deploys])) self.assertNotEqual(deploy_one["uuid"], deploy_two["uuid"]) self.assertEqual(deploy_two["status"], consts.DeployStatus.DEPLOY_INIT) self.assertEqual(deploy_two["config"], {"opt2": "val2"})
def test_deployment_create_several(self): # Create a deployment deploys = db.deployment_list() self.assertEqual(len(deploys), 0) deploy_one = db.deployment_create({'config': {'opt1': 'val1'}}) deploys = db.deployment_list() self.assertEqual(len(deploys), 1) self.assertEqual(deploy_one['uuid'], deploys[0]['uuid']) self.assertEqual(deploy_one['status'], consts.DeployStatus.DEPLOY_INIT) self.assertEqual(deploy_one['config'], {'opt1': 'val1'}) # Create another deployment and sure that they are different deploy_two = db.deployment_create({'config': {'opt2': 'val2'}}) deploys = db.deployment_list() self.assertEqual(len(deploys), 2) self.assertEqual([deploy_one['uuid'], deploy_two['uuid']], [deploy['uuid'] for deploy in deploys]) self.assertNotEqual(deploy_one['uuid'], deploy_two['uuid']) self.assertEqual(deploy_two['status'], consts.DeployStatus.DEPLOY_INIT) self.assertEqual(deploy_two['config'], {'opt2': 'val2'})
def test_deployment_list_with_status_and_name(self): deploy_one = db.deployment_create({}) deploy_two = db.deployment_create({ "config": {}, "status": consts.DeployStatus.DEPLOY_FAILED, }) deploy_three = db.deployment_create({"name": "deployment_name"}) deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_INIT) deploys.sort(key=lambda x: x["id"]) self.assertEqual(len(deploys), 2) self.assertEqual(deploys[0]["uuid"], deploy_one["uuid"]) deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_FAILED) self.assertEqual(len(deploys), 1) self.assertEqual(deploys[0]["uuid"], deploy_two["uuid"]) deploys = db.deployment_list( status=consts.DeployStatus.DEPLOY_FINISHED) self.assertEqual(len(deploys), 0) deploys = db.deployment_list(name="deployment_name") self.assertEqual(deploys[0]["uuid"], deploy_three["uuid"]) self.assertEqual(len(deploys), 1)
def test_deployment_update_several(self): # Create a deployment and update it deploy_one = db.deployment_create({}) self.assertEqual(deploy_one["config"], {}) update_deploy_one = db.deployment_update( deploy_one["uuid"], {"config": {"opt1": "val1"}}) self.assertEqual(update_deploy_one["uuid"], deploy_one["uuid"]) self.assertEqual(update_deploy_one["config"], {"opt1": "val1"}) get_deploy_one = db.deployment_get(deploy_one["uuid"]) self.assertEqual(get_deploy_one["uuid"], deploy_one["uuid"]) self.assertEqual(get_deploy_one["config"], {"opt1": "val1"}) # Create another deployment deploy_two = db.deployment_create({}) update_deploy_two = db.deployment_update( deploy_two["uuid"], {"config": {"opt2": "val2"}}) self.assertEqual(update_deploy_two["uuid"], deploy_two["uuid"]) self.assertEqual(update_deploy_two["config"], {"opt2": "val2"}) get_deploy_one_again = db.deployment_get(deploy_one["uuid"]) self.assertEqual(get_deploy_one_again["uuid"], deploy_one["uuid"]) self.assertEqual(get_deploy_one_again["config"], {"opt1": "val1"})
def test_deployment_update(self): deploy = db.deployment_create({}) self.assertEqual(deploy["config"], {}) update_deploy = db.deployment_update(deploy["uuid"], {"config": { "opt": "val" }}) self.assertEqual(update_deploy["uuid"], deploy["uuid"]) self.assertEqual(update_deploy["config"], {"opt": "val"}) get_deploy = db.deployment_get(deploy["uuid"]) self.assertEqual(get_deploy["uuid"], deploy["uuid"]) self.assertEqual(get_deploy["config"], {"opt": "val"})
def test_create(self): deployment = db.deployment_create({}) resource = db.resource_create({ 'deployment_uuid': deployment['uuid'], 'provider_name': 'fakeprovider', 'type': 'faketype', }) resources = db.resource_get_all(deployment['uuid']) self.assertTrue(resource['id']) self.assertEqual(len(resources), 1) self.assertTrue(resource['id'], resources[0]['id']) self.assertEqual(resource['deployment_uuid'], deployment['uuid']) self.assertEqual(resource['provider_name'], 'fakeprovider') self.assertEqual(resource['type'], 'faketype')
def test_create(self): deployment = db.deployment_create({}) resource = db.resource_create({ "deployment_uuid": deployment["uuid"], "provider_name": "fakeprovider", "type": "faketype", }) resources = db.resource_get_all(deployment["uuid"]) self.assertTrue(resource["id"]) self.assertEqual(len(resources), 1) self.assertTrue(resource["id"], resources[0]["id"]) self.assertEqual(resource["deployment_uuid"], deployment["uuid"]) self.assertEqual(resource["provider_name"], "fakeprovider") self.assertEqual(resource["type"], "faketype")
def test_get_all_by_provider_type(self): deployment = db.deployment_create({}) res_one = db.resource_create({ 'deployment_uuid': deployment['uuid'], 'type': 'one', }) res_two = db.resource_create({ 'deployment_uuid': deployment['uuid'], 'type': 'two', }) resources = db.resource_get_all(deployment['uuid'], type='one') self.assertEqual(len(resources), 1) self.assertEqual(res_one['id'], resources[0]['id']) resources = db.resource_get_all(deployment['uuid'], type='two') self.assertEqual(len(resources), 1) self.assertEqual(res_two['id'], resources[0]['id'])
def test_get_all_by_provider_type(self): deployment = db.deployment_create({}) res_one = db.resource_create({ "deployment_uuid": deployment["uuid"], "type": "one", }) res_two = db.resource_create({ "deployment_uuid": deployment["uuid"], "type": "two", }) resources = db.resource_get_all(deployment["uuid"], type="one") self.assertEqual(len(resources), 1) self.assertEqual(res_one["id"], resources[0]["id"]) resources = db.resource_get_all(deployment["uuid"], type="two") self.assertEqual(len(resources), 1) self.assertEqual(res_two["id"], resources[0]["id"])
def setUp(self): super(VerificationTestCase, self).setUp() self.deploy = db.deployment_create({})
def test_delete(self): deployment = db.deployment_create({}) res = db.resource_create({"deployment_uuid": deployment["uuid"]}) db.resource_delete(res["id"]) resources = db.resource_get_all(deployment["uuid"]) self.assertEqual(len(resources), 0)
def test_delete(self): deployment = db.deployment_create({}) res = db.resource_create({'deployment_uuid': deployment['uuid']}) db.resource_delete(res['id']) resources = db.resource_get_all(deployment['id']) self.assertEqual(len(resources), 0)
def setUp(self): super(TasksTestCase, self).setUp() self.deploy = db.deployment_create({})
def test_deployment_delete_is_busy(self): deployment = db.deployment_create({}) db.resource_create({'deployment_uuid': deployment['uuid']}) db.resource_create({'deployment_uuid': deployment['uuid']}) self.assertRaises(exceptions.DeploymentIsBusy, db.deployment_delete, deployment['uuid'])
def test_deployment_list(self): deploy_one = db.deployment_create({}) deploy_two = db.deployment_create({}) deploys = db.deployment_list() self.assertEqual(sorted([deploy_one['uuid'], deploy_two['uuid']]), sorted([deploy['uuid'] for deploy in deploys]))
def __init__(self, deployment=None, **attributes): if deployment: self.deployment = deployment else: self.deployment = db.deployment_create(attributes)