Skip to content

Commit 55b2064

Browse files
committed
Make functional test suite not depend on git
1 parent 768c618 commit 55b2064

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Dockerfile
44
codecov/
55
.dev/
66
.venv/
7+
.git/
8+
.jj/

cmstestsuite/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@
2424

2525
import logging
2626
import subprocess
27+
import typing
2728

2829
from cmscommon.commands import pretty_print_cmdline
2930

3031

3132
logger = logging.getLogger(__name__)
3233

34+
class FunctionalTestConfig(typing.TypedDict):
35+
VERBOSITY: int
36+
COVERAGE: typing.NotRequired[str]
37+
PROFILER: typing.NotRequired[str]
38+
CONFIG_PATH: typing.NotRequired[str]
3339

3440
# CONFIG is populated by our test script.
35-
CONFIG = {
41+
CONFIG: FunctionalTestConfig = {
3642
'VERBOSITY': 0,
3743
}
3844

cmstestsuite/functionaltestframework.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import json
2626
import logging
27+
import os
2728
import re
2829
import sys
2930
import time
@@ -129,7 +130,7 @@ def initialize_aws(self) -> str:
129130
self.admin_info["username"] = "admin_%s" % suffix
130131
logger.info("Trying %(username)s" % self.admin_info)
131132
try:
132-
sh([sys.executable, "cmscontrib/AddAdmin.py",
133+
sh([os.path.join(sys.prefix, "bin/cmsAddAdmin"),
133134
"%(username)s" % self.admin_info,
134135
"-p", "%(password)s" % self.admin_info],
135136
ignore_failure=False)

cmstestsuite/programstarter.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import signal
2929
import socket
3030
import subprocess
31+
import sys
3132
import threading
3233
import time
3334
from urllib.parse import urlsplit
@@ -105,10 +106,8 @@ def __init__(self, cms_config, service_name, shard=0, contest=None,
105106
def start(self):
106107
"""Start a CMS service."""
107108
logger.info("Starting %s.", self.service_name)
108-
executable = os.path.join(
109-
".", "scripts", "cms%s" % (self.service_name))
110-
if CONFIG["TEST_DIR"] is None:
111-
executable = "cms%s" % self.service_name
109+
110+
executable = os.path.join(sys.prefix, 'bin', f'cms{self.service_name}')
112111

113112
args = [executable]
114113
if self.shard is not None:

cmstestsuite/testrunner.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import datetime
2424
import logging
2525
import os
26-
import subprocess
26+
import sys
2727
import types
2828

2929
from cms import TOKEN_MODE_FINITE
@@ -63,11 +63,6 @@ def __init__(self, test_list, contest_id=None, workers=1, cpu_limits=None):
6363
self.num_users = 0
6464
self.workers = workers
6565

66-
if CONFIG["TEST_DIR"] is not None:
67-
# Set up our expected environment.
68-
os.chdir("%(TEST_DIR)s" % CONFIG)
69-
os.environ["PYTHONPATH"] = "%(TEST_DIR)s" % CONFIG
70-
7166
self.start_generic_services()
7267
self.suffix = self.framework.initialize_aws()
7368

@@ -87,22 +82,11 @@ def __init__(self, test_list, contest_id=None, workers=1, cpu_limits=None):
8782
self.n_submissions, self.n_user_tests, self.n_tests)
8883

8984
def load_cms_conf(self):
90-
try:
91-
git_root = subprocess.check_output(
92-
"git rev-parse --show-toplevel", shell=True,
93-
stderr=subprocess.DEVNULL).decode('utf-8').strip()
94-
except subprocess.CalledProcessError:
95-
git_root = None
96-
CONFIG["TEST_DIR"] = git_root
97-
# TODO: this probably doesn't work: config/cms.toml doesn't even exist
98-
CONFIG["CONFIG_PATH"] = "%s/config/cms.toml" % CONFIG["TEST_DIR"]
99-
if CONFIG["TEST_DIR"] is None:
100-
CONFIG["CONFIG_PATH"] = "/usr/local/etc/cms.toml"
85+
CONFIG["CONFIG_PATH"] = os.path.join(sys.prefix, "etc/cms.toml")
10186

10287
# Override CMS config path when environment variable is present
103-
CMS_CONFIG_ENV_VAR = "CMS_CONFIG"
104-
if CMS_CONFIG_ENV_VAR in os.environ:
105-
CONFIG["CONFIG_PATH"] = os.environ[CMS_CONFIG_ENV_VAR]
88+
if "CMS_CONFIG" in os.environ:
89+
CONFIG["CONFIG_PATH"] = os.environ["CMS_CONFIG"]
10690

10791
return self.framework.get_cms_config()
10892

0 commit comments

Comments
 (0)