Skip to content
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
3 changes: 3 additions & 0 deletions cron/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,6 @@ def do_measurement_control():
pass
except BaseException as exc: # pylint: disable=broad-except
error_helpers.log_error(f'Processing in {__file__} failed.', exception_context=exc.__context__, last_exception=exc, machine=config['machine']['description'])

DB().shutdown()

3 changes: 3 additions & 0 deletions cron/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from lib.global_config import GlobalConfig
from lib.terminal_colors import TerminalColors
from lib.system_checks import ConfigurationCheckError
from lib.db import DB

"""
The jobs.py file is effectively a state machine that can insert a job in the 'WAITING'
Expand Down Expand Up @@ -73,3 +74,5 @@
)
else:
error_helpers.log_error('Base exception occurred in jobs.py: ', exception_context=exc.__context__, last_exception=exc)

DB().shutdown()
2 changes: 2 additions & 0 deletions tests/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ python3 -m pip install -r ../requirements-dev.txt
playwright install --with-deps firefox
```

playwrite might fail with `BEWARE: your OS is not officially supported by Playwright; installing dependencies for ubuntu20.04-x64 as a fallback.` under non Ubuntu distros like Fedora as some libs are not installed. In this case remove the `-with-deps` and ignore the following warning as we only use firefox which should work.

We assume that your green-metrics-tool is already set up to work on your machine.

Tests will always run for *ScenarioRunner* and *Eco CI* even if you have this deactivated in your GMT installation.
Expand Down
22 changes: 22 additions & 0 deletions tests/setup-test-env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
from copy import deepcopy
import subprocess
import sys
from time import sleep
import yaml
import shutil
import re
Expand Down Expand Up @@ -31,6 +33,24 @@

DB_PW = 'testpw'

def check_sudo():
print('Checking sudo...')
process = None
try:
process = subprocess.Popen(['sudo', 'echo', 'ok'])
process.wait()
if process.returncode != 0:
raise RuntimeError("Failed to run sudo. Please run `sudo echo 'ok'` to get the sudo token and then rerun this script.")
except KeyboardInterrupt:
if process is not None:
process.terminate()
print('Interrupted by user. You might get some sudo message in your shell. Ignore it! Sleeping for 5 seconds to let sudo finish writing to terminal.')
print("Failed to run sudo. Please run `sudo echo 'ok'` to get the sudo token and then rerun this script.")

sleep(5) # We need to sleep here to give sudo time to write to terminal

sys.exit(1)

def copy_sql_structure(ee=False):
print('Copying SQL structure...')
shutil.copyfile('../docker/structure.sql', './structure.sql')
Expand Down Expand Up @@ -181,6 +201,7 @@ def create_frontend_config_file(ee=False, ai=False):
def edit_etc_hosts():
subprocess.run(['./edit-etc-hosts.sh'], check=True)


def build_test_docker_image():
subprocess.run(['docker', 'compose', '-f', test_compose_path, 'build'], check=True)

Expand All @@ -198,6 +219,7 @@ def build_test_docker_image():

args = parser.parse_args()

check_sudo()
copy_sql_structure(args.ee)
create_test_config_file(args.ee, args.ai)
create_frontend_config_file(args.ee, args.ai)
Expand Down
Loading