Skip to content
Snippets Groups Projects
Commit 21e264ea authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Log test output for all attemps | refs #31996

parent ee43c3d1
No related branches found
No related tags found
No related merge requests found
......@@ -4,16 +4,17 @@
Script to start tests and to manage their results
"""
import base64
from io import StringIO
import base64
import datetime
import glob
import os
import re
import socket
import subprocess
import sys
import time
import uuid
import glob
from time import sleep
import utils
from utils import log
......@@ -122,22 +123,21 @@ class Tester:
sys.path.append(root_dir)
# Check that this script is run by root
debug = "-d" in args
whoami = subprocess.check_output(["whoami"]).decode("utf-8").strip()
if whoami != "root" and not debug:
if os.environ.get("USER") != "root" and not debug:
log("This script should be run as root user.")
sys.exit(1)
# Update envsetup files
if "-n" not in args:
tester_path = os.path.join(root_dir, os.path.basename(__file__))
mtime = os.path.getmtime(tester_path)
subprocess.call(["python3", "update_envsetup.py"])
subprocess.run(["python3", "update_envsetup.py"])
if mtime != os.path.getmtime(tester_path):
log("The script has changed, restarting it...")
os.execl("/usr/bin/python3", "python3", tester_path, "-n", *args)
sys.exit(1) # not reachable
# Install utilities packages
if "-p" not in args:
subprocess.call(["python3", "pkgs_envsetup.py"])
subprocess.run(["python3", "pkgs_envsetup.py"])
# Load conf
conf = utils.load_conf()
if not conf:
......@@ -260,7 +260,7 @@ class Tester:
ms_path = os.path.join(path, "ms-testing-suite")
if not os.path.exists(ms_path):
log('Cloning ms-testing-suite in "%s".' % ms_path)
subprocess.call(
subprocess.run(
[
"git",
"clone",
......@@ -274,11 +274,11 @@ class Tester:
os.chdir(ms_path)
branch = utils.get_conf("ENVSETUP_BRANCH") or "stable"
if branch:
subprocess.call(["git", "checkout", branch])
subprocess.call(["git", "fetch", "--recurse-submodules", "--all"])
subprocess.call(["git", "reset", "--hard", "origin/{}".format(branch)])
subprocess.call(["git", "pull", "--recurse-submodules"])
subprocess.call(["git", "submodule", "update", "--init", "--recursive"])
subprocess.run(["git", "checkout", branch])
subprocess.run(["git", "fetch", "--recurse-submodules", "--all"])
subprocess.run(["git", "reset", "--hard", "origin/{}".format(branch)])
subprocess.run(["git", "pull", "--recurse-submodules"])
subprocess.run(["git", "submodule", "update", "--init", "--recursive"])
os.chdir(self.root_dir)
# Add tests to list
log("Add MediaServer tests if available.")
......@@ -329,20 +329,18 @@ class Tester:
while count < 3:
count += 1
log("Attempt: %s" % str(count))
p = subprocess.Popen(
p = subprocess.run(
command,
stdin=sys.stdin,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
out, _ = p.communicate()
out = p.stdout.decode("utf-8").strip()
log(out)
if p.returncode in (0, 2, 3):
break
sleep(5 * count * count)
if out:
out = out.decode("utf-8").strip()
out_of_support = out_of_support or "out of support" in out
log(out)
time.sleep(5 * count * count)
out_of_support = out_of_support or "out of support" in out
if p.returncode == 0:
status = "\033[92msuccess\033[0m"
successes += 1
......@@ -440,10 +438,8 @@ class Tester:
except Exception as e:
log("Failed to remove old log: %s" % e)
# Write log to file
hostname = subprocess.check_output(["hostname"])
if hostname:
hostname = hostname.decode("utf-8").strip()
else:
hostname = socket.gethostname()
if not hostname:
log("Failed to get hostname (required to send email).")
log_name = "results_%s_%s.txt" % (
hostname or "noname",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment