def test_use_vlan_tagging(self): """Use VLAN tagging for floating network Scenario: 1. Enable public VLAN tagging 2. Enter value in this field 3. Verify that floating VLAN tagging is selected and value is the same as for public VLAN 4. Click save settings 5. Verify that changes are saved """ value = '112' with Networks().public as n: n.vlan_tagging.click() n.vlan_id.send_keys(value) with Networks().floating as n: self.assertTrue( n.vlan_tagging.find_element_by_tag_name('input').is_selected()) self.assertEqual(n.vlan_id.get_attribute('value'), value) Networks().save_settings.click() time.sleep(1) self.refresh() with Networks().floating as n: self.assertTrue( n.vlan_tagging.find_element_by_tag_name('input').is_selected()) self.assertEqual(n.vlan_id.get_attribute('value'), value)
def _test_ranges(self, network, values): with getattr(Networks(), network) as n: n.ip_ranges[0].icon_plus.click() n.ip_ranges[0].start.clear() n.ip_ranges[0].start.send_keys(values[0][0]) n.ip_ranges[0].end.clear() n.ip_ranges[0].end.send_keys(values[0][1]) n.ip_ranges[1].start.send_keys(values[1][0]) n.ip_ranges[1].end.send_keys(values[1][1]) self._save_settings() with getattr(Networks(), network) as n: self.assertEqual(n.ip_ranges[0].start.get_attribute('value'), values[0][0]) self.assertEqual(n.ip_ranges[0].end.get_attribute('value'), values[0][1]) self.assertEqual(n.ip_ranges[1].start.get_attribute('value'), values[1][0]) self.assertEqual(n.ip_ranges[1].end.get_attribute('value'), values[1][1]) n.ip_ranges[0].start.clear() n.ip_ranges[0].start.send_keys(' ') self.assertIn( 'Invalid IP range start', n.ip_ranges[0].start.find_element_by_xpath('../../..').text) n.ip_ranges[1].end.clear() n.ip_ranges[1].end.send_keys(' ') self.assertIn( 'Invalid IP range end', n.ip_ranges[1].end.find_element_by_xpath('../../..').text)
def turn_on(): with getattr(Networks(), network) as n: n.vlan_tagging.click() self.assertTrue(n.vlan_id.is_displayed(), 'vlan id input is visible') n.vlan_id.send_keys(vlan_id) time.sleep(0.5) self._save_settings() assert_on() with getattr(Networks(), network) as n: n.vlan_id.clear() n.vlan_id.send_keys(' ') self.assertIn('Invalid VLAN ID', n.vlan_id.find_element_by_xpath('../../..').text) self._assert_save_verify_disabled()
def _test_select_field(self, network, field, value): with getattr(Networks(), network) as n: getattr(n, field).select_by_visible_text(value) self._save_settings() with getattr(Networks(), network) as n: self.assertEqual( getattr(n, field).first_selected_option.text, value, 'New value') getattr(n, field).options[0].click() Networks().cancel_changes.click() time.sleep(1) with getattr(Networks(), network) as n: self.assertEqual( getattr(n, field).first_selected_option.text, value, "cancel changes")
def test_two_nodes(self): """Verify network with two added nodes Scenario: 1. Add two compute nodes 2. Open Networks tab 3. Click Verify Networks 4. Verify that message 'Verification succeeded. Your network is configured correctly' appears """ Tabs().nodes.click() time.sleep(1) Nodes().add_nodes.click() time.sleep(1) Nodes().nodes_discovered[0].checkbox.click() Nodes().nodes_discovered[1].checkbox.click() RolesPanel().compute.click() Nodes().apply_changes.click() time.sleep(1) Tabs().networks.click() time.sleep(1) with Networks() as n: n.verify_networks.click() self.assertIn( 'Verification succeeded. ' 'Your network is configured correctly.', n.verification_alert.text, 'Verification succeeded')
def test_vlan_id_labels_visibility(self): """Checking vlan id label when vlan tagging is disabled Scenario: 1. Open Networks tab 2. Disable vlan tagging for Management, Storage, VM(Fixed) 3. Open Nodes tab 4. Select controller node 5. Click configure interfaces 6. Verify that 'Vlan Id' isn't visible on Storage, Management, VM(Fixed) network boxes """ label = 'VLAN ID' Tabs().networks.click() with Networks() as n: n.management.vlan_tagging.click() n.storage.vlan_tagging.click() n.fixed.vlan_tagging.click() n.save_settings.click() time.sleep(1) Tabs().nodes.click() Nodes().nodes[0].details.click() NodeInfo().edit_networks.click() with InterfacesSettings() as s: self.assertNotIn(label, s.interfaces[0].networks['storage'].text, 'vlan id is visible. Storage network') self.assertNotIn(label, s.interfaces[0].networks['management'].text, 'vlan id is visible. Management network') self.assertNotIn(label, s.interfaces[0].networks['vm (fixed)'].text, 'vlan id is visible. VM (Fixed) network')
def test_neutron_vlan(self): """Create environment with Neutron VLAN network Scenario: 1. Create environment with Neutron VLAN network 2. Click on created environment 3. Open networks tab 4. Verify Neutron parameters are displayed and Neutron with vlan segmentation text is displayed """ with Wizard() as w: w.name.send_keys(OPENSTACK_CENTOS) w.release.select_by_visible_text(OPENSTACK_RELEASE_CENTOS) for i in range(3): w.next.click() w.network_neutron_vlan.click() for i in range(3): w.next.click() w.create.click() w.wait_until_exists() cb = Environments().create_cluster_boxes[0] cb.click() Tabs().networks.click() with Networks() as n: self.assertEqual(n.segmentation_type.text, 'Neutron with vlan segmentation') self.assertTrue(NeutronParameters().parent.is_displayed())
def assert_on(): with getattr(Networks(), network) as n: self.assertTrue( n.vlan_tagging.find_element_by_tag_name( 'input').is_selected(), 'use vlan tagging is turned on') self.assertEqual(n.vlan_id.get_attribute('value'), vlan_id, 'vlan id value')
def turn_off(): with getattr(Networks(), network) as n: n.vlan_tagging.click() self.assertFalse(n.vlan_id.is_displayed(), 'vlan id input is not visible') time.sleep(0.5) self._save_settings() assert_off()
def assert_off(): with getattr(Networks(), network) as n: self.assertFalse( n.vlan_tagging.find_element_by_tag_name( 'input').is_selected(), 'use vlan tagging is turned off') self.assertFalse(n.vlan_id.is_displayed(), 'vlan id input is not visible')
def _test_text_field(self, network, field, value): with getattr(Networks(), network) as n: getattr(n, field).clear() getattr(n, field).send_keys(value) self._save_settings() with getattr(Networks(), network) as n: self.assertEqual( getattr(n, field).get_attribute('value'), value, 'New value') getattr(n, field).clear() getattr(n, field).send_keys(' ') self.assertIn( 'Invalid', getattr(n, field).find_element_by_xpath('../../..').text) self._assert_save_verify_disabled() Networks().cancel_changes.click() time.sleep(1) with getattr(Networks(), network) as n: self.assertEqual( getattr(n, field).get_attribute('value'), value, "cancel changes")
def test_no_nodes(self): """Verify network without added nodes Scenario: 1. Click Verify Networks 2. Verify that message 'At least two nodes are required' appears """ with Networks() as n: n.verify_networks.click() self.assertIn( 'At least two nodes are required', n.verification_alert.text, 'Alert text contains "At least two nodes are required"')
def test_default_settings(self): """Create default environment Scenario: 1. Create environment with default values 2. Click on created environment 3. Verify that correct environment name is displayed 4. Click on information icon and verify all information is displayed correctly 5. Verify all info on Networks and Settings tab """ with Wizard() as w: w.name.send_keys(OPENSTACK_CENTOS) w.release.select_by_visible_text(OPENSTACK_RELEASE_CENTOS) for i in range(6): w.next.click() w.create.click() w.wait_until_exists() cb = Environments().create_cluster_boxes[0] self.assertIn(OPENSTACK_CENTOS, cb.text) cb.click() with Nodes() as n: time.sleep(1) self.assertEqual(n.env_name.text, OPENSTACK_CENTOS) n.info_icon.click() self.assertIn('display: block;', n.env_details.get_attribute('style')) self.assertIn(OPENSTACK_CENTOS, n.env_details.text) self.assertIn('New', n.env_details.text) self.assertIn('Multi-node', n.env_details.text) self.assertNotIn('with HA', n.env_details.text) n.info_icon.click() self.assertIn('display: none;', n.env_details.get_attribute('style')) Tabs().networks.click() with Networks() as n: self.assertTrue(n.flatdhcp_manager. find_element_by_tag_name('input').is_selected()) Tabs().settings.click() with Settings() as s: self.assertFalse(s.install_savanna. find_element_by_tag_name('input').is_selected()) self.assertFalse(s.install_murano. find_element_by_tag_name('input').is_selected()) self.assertFalse(s.install_ceilometer. find_element_by_tag_name('input').is_selected()) self.assertTrue(s.hypervisor_qemu. find_element_by_tag_name('input').is_selected()) pass
def _test_ranges_minus_icon(self, network): with getattr(Networks(), network) as n: for i in range(3): n.ip_ranges[i].icon_plus.click() n.ip_ranges[3].icon_minus.click() self.assertEqual(len(n.ip_ranges), 3, 'Minus icon. last row') n.ip_ranges[2].start.send_keys(RANGES[0][0]) n.ip_ranges[2].end.send_keys(RANGES[0][1]) n.ip_ranges[1].icon_minus.click() self.assertEqual(len(n.ip_ranges), 2, 'Minus icon. second row') self.assertEqual(n.ip_ranges[1].start.get_attribute('value'), RANGES[0][0]) self.assertEqual(n.ip_ranges[1].end.get_attribute('value'), RANGES[0][1])
def test_name_servers(self): """Change dns servers Scenario: 1. Change dns servers value 2. Click save settings 3. Verify that values are saved 5. Clear values for dns servers 6. Verify that Save settings and Verify networks are disabled """ v1 = '8.7.7.7' v2 = '8.6.6.6' with Networks() as n: n.dns1.clear() n.dns1.send_keys(v1) n.dns2.clear() n.dns2.send_keys(v2) self._save_settings() with Networks() as n: self.assertEqual(n.dns1.get_attribute('value'), v1, 'dns1') self.assertEqual(n.dns1.get_attribute('value'), v1, 'dns2') n.dns1.clear() n.dns1.send_keys(' ') self.assertIn('Invalid nameserver', n.dns1.find_element_by_xpath('../../..').text) n.dns2.clear() n.dns2.send_keys(' ') self.assertIn('Invalid nameserver', n.dns2.find_element_by_xpath('../../..').text) self._assert_save_verify_disabled() Networks().cancel_changes.click() self.assertEqual(n.dns1.get_attribute('value'), v1, 'cancel changes dns1') self.assertEqual(n.dns1.get_attribute('value'), v1, 'cancel changes dns2')
def setUpClass(cls): """Global precondition Steps: 1. Create simple environment with default values 2. Click on created environment and open networks tab 3. Select VLAN Manager and save settings """ BaseTestCase.setUpClass() preconditions.Environment.simple_flat() Tabs().networks.click() with Networks() as n: n.vlan_manager.click() n.save_settings.click() time.sleep(1)
def _test_ranges_plus_icon(self, network): with getattr(Networks(), network) as n: n.ip_ranges[0].icon_plus.click() self.assertEqual(len(n.ip_ranges), 2, 'Plus icon. row 1') n.ip_ranges[1].icon_plus.click() self.assertEqual(len(n.ip_ranges), 3, 'Plus icon. row 2') n.ip_ranges[1].start.send_keys(RANGES[0][0]) n.ip_ranges[1].end.send_keys(RANGES[0][1]) n.ip_ranges[0].icon_plus.click() self.assertEqual(len(n.ip_ranges), 4, 'Plus icon. row 1') self.assertEqual(n.ip_ranges[1].start.get_attribute('value'), '') self.assertEqual(n.ip_ranges[1].end.get_attribute('value'), '') self.assertEqual(n.ip_ranges[2].start.get_attribute('value'), RANGES[0][0]) self.assertEqual(n.ip_ranges[2].end.get_attribute('value'), RANGES[0][1])
def test_fixed_vlan_range_end_calculation(self): """Check calculation of VLAN id end Scenario: 1. Enter new value in VLAN id start field 2. Click save settings 3. Verify that value in VLAN id end equals to VLAN id start plus number of networks minus 1 """ start_values = [105, 120] with Networks().fixed as n: number = int(n.number_of_networks.get_attribute('value')) for v in start_values: n.vlan_id.clear() n.vlan_id.send_keys(v) self.assertEqual(n.vlan_end.get_attribute('value'), str(v + number - 1), 'end value')
def test_fixed_vlan_range_end_calculation_2(self): """Check calculation of VLAN id end when number of networks is changed Scenario: 1. Enter new value in number of networks field 2. Click save settings 3. Verify that value in VLAN id end equals to VLAN id start plus number of networks minus 1 """ numbers = [5, 20] with Networks().fixed as n: start = int(n.vlan_id.get_attribute('value')) for v in numbers: n.number_of_networks.clear() n.number_of_networks.send_keys(v) self.assertEqual(n.vlan_end.get_attribute('value'), str(v + start - 1), 'end value')
def test_vlan_id_values(self): """Checking correctness of vlan id on Networks tab Scenario: 1. Open Networks tab 2. Enable vlan tagging for Management, Storage, VM(Fixed) and enter values in range from 110 to 200 3. Open Nodes tab 4. Select controller node 5. Click configure interfaces 6. Verify that 'Vlan Id' values are correct on Storage, Management, VM(Fixed) network boxes """ label = 'VLAN ID: {0}' vlans = [random.randint(110, 200) for i in range(3)] Tabs().networks.click() with Networks() as n: n.management.vlan_id.clear() n.management.vlan_id.send_keys(vlans[0]) n.storage.vlan_id.clear() n.storage.vlan_id.send_keys(vlans[1]) n.fixed.vlan_id.clear() n.fixed.vlan_id.send_keys(vlans[2]) n.save_settings.click() time.sleep(1) Tabs().nodes.click() Nodes().nodes[0].details.click() NodeInfo().edit_networks.click() with InterfacesSettings() as s: self.assertIn( label.format(vlans[0]), s.interfaces[0]. networks['management'].text, 'vlan id is correct. Management network') self.assertIn( label.format(vlans[1]), s.interfaces[0]. networks['storage'].text, 'vlan id is correct. Storage network') self.assertIn( label.format(vlans[2]), s.interfaces[0]. networks['vm (fixed)'].text, 'vlan id is correct. VM (Fixed) network')
def test_one_node(self): """Verify network with one added nodes Scenario: 1. Add one controller node 2. Open Networks tab 3. Click Verify Networks 4. Verify that message 'At least two nodes are required' appears """ Tabs().nodes.click() time.sleep(1) Nodes().add_nodes.click() time.sleep(1) Nodes().nodes_discovered[0].checkbox.click() RolesPanel().controller.click() Nodes().apply_changes.click() time.sleep(1) Tabs().networks.click() time.sleep(1) with Networks() as n: n.verify_networks.click() self.assertIn( 'At least two nodes are required', n.verification_alert.text, 'Alert text contains "At least two nodes are required"')
def _assert_save_cancel_disabled(self): self.assertFalse(Networks().save_settings.is_enabled(), 'Save settings is disabled') self.assertFalse(Networks().cancel_changes.is_enabled(), 'Cancel changes is disabled')
def _assert_save_verify_disabled(self): self.assertFalse(Networks().save_settings.is_enabled(), 'Save settings is disabled') self.assertFalse(Networks().verify_networks.is_enabled(), 'Verify networks is disabled')
def _save_settings(self): Networks().save_settings.click() time.sleep(1) self._assert_save_cancel_disabled() self.refresh()