Exemplo n.º 1
0
def load_cities(request):
    """
    Before running the tests we want to load cities
    """
    log = logging.getLogger(__name__)
    if request.config.getvalue("skip_cities") or request.config.getvalue(
            "check_ref"):
        log.info("skipping cities loading")
        return

    if config.get('USE_ARTEMIS_NG'):
        log.warning('Posting cities')
        url = config['URL_TYR'] + "/v0/cities/"
        files = {'file': open(config['CITIES_INPUT_FILE'], 'rb')}
        r = requests.post(url, files=files)
        r.raise_for_status()
        return

    log.info("loading cities database")

    utils.launch_exec('cities -i {input} --connection-string'.format(
        input=config['CITIES_INPUT_FILE']),
                      additional_args=[config['CITIES_DB']])

    log.info("cities database loaded")
Exemplo n.º 2
0
def load_cities(request):
    """
    Load cities before running the tests
    """
    def is_retry_exception(exception):
        return isinstance(exception, RetryError)

    def get_last_cities_job():
        r_cities = requests.get(config["URL_TYR"] + "/v0/cities/status")
        r_cities.raise_for_status()
        return json.loads(r_cities.text)["latest_job"]

    @retry(stop_max_delay=300000,
           wait_fixed=500,
           retry_on_exception=is_retry_exception)
    def wait_for_cities_completion():
        """
        Wait until the 'cities' task is completed
        The task is considered failed if any error occurs while requesting Tyr
        """
        last_cities_job = get_last_cities_job()

        if last_cities_job and "state" in last_cities_job:
            if last_cities_job["state"] == "running":
                raise RetryError("Cities task still running...")
            elif last_cities_job["state"] == "failed":
                raise Exception("Job 'cities' status")
        else:
            raise Exception("Couldn't get 'cities' job status")

    log = logging.getLogger(__name__)
    if request.config.getvalue("skip_cities") or request.config.getvalue(
            "check_ref"):
        log.info("skipping cities loading")
        return

    if config.get("USE_ARTEMIS_NG"):
        log.info("Posting cities")
        url = config["URL_TYR"] + "/v0/cities/"
        files = {"file": open(config["CITIES_INPUT_FILE"], "rb")}
        r = requests.post(url, files=files)
        r.raise_for_status()

        wait_for_cities_completion()
        log.info("Cities task finished")
        return

    log.info("loading cities database")

    utils.launch_exec(
        "cities -i {input} --connection-string".format(
            input=config["CITIES_INPUT_FILE"]),
        additional_args=[config["CITIES_DB"]],
    )

    log.info("cities database loaded")
Exemplo n.º 3
0
 def deco(cls):
     cls.data_sets = []
     for c in cls.__bases__:
         if hasattr(c, "data_sets"):
             for dataset in c.data_sets:
                 cls.data_sets.append(DataSet(name=dataset.name,
                                              reload_timeout=datetime.timedelta(minutes=2),
                                              fixed_wait=datetime.timedelta(seconds=1),
                                              scenario=dataset.scenario))
     if config:
         for dataset in cls.data_sets:
             conf = config.get(dataset.name, None)
             if conf:
                 dataset.scenario = conf.get("scenario", "default")
     return cls
Exemplo n.º 4
0
 def deco(cls):
     cls.data_sets = []
     for c in cls.__bases__:
         if hasattr(c, "data_sets"):
             for dataset in c.data_sets:
                 cls.data_sets.append(
                     DataSet(name=dataset.name,
                             reload_timeout=datetime.timedelta(minutes=2),
                             fixed_wait=datetime.timedelta(seconds=1),
                             scenario=dataset.scenario))
     if config:
         for dataset in cls.data_sets:
             conf = config.get(dataset.name, None)
             if conf:
                 dataset.scenario = conf.get("scenario", "default")
     return cls
Exemplo n.º 5
0
from artemis.configuration_manager import config

if config.get("USE_ARTEMIS_NG"):
    from artemis.base_pytest import ArtemisTestFixture  # noqa: F401
else:
    from artemis.test_mechanism import ArtemisTestFixture  # noqa: F401
Exemplo n.º 6
0
from artemis.configuration_manager import config

if config.get('USE_ARTEMIS_NG'):
    from artemis.base_pytest import ArtemisTestFixture
else:
    from artemis.test_mechanism import ArtemisTestFixture