diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/instancespage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/instancespage.py index ad74f75280..9ba852bdb8 100644 --- a/openstack_dashboard/test/integration_tests/pages/project/compute/instancespage.py +++ b/openstack_dashboard/test/integration_tests/pages/project/compute/instancespage.py @@ -14,9 +14,8 @@ from openstack_dashboard.test.integration_tests.regions import forms from openstack_dashboard.test.integration_tests.regions import tables -class InstancesTable(tables.TableRegion): - name = "instances" - CREATE_INSTANCE_FORM_FIELDS = (( +class LaunchInstanceForm(forms.TabbedFormRegion): + field_mappings = (( "availability_zone", "name", "flavor", "count", "source_type", "instance_snapshot_id", "volume_id", "volume_snapshot_id", "image_id", "volume_size", @@ -26,12 +25,18 @@ class InstancesTable(tables.TableRegion): ("disk_config", "config_drive") ) + def __init__(self, driver, conf): + super(LaunchInstanceForm, self).__init__( + driver, conf, field_mappings=self.field_mappings) + + +class InstancesTable(tables.TableRegion): + name = "instances" + @tables.bind_table_action('launch') def launch_instance(self, launch_button): launch_button.click() - return forms.TabbedFormRegion( - self.driver, self.conf, - field_mappings=self.CREATE_INSTANCE_FORM_FIELDS) + return LaunchInstanceForm(self.driver, self.conf) @tables.bind_table_action('delete') def delete_instance(self, delete_button): diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/volumes/volumespage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/volumes/volumespage.py index caa4ec628c..250a6456d9 100644 --- a/openstack_dashboard/test/integration_tests/pages/project/compute/volumes/volumespage.py +++ b/openstack_dashboard/test/integration_tests/pages/project/compute/volumes/volumespage.py @@ -11,6 +11,8 @@ # under the License. from openstack_dashboard.test.integration_tests.pages import basepage +from openstack_dashboard.test.integration_tests.pages.project.compute \ + import instancespage from openstack_dashboard.test.integration_tests.regions import forms from openstack_dashboard.test.integration_tests.regions import tables @@ -67,6 +69,11 @@ class VolumesTable(tables.TableRegion): return forms.FormRegion(self.driver, self.conf, field_mappings=self.EXTEND_VOLUME_FORM_FIELDS) + @tables.bind_row_action('launch_volume') + def launch_volume_as_instance(self, launch_volume_button, row): + launch_volume_button.click() + return instancespage.LaunchInstanceForm(self.driver, self.conf) + @tables.bind_row_action('upload_to_image') def upload_volume_to_image(self, upload_button, row): upload_button.click() @@ -179,3 +186,17 @@ class VolumesPage(basepage.BaseNavigationPage): row = self._get_row_with_volume_name(name) size = str(row.cells[self.VOLUMES_TABLE_SIZE_COLUMN].text) return int(filter(str.isdigit, size)) + + def launch_instance(self, name, instance_name, available_zone=None): + row = self._get_row_with_volume_name(name) + instance_form = self.volumes_table.launch_volume_as_instance(row) + if available_zone is None: + available_zone = self.conf.launch_instances.available_zone + instance_form.availability_zone.value = available_zone + instance_form.name.text = instance_name + instance_form.submit() + + def get_attach_instance(self, name): + row = self._get_row_with_volume_name(name) + attach_instance = row.cells[self.VOLUMES_TABLE_ATTACHED_COLUMN].text + return attach_instance diff --git a/openstack_dashboard/test/integration_tests/tests/test_volumes.py b/openstack_dashboard/test/integration_tests/tests/test_volumes.py index 31f9711107..f6ede29843 100644 --- a/openstack_dashboard/test/integration_tests/tests/test_volumes.py +++ b/openstack_dashboard/test/integration_tests/tests/test_volumes.py @@ -156,6 +156,7 @@ class TestAdminVolumes(helpers.AdminTestCase, TestVolumes): class TestVolumesActions(helpers.TestCase): VOLUME_NAME = helpers.gen_random_resource_name("volume") IMAGE_NAME = helpers.gen_random_resource_name("image") + INSTANCE_NAME = helpers.gen_random_resource_name("instance") def setUp(self): super(TestVolumesActions, self).setUp() @@ -221,6 +222,37 @@ class TestVolumesActions(helpers.TestCase): self.volumes_page = \ self.home_pg.go_to_compute_volumes_volumespage() + def test_volume_launch_as_instance(self): + """This test case checks launch volume as instance functionality: + Steps: + 1. Launch volume as instance + 2. Check that instance is created + 3. Check that no Error messages present + 4. Check that instance status is 'active' + 5. Check that volume status is 'in use' + 6. Delete instance + """ + self.volumes_page.launch_instance(self.VOLUME_NAME, self.INSTANCE_NAME) + self.assertTrue( + self.volumes_page.find_message_and_dismiss(messages.SUCCESS)) + self.assertFalse( + self.volumes_page.find_message_and_dismiss(messages.ERROR)) + instances_page = self.home_pg.go_to_compute_instancespage() + self.assertTrue(instances_page.is_instance_active(self.INSTANCE_NAME)) + self.volumes_page = self.home_pg.go_to_compute_volumes_volumespage() + self.assertTrue(self.volumes_page.is_volume_status(self.VOLUME_NAME, + 'In-use')) + self.assertIn(self.INSTANCE_NAME, + self.volumes_page.get_attach_instance(self.VOLUME_NAME)) + instances_page = self.home_pg.go_to_compute_instancespage() + instances_page.delete_instance(self.INSTANCE_NAME) + self.assertTrue( + instances_page.find_message_and_dismiss(messages.SUCCESS)) + self.assertFalse( + instances_page.find_message_and_dismiss(messages.ERROR)) + self.assertTrue(instances_page.is_instance_deleted(self.INSTANCE_NAME)) + self.volumes_page = self.home_pg.go_to_compute_volumes_volumespage() + def tearDown(self): self.volumes_page.delete_volume(self.VOLUME_NAME) self.assertTrue(