Exemple #1
0
def run(test, params, env):
    """
    Logs guest's hostname.
    1) Decide whether use host/guest
    2) Check current service status
    3) Start (Stop) $service
    4) Check status of $service
    5) Stop (Start) $service
    6) Check service status

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    if params.get('test_on_guest') == "yes":
        # error_context.context() is common method to log test steps used to verify
        # what exactly was tested.
        error_context.context("Using guest.", logging.info)
        vm = env.get_vm(params["main_vm"])
        session = vm.wait_for_login()
        # RemoteRunner is object, which simulates the utils.run() behavior
        # on remote consoles
        runner = remote.RemoteRunner(session=session).run
    else:
        error_context.context("Using host", logging.info)
        runner = process.run

    error_context.context("Initialize service manager", logging.info)
    service = SpecificServiceManager(params["test_service"], runner)

    error_context.context("Testing service %s" % params["test_service"],
                          logging.info)
    original_status = service.status()
    logging.info("Original status=%s", original_status)

    if original_status is True:
        service.stop()
        time.sleep(5)
        if service.status() is not False:
            logging.error("Fail to stop service")
            service.start()
            raise exceptions.TestFail("Fail to stop service")
        service.start()
    else:
        service.start()
        time.sleep(5)
        if service.status() is not True:
            logging.error("Fail to start service")
            service.stop()
            raise exceptions.TestFail("Fail to start service")
        service.start()
    time.sleep(5)
    if not service.status() is original_status:
        raise exceptions.TestFail("Fail to restore original status of the %s "
                                  "service" % params["test_service"])
Exemple #2
0
def run(test, params, env):
    """
    Logs guest's hostname.
    1) Decide whether use host/guest
    2) Check current service status
    3) Start (Stop) $service
    4) Check status of $service
    5) Stop (Start) $service
    6) Check service status

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    if params.get('test_on_guest') == "yes":
        # error_context.context() is common method to log test steps used to verify
        # what exactly was tested.
        error_context.context("Using guest.", logging.info)
        vm = env.get_vm(params["main_vm"])
        session = vm.wait_for_login()
        # RemoteRunner is object, which simulates the utils.run() behavior
        # on remote consoles
        runner = remote.RemoteRunner(session=session).run
    else:
        error_context.context("Using host", logging.info)
        runner = process.run

    error_context.context("Initialize service manager", logging.info)
    service = SpecificServiceManager(params["test_service"], runner)

    error_context.context("Testing service %s" %
                          params["test_service"], logging.info)
    original_status = service.status()
    logging.info("Original status=%s", original_status)

    if original_status is True:
        service.stop()
        time.sleep(5)
        if service.status() is not False:
            logging.error("Fail to stop service")
            service.start()
            raise exceptions.TestFail("Fail to stop service")
        service.start()
    else:
        service.start()
        time.sleep(5)
        if service.status() is not True:
            logging.error("Fail to start service")
            service.stop()
            raise exceptions.TestFail("Fail to start service")
        service.start()
    time.sleep(5)
    if not service.status() is original_status:
        raise exceptions.TestFail("Fail to restore original status of the %s "
                                  "service" % params["test_service"])
Exemple #3
0
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        config_file = self.datadir + '/services.cfg'
        parser.read(config_file)
        services_list = parser.get(detected_distro.name, 'services').split(',')
        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
        else:
            services_list.extend(['rtas_errd'])
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        config_file = self.datadir + '/services.cfg'
        parser.read(config_file)
        services_list = parser.get(detected_distro.name, 'services').split(',')
        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
        else:
            services_list.extend(['rtas_errd'])
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        parser.read(self.get_data('services.cfg'))
        services_list = parser.get(detected_distro.name, 'services').split(',')

        smm = SoftwareManager()
        deps = []

        if detected_distro.name == 'SuSE':
            deps.extend(['ppc64-diag', 'libvirt-daemon'])
            if detected_distro.version >= 15:
                services_list.append('firewalld')
            else:
                services_list.append('SuSEfirewall2')

        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel(' %s is needed for the test to be run' % package)

        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
            if os.path.exists('/proc/device-tree/bmc'):
                services_list.remove('opal_errd')
        else:
            services_list.extend(['rtas_errd'])
        if 'Ubuntu' in detected_distro.name:
            if detected_distro.version >= 17:
                services_list.remove('networking')
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        parser.read(self.get_data('services.cfg'))
        services_list = parser.get(detected_distro.name, 'services').split(',')

        smm = SoftwareManager()
        deps = []

        if detected_distro.name == 'SuSE':
            deps.extend(['ppc64-diag', 'libvirt-daemon'])
            if detected_distro.version >= 15:
                services_list.append('firewalld')
            else:
                services_list.append('SuSEfirewall2')
        elif detected_distro.name == 'Ubuntu':
            deps.extend(['opal-prd'])
            if detected_distro.version >= 17:
                services_list.remove('networking')

        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel(' %s is needed for the test to be run' % package)

        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
            if os.path.exists('/proc/device-tree/bmc'):
                services_list.remove('opal_errd')
        else:
            services_list.extend(['rtas_errd'])
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")