diff --git a/.travis.yml b/.travis.yml index 032b4f47aeb..d8e6f96ea15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,7 +99,7 @@ env: smoke/misc/test_vm_sync" - TESTS="component/find_hosts_for_migration - component/test_accounts + smoke/test_accounts component/test_acl_isolatednetwork_delete component/test_acl_listsnapshot component/test_acl_listvm @@ -124,28 +124,30 @@ env: component/test_non_contiguous_vlan component/test_persistent_networks" - - TESTS="component/test_projects + - TESTS="smoke/test_projects component/test_project_configs component/test_project_usage - component/test_regions + smoke/test_regions component/test_regions_accounts component/test_routers component/test_snapshots" - TESTS="component/test_project_limits - component/test_resource_limits" + component/test_resource_limits + smoke/test_host_maintenance" - TESTS="component/test_stopped_vm component/test_tags component/test_templates component/test_update_vm - component/test_usage" + smoke/test_usage" - TESTS="component/test_volumes component/test_vpc_network component/test_vpc_offerings component/test_vpn_users" + # FIXME: fix following tests and include them in Travis # - TESTS="component/test_affinity_groups_projects" # - TESTS="component/test_allocation_states" diff --git a/test/integration/component/test_regions.py b/test/integration/component/test_regions.py deleted file mode 100644 index 38b96d59bcd..00000000000 --- a/test/integration/component/test_regions.py +++ /dev/null @@ -1,139 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from marvin.cloudstackTestCase import * -from marvin.cloudstackAPI import * -from marvin.lib.utils import * -from marvin.lib.base import * -from marvin.lib.common import * -from nose.plugins.attrib import attr -from random import choice - -class Services: - def __init__(self): - self.services = { - "region": { - "regionid": "2", - "regionname": "Region2", - "regionendpoint": "http://region2:8080/client" - } - } - -class TestRegions(cloudstackTestCase): - """Test Regions - CRUD tests for regions - """ - - @classmethod - def setUpClass(cls): - cls.api_client = super(TestRegions, cls).getClsTestClient().getApiClient() - cls.services = Services().services - cls.domain = get_domain(cls.api_client) - cls.cleanup = [] - return - - def setUp(self): - pseudo_random_int = choice(xrange(2, 200)) - self.services["region"]["regionid"] = pseudo_random_int - self.services["region"]["regionname"] = "region" + str(pseudo_random_int) - self.services["region"]["regionendpoint"] = "http://region" + str(pseudo_random_int) + ":8080/client" - - self.region = Region.create(self.api_client, - self.services["region"] - ) - self.cleanup = [] - self.cleanup.append(self.region) - - list_region = Region.list(self.api_client, - id=self.services["region"]["regionid"] - ) - - self.assertEqual( - isinstance(list_region, list), - True, - msg="Region creation failed" - ) - - @attr(tags=["simulator", "basic", "advanced"], required_hardware="false") - def test_createRegionWithExistingRegionId(self): - """Test for duplicate checks on region id - """ - self.services["region"]["regionname"] = random_gen() #alter region name but not id - self.assertRaises(Exception, Region.create, self.api_client, self.services["region"]) - - @attr(tags=["simulator", "basic", "advanced"], required_hardware="false") - def test_createRegionWithExistingRegionName(self): - """Test for duplicate checks on region name - """ - random_int = choice(xrange(2, 200)) - self.services["region"]["regionid"] = random_int #alter id but not name - self.services["region"]["regionendpoint"] = "http://region" + str(random_int) + ":8080/client" - self.assertRaises(Exception, Region.create, self.api_client, self.services["region"]) - - @attr(tags=["simulator", "basic", "advanced"], required_hardware="false") - def test_updateRegion(self): - """ Test for update Region - """ - self.services["region"]["regionname"] = "Region3" + random_gen() - self.services["region"]["regionendpoint"] = "http://region3updated:8080/client" - - updated_region = self.region.update(self.api_client, - self.services["region"] - ) - - list_region = Region.list(self.api_client, - id=self.services["region"]["regionid"] - ) - - self.assertEqual( - isinstance(list_region, list), - True, - "Check for list Region response" - ) - region_response = list_region[0] - - self.assertEqual( - region_response.id, - updated_region.id, - "listRegion response does not match with region Id created" - ) - - self.assertEqual( - region_response.name, - updated_region.name, - "listRegion response does not match with region name created" - ) - self.assertEqual( - region_response.endpoint, - updated_region.endpoint, - "listRegion response does not match with region endpoint created" - ) - - def tearDown(self): - """ Test for delete region as cleanup - """ - try: - #Clean up - cleanup_resources(self.api_client, self.cleanup) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) - - @classmethod - def tearDownClass(cls): - """ - Nothing to do - """ - pass diff --git a/test/integration/component/test_accounts.py b/test/integration/smoke/test_accounts.py similarity index 100% rename from test/integration/component/test_accounts.py rename to test/integration/smoke/test_accounts.py diff --git a/test/integration/component/test_host_maintenance.py b/test/integration/smoke/test_host_maintenance.py similarity index 100% rename from test/integration/component/test_host_maintenance.py rename to test/integration/smoke/test_host_maintenance.py diff --git a/test/integration/component/test_projects.py b/test/integration/smoke/test_projects.py similarity index 100% rename from test/integration/component/test_projects.py rename to test/integration/smoke/test_projects.py diff --git a/test/integration/smoke/test_regions.py b/test/integration/smoke/test_regions.py index 7b0dec3c6ee..a6823c6ea35 100644 --- a/test/integration/smoke/test_regions.py +++ b/test/integration/smoke/test_regions.py @@ -21,28 +21,53 @@ from marvin.lib.utils import * from marvin.lib.base import * from marvin.lib.common import * from nose.plugins.attrib import attr +from random import choice + +class Services: + def __init__(self): + self.services = { + "region": { + "regionid": "2", + "regionname": "Region2", + "regionendpoint": "http://region2:8080/client" + } + } class TestRegions(cloudstackTestCase): """Test Regions - basic region creation """ + def setUp(self): + testClient = super(TestRegions, self).getClsTestClient() + self.apiclient = testClient.getApiClient() + self.services = testClient.getParsedTestDataConfig() - @classmethod - def setUpClass(cls): - testClient = super(TestRegions, cls).getClsTestClient() - cls.apiclient = testClient.getApiClient() - cls.services = testClient.getParsedTestDataConfig() + self.domain = get_domain(self.apiclient) + self.cleanup = [] + pseudo_random_int = choice(xrange(2, 200)) + self.services["region"]["regionid"] = pseudo_random_int + self.services["region"]["regionname"] = "region" + str(pseudo_random_int) + self.services["region"]["regionendpoint"] = "http://region" + str(pseudo_random_int) + ":8080/client" - cls.domain = get_domain(cls.apiclient) - cls.cleanup = [] + self.region = Region.create(self.apiclient, + self.services["region"] + ) + self.cleanup = [] + self.cleanup.append(self.region) + + list_region = Region.list(self.apiclient, + id=self.services["region"]["regionid"] + ) + + self.assertEqual( + isinstance(list_region, list), + True, + msg="Region creation failed" + ) @attr(tags=["basic", "advanced"], required_hardware="false") def test_createRegion(self): """ Test for create region """ - region = Region.create(self.apiclient, - self.services["region"] - ) - list_region = Region.list(self.apiclient, id=self.services["region"]["regionid"] ) @@ -53,9 +78,9 @@ class TestRegions(cloudstackTestCase): "Check for list Region response" ) region_response = list_region[0] - + id = self.services["region"]["regionid"] self.assertEqual( - str(region_response.id), + region_response.id, self.services["region"]["regionid"], "listRegion response does not match with region Id created" ) @@ -70,15 +95,67 @@ class TestRegions(cloudstackTestCase): self.services["region"]["regionendpoint"], "listRegion response does not match with region endpoint created" ) - self.cleanup.append(region) - return - @classmethod - def tearDownClass(cls): + @attr(tags=["simulator", "basic", "advanced"], required_hardware="false") + def test_createRegionWithExistingRegionId(self): + """Test for duplicate checks on region id + """ + self.services["region"]["regionname"] = random_gen() # alter region name but not id + self.assertRaises(Exception, Region.create, self.apiclient, self.services["region"]) + + @attr(tags=["simulator", "basic", "advanced"], required_hardware="false") + def test_createRegionWithExistingRegionName(self): + """Test for duplicate checks on region name + """ + random_int = choice(xrange(2, 200)) + self.services["region"]["regionid"] = random_int # alter id but not name + self.services["region"]["regionendpoint"] = "http://region" + str(random_int) + ":8080/client" + self.assertRaises(Exception, Region.create, self.apiclient, self.services["region"]) + + @attr(tags=["simulator", "basic", "advanced"], required_hardware="false") + def test_updateRegion(self): + """ Test for update Region + """ + self.services["region"]["regionname"] = "Region3" + random_gen() + self.services["region"]["regionendpoint"] = "http://region3updated:8080/client" + + updated_region = self.region.update(self.apiclient, + self.services["region"] + ) + + list_region = Region.list(self.apiclient, + id=self.services["region"]["regionid"] + ) + + self.assertEqual( + isinstance(list_region, list), + True, + "Check for list Region response" + ) + region_response = list_region[0] + + self.assertEqual( + region_response.id, + updated_region.id, + "listRegion response does not match with region Id created" + ) + + self.assertEqual( + region_response.name, + updated_region.name, + "listRegion response does not match with region name created" + ) + self.assertEqual( + region_response.endpoint, + updated_region.endpoint, + "listRegion response does not match with region endpoint created" + ) + + def tearDown(self): + """ Test for delete region as cleanup + """ try: #Clean up - cleanup_resources(cls.apiclient, cls.cleanup) - list_region = Region.list(cls.apiclient, id=cls.services["region"]["regionid"]) - assert list_region is None, "Region deletion fails" + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: - raise Exception("Warning: Region cleanup/delete fails with : %s" % e) + raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/component/test_usage.py b/test/integration/smoke/test_usage.py similarity index 100% rename from test/integration/component/test_usage.py rename to test/integration/smoke/test_usage.py