Example #1
0
    def __init__(self, **kwargs):
        super(SnapsTestRunner, self).__init__(**kwargs)
        self.logger = logging.getLogger(__name__)

        if 'os_creds' in kwargs:
            self.os_creds = kwargs['os_creds']
        else:
            self.os_creds = openstack_tests.get_credentials(
                os_env_file=CONST.__getattribute__('openstack_creds'),
                proxy_settings_str=None,
                ssh_proxy_cmd=None)

        if 'ext_net_name' in kwargs:
            self.ext_net_name = kwargs['ext_net_name']
        else:
            self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)

        self.use_fip = CONST.__getattribute__('snaps_use_floating_ips')
        self.use_keystone = CONST.__getattribute__('snaps_use_keystone')
        scenario = functest_utils.get_scenario()

        self.flavor_metadata = None
        if 'ovs' in scenario or 'fdio' in scenario:
            self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE

        self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)

        self.image_metadata = None
        if hasattr(CONST, 'snaps_images'):
            self.image_metadata = CONST.__getattribute__('snaps_images')
Example #2
0
 def test_get_scenario_failed(self, mock_logger_info):
     with mock.patch.dict(os.environ, {}, clear=True):
         self.assertEqual(functest_utils.get_scenario(),
                          "os-nosdn-nofeature-noha")
         mock_logger_info.assert_called_once_with("Impossible to retrieve "
                                                  "the scenario.Use "
                                                  "default "
                                                  "os-nosdn-nofeature-noha")
Example #3
0
    def __init__(self):
        super(SnapsTestRunner, self).__init__()

        self.ext_net_name = snaps_utils.get_ext_net_name()

        scenario = functest_utils.get_scenario()

        self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_ANY
        if 'ovs' in scenario or 'fdio' in scenario:
            self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
Example #4
0
    def __init__(self, case_name=''):
        super(SnapsTestRunner, self).__init__(case_name)

        self.ext_net_name = snaps_utils.get_ext_net_name()
        self.logger = ft_logger.Logger(self.project_name).getLogger()
        scenario = functest_utils.get_scenario()

        self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_ANY
        if 'ovs' in scenario or 'fdio' in scenario:
            self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE

        self.logger.info("Using flavor metatdata '%s'" % self.flavor_metadata)
Example #5
0
    def run(self):
        """
        Begins the test execution which should originate from the subclass
        """
        self.logger.info('Begin virtual environment setup')

        self.start_time = time.time()
        self.logger.info("vPing Start Time:'%s'" % (datetime.fromtimestamp(
            self.start_time).strftime('%Y-%m-%d %H:%M:%S')))

        image_base_name = '{}-{}'.format(
            CONST.__getattribute__('vping_image_name'), str(self.guid))
        os_image_settings = openstack_tests.cirros_image_settings(
            image_base_name, image_metadata=self.cirros_image_config)
        self.logger.info("Creating image with name: '%s'" % image_base_name)

        self.image_creator = deploy_utils.create_image(self.os_creds,
                                                       os_image_settings)
        self.creators.append(self.image_creator)

        private_net_name = CONST.__getattribute__(
            'vping_private_net_name') + self.guid
        private_subnet_name = CONST.__getattribute__(
            'vping_private_subnet_name') + self.guid
        private_subnet_cidr = CONST.__getattribute__(
            'vping_private_subnet_cidr')
        self.logger.info("Creating network with name: '%s'" % private_net_name)
        self.network_creator = deploy_utils.create_network(
            self.os_creds,
            NetworkSettings(name=private_net_name,
                            subnet_settings=[
                                SubnetSettings(name=private_subnet_name,
                                               cidr=private_subnet_cidr)
                            ]))
        self.creators.append(self.network_creator)

        self.logger.info("Creating flavor with name: '%s'" % self.flavor_name)
        scenario = functest_utils.get_scenario()
        flavor_metadata = None
        if 'ovs' in scenario or 'fdio' in scenario:
            flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
        flavor_creator = OpenStackFlavor(
            self.os_creds,
            FlavorSettings(name=self.flavor_name,
                           ram=512,
                           disk=1,
                           vcpus=1,
                           metadata=flavor_metadata))
        flavor_creator.create()
        self.creators.append(flavor_creator)
Example #6
0
def main():
    cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
    start_time = time.time()

    ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)

    stop_time = time.time()
    duration = round(stop_time - start_time, 1)
    if ret == 0:
        logger.info("doctor OK")
        test_status = 'OK'
    else:
        logger.info("doctor FAILED")
        test_status = 'NOK'

    details = {
        'timestart': start_time,
        'duration': duration,
        'status': test_status,
    }
    pod_name = functest_utils.get_pod_name(logger)
    scenario = functest_utils.get_scenario(logger)
    version = functest_utils.get_version(logger)
    build_tag = functest_utils.get_build_tag(logger)

    status = "FAIL"
    if details['status'] == "OK":
        status = "PASS"

    logger.info("Pushing Doctor results: TEST_DB_URL=%(db)s pod_name=%(pod)s "
                "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
                    'db': TEST_DB_URL,
                    'pod': pod_name,
                    'v': version,
                    's': scenario,
                    'c': status,
                    'b': build_tag,
                    'd': details,
                })
    functest_utils.push_results_to_db("doctor",
                                      "doctor-notification",
                                      logger,
                                      start_time,
                                      stop_time,
                                      status,
                                      details)
Example #7
0
def main():
    cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
    start_time = time.time()

    ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)

    stop_time = time.time()
    duration = round(stop_time - start_time, 1)
    if ret:
        logger.info("doctor OK")
        test_status = 'OK'
    else:
        logger.info("doctor FAILED")
        test_status = 'NOK'

    details = {
        'timestart': start_time,
        'duration': duration,
        'status': test_status,
    }
    pod_name = functest_utils.get_pod_name(logger)
    scenario = functest_utils.get_scenario(logger)
    version = functest_utils.get_version(logger)
    build_tag = functest_utils.get_build_tag(logger)

    status = "failed"
    if details['status'] == "OK":
        status = "passed"

    logger.info("Pushing Doctor results: TEST_DB_URL=%(db)s pod_name=%(pod)s "
                "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
                    'db': TEST_DB_URL,
                    'pod': pod_name,
                    'v': version,
                    's': scenario,
                    'c': status,
                    'b': build_tag,
                    'd': details,
                })
    functest_utils.push_results_to_db("doctor",
                                      "doctor-notification",
                                      logger,
                                      start_time,
                                      stop_time,
                                      status,
                                      details)
Example #8
0
def main():
    cmd = ('%s/tests/run.sh' % COPPER_REPO)
    start_time = time.time()

    ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)

    stop_time = time.time()
    duration = round(stop_time - start_time, 1)
    if ret == 0:
        logger.info("COPPER PASSED")
        test_status = 'PASS'
    else:
        logger.info("COPPER FAILED")
        test_status = 'FAIL'

    details = {
        'timestart': start_time,
        'duration': duration,
        'status': test_status,
    }
    pod_name = functest_utils.get_pod_name(logger)
    scenario = functest_utils.get_scenario(logger)
    version = functest_utils.get_version(logger)
    build_tag = functest_utils.get_build_tag(logger)

    logger.info("Pushing COPPER results: TEST_DB_URL=%(db)s pod_name=%(pod)s "
                "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
                    'db': TEST_DB_URL,
                    'pod': pod_name,
                    'v': version,
                    's': scenario,
                    'c': details['status'],
                    'b': build_tag,
                    'd': details,
                })
    functest_utils.push_results_to_db("COPPER",
                                      "COPPER-notification",
                                      logger,
                                      start_time,
                                      stop_time,
                                      details['status'],
                                      details)
Example #9
0
 def test_get_scenario_default(self):
     with mock.patch.dict(os.environ,
                          {'DEPLOY_SCENARIO': 'test_scenario'},
                          clear=True):
         self.assertEqual(functest_utils.get_scenario(),
                          self.scenario)