Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable user logs in ETR #51

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading