Skip to content

Commit

Permalink
Enable user logs in ETR (#51)
Browse files Browse the repository at this point in the history
* Enable user logs in ETR

* Only load json if requested to
  • Loading branch information
t-persson authored Sep 17, 2024
1 parent 2da272a commit f0f069b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package_dir =
# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD!
setup_requires = pyscaffold>=3.2a0,<3.3a0
install_requires =
etos_lib==3.2.2
etos_lib==4.3.6
cryptography>=42.0.4,<43.0.0
packageurl-python==0.9.1
jsontas==1.3.0
Expand Down
12 changes: 10 additions & 2 deletions src/etos_test_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@
import logging
from importlib.metadata import version, PackageNotFoundError
from etos_lib.logging.logger import setup_logging
from etos_test_runner.lib.decrypt import decrypt

try:
VERSION = version("etos_test_runner")
except PackageNotFoundError:
VERSION = "Unknown"

# Disable sending logs for now.
os.environ["ETOS_ENABLE_SENDING_LOGS"] = "false"
if os.getenv("ETOS_ENCRYPTION_KEY"):
os.environ["ETOS_RABBITMQ_PASSWORD"] = decrypt(
os.environ["ETOS_RABBITMQ_PASSWORD"], os.getenv("ETOS_ENCRYPTION_KEY")
)

DEV = os.getenv("DEV", "false").lower() == "true"
ENVIRONMENT = "development" if DEV else "production"
setup_logging("ETOS Test Runner", VERSION, ENVIRONMENT)

# ETR will print the entire environment just before executing.
# Hide the password.
os.environ["ETOS_RABBITMQ_PASSWORD"] = "*********"

# JSONTas would print all passwords as they are decrypted,
# which is not safe, so we disable propagation on the loggers.
# Propagation needs to be set to 0 instead of disabling the
Expand Down
6 changes: 2 additions & 4 deletions src/etos_test_runner/etr.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ def download_and_load(self, sub_suite_url):
:param sub_suite_url: URL to where the sub suite information exists.
:type sub_suite_url: str
"""
generator = self.etos.http.wait_for_request(sub_suite_url, as_json=False)
for response in generator:
json_config = response.json(object_pairs_hook=OrderedDict)
break
response = self.etos.http.get(sub_suite_url)
json_config = response.json(object_pairs_hook=OrderedDict)
dataset = CustomDataset()
dataset.add("decrypt", Decrypt)
config = JsonTas(dataset).run(json_config)
Expand Down
7 changes: 6 additions & 1 deletion src/etos_test_runner/lib/log_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,12 @@ def __retry_upload(
# Seek back to the start of the file so that the uploaded file
# is not 0 bytes in size.
log_file.seek(0)
yield self.etos.http.request(verb, url, as_json, data=log_file, **requests_kwargs)
request = getattr(self.etos.http, verb.lower())
response = request(url, data=log_file, **requests_kwargs)
if as_json:
yield response.json()
else:
yield response
break
except (
ConnectionError,
Expand Down

0 comments on commit f0f069b

Please sign in to comment.