aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2022-03-03 16:59:14 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2022-03-03 17:25:00 +0100
commit75c869b6a39e94fe06ececa5b5a2b39807aa6daa (patch)
tree46a9d8eaaa8ba95448652368fa2ca1e03e7a53ed /xtesting
parent63683ea116ce54595a48f2e9c3ed3957122fab2d (diff)
Rewrite last direct call to ci/testcases.yaml
Change-Id: Ic4a857b6cdee7e3f9e2330414b0e6a6df98eea25 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting')
-rw-r--r--xtesting/ci/run_tests.py22
-rw-r--r--xtesting/core/campaign.py18
-rw-r--r--xtesting/utils/constants.py7
3 files changed, 24 insertions, 23 deletions
diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py
index c88c8282..0b94c28b 100644
--- a/xtesting/ci/run_tests.py
+++ b/xtesting/ci/run_tests.py
@@ -23,13 +23,13 @@ import sys
import textwrap
import enum
-import pkg_resources
import prettytable
from stevedore import driver
import yaml
from xtesting.ci import tier_builder
from xtesting.core import testcase
+from xtesting.utils import config
from xtesting.utils import constants
from xtesting.utils import env
@@ -88,7 +88,7 @@ class Runner():
self.clean_flag = True
self.report_flag = False
self.push_flag = False
- self.tiers = tier_builder.TierBuilder(_get_xtesting_config(
+ self.tiers = tier_builder.TierBuilder(config.get_xtesting_config(
constants.TESTCASE_DESCRIPTION,
constants.TESTCASE_DESCRIPTION_DEFAULT))
@@ -115,8 +115,10 @@ class Runner():
@staticmethod
def get_dict_by_test(testname):
# pylint: disable=missing-docstring
- with open(pkg_resources.resource_filename(
- 'xtesting', 'ci/testcases.yaml'), encoding='utf-8') as tyaml:
+ with open(config.get_xtesting_config(
+ constants.TESTCASE_DESCRIPTION,
+ constants.TESTCASE_DESCRIPTION_DEFAULT),
+ encoding='utf-8') as tyaml:
testcases_yaml = yaml.safe_load(tyaml)
for dic_tier in testcases_yaml.get("tiers"):
for dic_testcase in dic_tier['testcases']:
@@ -305,14 +307,6 @@ class Runner():
LOGGER.info("Xtesting report:\n\n%s\n", msg)
-def _get_xtesting_config(filename, default):
- for path in constants.XTESTING_PATHES:
- abspath = os.path.abspath(os.path.expanduser(path))
- if os.path.isfile(os.path.join(abspath, filename)):
- return os.path.join(abspath, filename)
- return default
-
-
def main():
"""Entry point"""
try:
@@ -322,10 +316,10 @@ def main():
print(f"Cannot create {constants.RESULTS_DIR}")
return testcase.TestCase.EX_RUN_ERROR
if env.get('DEBUG').lower() == 'true':
- logging.config.fileConfig(_get_xtesting_config(
+ logging.config.fileConfig(config.get_xtesting_config(
'logging.debug.ini', constants.DEBUG_INI_PATH_DEFAULT))
else:
- logging.config.fileConfig(_get_xtesting_config(
+ logging.config.fileConfig(config.get_xtesting_config(
'logging.ini', constants.INI_PATH_DEFAULT))
logging.captureWarnings(True)
parser = RunTestsParser()
diff --git a/xtesting/core/campaign.py b/xtesting/core/campaign.py
index dbde42df..5ca47d6e 100644
--- a/xtesting/core/campaign.py
+++ b/xtesting/core/campaign.py
@@ -21,11 +21,11 @@ from urllib.parse import urlparse
import boto3
from boto3.s3.transfer import TransferConfig
import botocore
-import pkg_resources
import requests
from xtesting.core import testcase
from xtesting.utils import env
+from xtesting.utils import config
from xtesting.utils import constants
__author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
@@ -120,7 +120,7 @@ class Campaign():
dst_s3_url = os.environ["S3_DST_URL"]
multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
"S3_ENDPOINT_URL"] else 8 * 1024 * 1024
- config = TransferConfig(multipart_threshold=multipart_threshold)
+ tconfig = TransferConfig(multipart_threshold=multipart_threshold)
bucket_name = urlparse(dst_s3_url).netloc
s3path = re.search(
'^/*(.*)/*$', urlparse(dst_s3_url).path).group(1)
@@ -136,7 +136,7 @@ class Campaign():
b3resource.Bucket(bucket_name).download_file(
s3_object.key,
re.sub(f'^{s3path}/*', '', s3_object.key),
- Config=config)
+ Config=tconfig)
Campaign.__logger.info(
"Downloading %s",
re.sub(f'^{s3path}/*', '', s3_object.key))
@@ -183,7 +183,7 @@ class Campaign():
dst_s3_url = os.environ["S3_DST_URL"]
multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
"S3_ENDPOINT_URL"] else 8 * 1024 * 1024
- config = TransferConfig(multipart_threshold=multipart_threshold)
+ tconfig = TransferConfig(multipart_threshold=multipart_threshold)
bucket_name = urlparse(dst_s3_url).netloc
mime_type = mimetypes.guess_type(f'{build_tag}.zip')
path = urlparse(dst_s3_url).path.strip("/")
@@ -191,7 +191,7 @@ class Campaign():
b3resource.Bucket(bucket_name).upload_file(
f'{build_tag}.zip',
os.path.join(path, f'{build_tag}.zip'),
- Config=config,
+ Config=tconfig,
ExtraArgs={'ContentType': mime_type[
0] or 'application/octet-stream'})
dst_http_url = os.environ["HTTP_DST_URL"]
@@ -217,10 +217,10 @@ def main():
if not os.path.exists(testcase.TestCase.dir_results):
os.makedirs(testcase.TestCase.dir_results)
if env.get('DEBUG').lower() == 'true':
- logging.config.fileConfig(pkg_resources.resource_filename(
- 'xtesting', constants.DEBUG_INI_PATH))
+ logging.config.fileConfig(config.get_xtesting_config(
+ 'logging.debug.ini', constants.DEBUG_INI_PATH_DEFAULT))
else:
- logging.config.fileConfig(pkg_resources.resource_filename(
- 'xtesting', constants.INI_PATH))
+ logging.config.fileConfig(config.get_xtesting_config(
+ 'logging.ini', constants.INI_PATH_DEFAULT))
logging.captureWarnings(True)
Campaign.zip_campaign_files()
diff --git a/xtesting/utils/constants.py b/xtesting/utils/constants.py
index d99a0e33..f5e29e0d 100644
--- a/xtesting/utils/constants.py
+++ b/xtesting/utils/constants.py
@@ -1,5 +1,12 @@
#!/usr/bin/env python
+# Copyright (c) 2019 Orange and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
# pylint: disable=missing-docstring
import os