def test_cat_fail(self, ssh): ssh.command = mock.MagicMock( return_value=FakeSSHResult([], 1, 'stderr')) with pytest.raises( HostInfoError, match=r'.*Not able to cat /etc/redhat-release "stderr".*'): get_host_info()
def test_cat_fail(self, ssh): ssh.command = mock.MagicMock( return_value=FakeSSHResult([], 1, 'stderr')) with self.assertRaises(HostInfoError) as context: get_host_info() self.assertEqual(str(context.exception), 'Not able to cat /etc/redhat-release "stderr"')
def test_release_parse_fail(self, ssh): ssh.command = mock.MagicMock(return_value=FakeSSHResult([''], 0)) with self.assertRaises(HostInfoError) as context: get_host_info() if six.PY2: message = context.exception.message else: message = str(context.exception) self.assertEqual(message, 'Not able to parse release string ""')
def test_cat_fail(self, ssh): ssh.command = mock.MagicMock( return_value=FakeSSHResult([], 1, 'stderr')) with self.assertRaises(HostInfoError) as context: get_host_info() self.assertEqual( str(context.exception), 'Not able to cat /etc/redhat-release "stderr"' )
def test_positive_check_installer_services(self): """Check if services start correctly :id: 85fd4388-6d94-42f5-bed2-24be38e9f104 :expectedresults: All services {'elasticsearch', 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers', 'qdrouterd', 'qpidd', 'tomcat'} are started """ major_version = get_host_info()[1] services = ( 'elasticsearch', 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers', 'qdrouterd', 'qpidd', 'tomcat6' if major_version == RHEL_6_MAJOR_VERSION else 'tomcat', ) # check `services` status using service command if major_version >= RHEL_7_MAJOR_VERSION: status_format = 'systemctl status {0}' else: status_format = 'service {0} status' for service in services: result = ssh.command(status_format.format(service)) if (major_version == RHEL_6_MAJOR_VERSION and service is 'qpidd' and not bz_bug_is_open(1246152)): # This is a note to fix this test once Bug 1246152 is fixed self.fail('Bug 1246152 is fixed. Fix Me.') else: continue self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # check status reported by hammer ping command result = ssh.command(u'hammer -u {0[0]} -p {0[1]} ping'.format( settings.server.get_credentials() )) # iterate over the lines grouping every 3 lines # example [1, 2, 3, 4, 5, 6] will return [(1, 2, 3), (4, 5, 6)] for service, status, server_response in zip( *[iter(result.stdout)] * 3): service = service.replace(':', '').strip() status = status.split(':')[1].strip().lower() server_response = server_response.split(':', 1)[1].strip() self.assertEqual( status, 'ok', '{0} responded with {1}'.format(service, server_response) )
def test_positive_check_installer_services(self): """Check if services start correctly @Feature: Installer @Assert: All services {'elasticsearch', 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers', 'qdrouterd', 'qpidd', 'tomcat'} are started """ major_version = get_host_info()[1] services = ( 'elasticsearch', 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers', 'qdrouterd', 'qpidd', 'tomcat6' if major_version == RHEL_6_MAJOR_VERSION else 'tomcat', ) # check `services` status using service command if major_version >= RHEL_7_MAJOR_VERSION: status_format = 'systemctl status {0}' else: status_format = 'service {0} status' for service in services: result = ssh.command(status_format.format(service)) if (major_version == RHEL_6_MAJOR_VERSION and service is 'qpidd' and not bz_bug_is_open(1246152)): # This is a note to fix this test once Bug 1246152 is fixed self.fail('Bug 1246152 is fixed. Fix Me.') else: continue self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # check status reported by hammer ping command result = ssh.command(u'hammer -u {0[0]} -p {0[1]} ping'.format( settings.server.get_credentials())) # iterate over the lines grouping every 3 lines # example [1, 2, 3, 4, 5, 6] will return [(1, 2, 3), (4, 5, 6)] for service, status, server_response in zip(*[iter(result.stdout)] * 3): service = service.replace(':', '').strip() status = status.split(':')[1].strip().lower() server_response = server_response.split(':', 1)[1].strip() self.assertEqual( status, 'ok', '{0} responded with {1}'.format(service, server_response))
def test_rhel_info(self, ssh): ssh.command = mock.MagicMock(return_value=FakeSSHResult( ['Red Hat Enterprise Linux Server release 7.1 (Maipo)'], 0 )) self.assertTupleEqual( get_host_info(), ('Red Hat Enterprise Linux Server', 7, 1) )
def setUpClass(cls): """Create an organization and product which can be re-used in tests.""" super(DockerUnixSocketContainerTestCase, cls).setUpClass() cls.host_info = get_host_info() cls.organization = entities.Organization().create() cls.cr_internal = entities.DockerComputeResource( name=gen_string('alpha'), organization=[cls.organization], url=settings.docker.get_unix_socket_url(), ).create()
def test_positive_check_installer_services(self): """Check if services start correctly :id: 85fd4388-6d94-42f5-bed2-24be38e9f104 :expectedresults: All services {'elasticsearch', 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers', 'qdrouterd', 'qpidd', 'tomcat'} are started """ major_version = get_host_info()[1] services = ( 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_streamer', 'pulp_workers', 'qdrouterd', 'qpidd', 'smart_proxy_dynflow_core', 'squid', 'tomcat6' if major_version == RHEL_6_MAJOR_VERSION else 'tomcat', ) # check `services` status using service command if major_version >= RHEL_7_MAJOR_VERSION: status_format = 'systemctl status {0}' else: status_format = 'service {0} status' for service in services: with self.subTest(service): result = ssh.command(status_format.format(service)) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # check status reported by hammer ping command result = ssh.command(u'hammer -u {0[0]} -p {0[1]} ping'.format( settings.server.get_credentials() )) # iterate over the lines grouping every 3 lines # example [1, 2, 3, 4, 5, 6] will return [(1, 2, 3), (4, 5, 6)] for service, status, response in zip(*[iter(result.stdout)] * 3): service = service.replace(':', '').strip() status = status.split(':')[1].strip().lower() response = response.split(':', 1)[1].strip() self.assertEqual( status, 'ok', '{0} responded with {1}'.format(service, response) )
def get_server_distro(): # type: () -> str global _server_distro if _server_distro is None: _, major, _ = get_host_info() _server_distro = MAJOR_VERSION_DISTRO[major] return _server_distro
def test_rhel_info(self, ssh): ssh.command = mock.MagicMock(return_value=FakeSSHResult( ['Red Hat Enterprise Linux Server release 7.1 (Maipo)'], 0)) self.assertTupleEqual(get_host_info(), ('Red Hat Enterprise Linux Server', 7, 1))
def test_fedora_info(self, ssh): ssh.command = mock.MagicMock( return_value=FakeSSHResult(['Fedora release 20 (Heisenbug)'], 0)) self.assertTupleEqual(get_host_info(), ('Fedora', 20, None))
def test_fedora_info(self, ssh): ssh.command = mock.MagicMock(return_value=FakeSSHResult( ['Fedora release 20 (Heisenbug)'], 0 )) self.assertTupleEqual(get_host_info(), ('Fedora', 20, None))
def test_release_parse_fail(self, ssh): ssh.command = mock.MagicMock(return_value=FakeSSHResult([''], 0)) with pytest.raises(HostInfoError, match=r'.*Not able to parse release string "".*'): get_host_info()