def test_installer_check_services(self): """@Test: Services 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 """ services = ( 'elasticsearch', 'foreman-proxy', 'foreman-tasks', 'httpd', 'mongod', 'postgresql', 'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers', 'qdrouterd', 'qpidd', 'tomcat', ) # check `services` status using service command if get_host_info()[1] >= 7: status_format = 'systemctl status {0}' else: status_format = 'service {0} status' for service in services: 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( get_server_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 izip( *[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) )