diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a4a555e..e770673 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,11 +45,28 @@ jobs: - name: run integration tests run: ./integration_tests.sh --durations=10 --cov=nomad_tools -n 3 + test_ssl: + name: Test ssl + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: upgrade pip + run: pip install --upgrade pip + - name: install editable package + run: pip install -e . + - name: install nomad server + run: bash ./tests/provision.sh nomad_install 1.8.0 + - name: run nomad server tls + run: bash ./tests/provision.sh nomad_start_tls + - name: test tls connection + run: ./tests/tls_env.bash testall pypi-publish: name: Upload release to PyPI needs: - test + - test_ssl if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') #if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest diff --git a/jobs/test-forever.nomad.hcl b/jobs/test-forever.nomad.hcl new file mode 100644 index 0000000..c057649 --- /dev/null +++ b/jobs/test-forever.nomad.hcl @@ -0,0 +1,13 @@ +job "test-forever" { + # meta { uuid = uuidv4() } + group "test-forever" { + task "test-forever" { + driver = "docker" + config { + image = "busybox:stable" + command = "sleep" + args = ["3600h"] + } + } + } +} diff --git a/jobs/test-sigterm.nomad.hcl b/jobs/test-sigterm.nomad.hcl new file mode 100644 index 0000000..6fad348 --- /dev/null +++ b/jobs/test-sigterm.nomad.hcl @@ -0,0 +1,26 @@ +job "test-sigterm" { + type = "batch" + meta { + uuid = uuidv4() + } + group "example" { + task "example" { + driver = "docker" + config { + image = "bash" + args = [ + "sh", + "-xc", + <=0.0.5 clickforward>=0.0.1 python-dotenv>=0.21.1 packaging>=16.1 -tabulate +tabulate>=0.9.0 +requests-toolbelt>=1.0.0 diff --git a/src/nomad_tools/entry.py b/src/nomad_tools/entry.py new file mode 100644 index 0000000..1a92c45 --- /dev/null +++ b/src/nomad_tools/entry.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +import click +import clickforward +from click.shell_completion import BashComplete + +from . import ( + entry_constrainteval, + entry_go, + entry_cp, + entry_dockers, + entry_downloadrelease, + entry_gitlab_runner, + entry_port, + entry_vardir, + entry_watch, +) +from .common_click import EPILOG, common_options, main_options +from .common_nomad import namespace_option + +clickforward.init() + +# Fix bash splitting completion on colon. +# Use __reassemble_comp_words_by_ref from bash-completion. +# Pass COMP_POINT as environment variable. +BashComplete.source_template = r"""\ + %(complete_func)s() { + local cword words=() + if [[ $(type -t __reassemble_comp_words_by_ref) == function ]]; then + __reassemble_comp_words_by_ref "=:" words cword + else + words=("${COMP_WORDS[@]}") + cword=${COMP_CWORD} + fi + local IFS=$'\n' + response=$(COMP_POINT=$COMP_POINT COMP_WORDS="${words[*]}" COMP_CWORD="$cword" %(complete_var)s=bash_complete $1) + for completion in $response; do + IFS=',' read type value <<< "$completion" + case $type in + dir) COMPREPLY=(); compopt -o dirnames; ;; + file) COMPREPLY=(); compopt -o default; ;; + plain) COMPREPLY+=("$value"); ;; + nospace) compopt -o nospace; ;; + esac + done + } + %(complete_func)s_setup() { + complete -o nosort -F %(complete_func)s %(prog_name)s + } + %(complete_func)s_setup; +""" + + +@click.group( + "nomadtools", + help="Collection of useful tools for HashiCorp Nomad.", + epilog=EPILOG, +) +@namespace_option() +@common_options() +@main_options() +def cli(): + pass + + +cli.add_command(entry_constrainteval.cli) +cli.add_command(entry_go.cli) +cli.add_command(entry_cp.cli) +cli.add_command(entry_dockers.cli) +cli.add_command(entry_downloadrelease.cli) +cli.add_command(entry_gitlab_runner.cli) +cli.add_command(entry_port.cli) +cli.add_command(entry_vardir.cli) +cli.add_command(entry_watch.cli) + + +def main(): + cli(max_content_width=9999) + + +if __name__ == "__main__": + main() diff --git a/src/nomad_tools/nomad_cp.py b/src/nomad_tools/entry_cp.py similarity index 100% rename from src/nomad_tools/nomad_cp.py rename to src/nomad_tools/entry_cp.py diff --git a/src/nomad_tools/nomad_dockers.py b/src/nomad_tools/entry_dockers.py similarity index 100% rename from src/nomad_tools/nomad_dockers.py rename to src/nomad_tools/entry_dockers.py diff --git a/src/nomad_tools/nomad_downloadrelease.py b/src/nomad_tools/entry_downloadrelease.py similarity index 100% rename from src/nomad_tools/nomad_downloadrelease.py rename to src/nomad_tools/entry_downloadrelease.py diff --git a/src/nomad_tools/nomad_gitlab_runner.py b/src/nomad_tools/entry_gitlab_runner.py similarity index 98% rename from src/nomad_tools/nomad_gitlab_runner.py rename to src/nomad_tools/entry_gitlab_runner.py index 6e1f6ee..703e7d5 100755 --- a/src/nomad_tools/nomad_gitlab_runner.py +++ b/src/nomad_tools/entry_gitlab_runner.py @@ -19,7 +19,7 @@ import click import yaml -from . import nomad_watch, nomadlib, taskexec +from . import entry_watch, nomadlib, taskexec from .common import ( cached_property, common_options, @@ -38,7 +38,7 @@ def get_gitlab_runner_package_script(file: str): - return get_package_file(f"nomad_gitlab_runner/{file}") + return get_package_file(f"entry_gitlab_runner/{file}") def get_CUSTOM_ENV() -> Dict[str, str]: @@ -536,12 +536,12 @@ def get_nomad_job(self) -> Job: ############################################################################### -def run_nomad_watch(cmd: str): +def run_entry_watch(cmd: str): cmdarr = ["-T", *split(cmd)] cmd = quotearr(cmdarr) log.debug(f"+ nomad-watch {cmd}") try: - return nomad_watch.cli.main(cmdarr, standalone_mode=False) + return entry_watch.cli.main(cmdarr, standalone_mode=False) except SystemExit as e: if not (e.code is None or e.code == 0): raise @@ -556,7 +556,7 @@ def purge_previous_nomad_job(jobname: str): assert ( job.Stop is True or job.Status == "dead" ), f"Job {job.description()} already exists and is not stopped or not dead. Bailing out" - run_nomad_watch(f"--purge -xn0 stop {quote(jobname)}") + run_entry_watch(f"--purge -xn0 stop {quote(jobname)}") ############################################################################### @@ -759,7 +759,7 @@ def mode_prepare(): with tempfile.NamedTemporaryFile("w+") as f: f.write(jobjson) f.flush() - run_nomad_watch(f"--json start {f.name}") + run_entry_watch(f"--json start {f.name}") @cli.command("run", help="https://docs.gitlab.com/runner/executors/custom.html#run") @@ -797,7 +797,7 @@ def mode_run(script: str, stage: str): @executor_exit def mode_cleanup(): je = Jobenv() - run_nomad_watch( + run_entry_watch( f" {'--purge' if config.purge else ''}" f" {'--purge-successful' if config.purge_successful and config.purge is None else ''}" f" -x -n0 stop {quote(je.jobname)}" diff --git a/src/nomad_tools/nomad_gitlab_runner/script.sh b/src/nomad_tools/entry_gitlab_runner/script.sh similarity index 100% rename from src/nomad_tools/nomad_gitlab_runner/script.sh rename to src/nomad_tools/entry_gitlab_runner/script.sh diff --git a/src/nomad_tools/nomad_gitlab_runner/waiter.sh b/src/nomad_tools/entry_gitlab_runner/waiter.sh similarity index 100% rename from src/nomad_tools/nomad_gitlab_runner/waiter.sh rename to src/nomad_tools/entry_gitlab_runner/waiter.sh diff --git a/src/nomad_tools/entry_go.py b/src/nomad_tools/entry_go.py index bbd7989..cfbaddf 100644 --- a/src/nomad_tools/entry_go.py +++ b/src/nomad_tools/entry_go.py @@ -21,7 +21,7 @@ import clickforward import dotenv -from . import nomad_watch, taskexec +from . import entry_watch, taskexec from .common_base import NOMAD_NAMESPACE, quotearr from .common_click import EPILOG, common_options from .common_nomad import namespace_option @@ -636,9 +636,9 @@ def __thread(self): @common_options() @namespace_option() @clickdc.adddc("args", Args) -@clickdc.adddc("notifyargs", nomad_watch.NotifyOptions) +@clickdc.adddc("notifyargs", entry_watch.NotifyOptions) @click.option("-v", "--verbose", is_flag=True) -def cli(args: Args, notifyargs: nomad_watch.NotifyOptions, verbose: bool): +def cli(args: Args, notifyargs: entry_watch.NotifyOptions, verbose: bool): global ARGS ARGS = args if args.command[0].startswith("-"): @@ -674,7 +674,7 @@ def cli(args: Args, notifyargs: nomad_watch.NotifyOptions, verbose: bool): cmd = [f"--notifyfdstarted={wfd}", *cmd] with redirect_stdin_str(jobjson): log.debug(f"+ {quotearr(cmd)}") - nomad_watch.cli.main(args=cmd) + entry_watch.cli.main(args=cmd) if __name__ == "__main__": diff --git a/src/nomad_tools/nomad_port.py b/src/nomad_tools/entry_port.py similarity index 100% rename from src/nomad_tools/nomad_port.py rename to src/nomad_tools/entry_port.py diff --git a/src/nomad_tools/nomad_taskexec.py b/src/nomad_tools/entry_taskexec.py similarity index 100% rename from src/nomad_tools/nomad_taskexec.py rename to src/nomad_tools/entry_taskexec.py diff --git a/src/nomad_tools/nomad_vardir.py b/src/nomad_tools/entry_vardir.py similarity index 100% rename from src/nomad_tools/nomad_vardir.py rename to src/nomad_tools/entry_vardir.py diff --git a/src/nomad_tools/nomad_watch.py b/src/nomad_tools/entry_watch.py similarity index 100% rename from src/nomad_tools/nomad_watch.py rename to src/nomad_tools/entry_watch.py diff --git a/src/nomad_tools/entrypoint.py b/src/nomad_tools/entrypoint.py index 9b2986f..6f79738 100644 --- a/src/nomad_tools/entrypoint.py +++ b/src/nomad_tools/entrypoint.py @@ -1,82 +1,61 @@ #!/usr/bin/env python3 - -import click -import clickforward -from click.shell_completion import BashComplete - -from . import ( - entry_constrainteval, - entry_go, - nomad_cp, - nomad_dockers, - nomad_downloadrelease, - nomad_gitlab_runner, - nomad_port, - nomad_vardir, - nomad_watch, -) -from .common_click import EPILOG, common_options, main_options -from .common_nomad import namespace_option - -clickforward.init() - -# Fix bash splitting completion on colon. -# Use __reassemble_comp_words_by_ref from bash-completion. -# Pass COMP_POINT as environment variable. -BashComplete.source_template = r"""\ - %(complete_func)s() { - local cword words=() - if [[ $(type -t __reassemble_comp_words_by_ref) == function ]]; then - __reassemble_comp_words_by_ref "=:" words cword - else - words=("${COMP_WORDS[@]}") - cword=${COMP_CWORD} - fi - local IFS=$'\n' - response=$(COMP_POINT=$COMP_POINT COMP_WORDS="${words[*]}" COMP_CWORD="$cword" %(complete_var)s=bash_complete $1) - for completion in $response; do - IFS=',' read type value <<< "$completion" - case $type in - dir) COMPREPLY=(); compopt -o dirnames; ;; - file) COMPREPLY=(); compopt -o default; ;; - plain) COMPREPLY+=("$value"); ;; - nospace) compopt -o nospace; ;; - esac - done - } - %(complete_func)s_setup() { - complete -o nosort -F %(complete_func)s %(prog_name)s - } - %(complete_func)s_setup; +import os +import sys + +NOMAD_HELP = """ +Usage: nomad [-version] [-help] [-autocomplete-(un)install] [args] + +Common commands: + run Run a new job or update an existing job + stop Stop a running job + status Display the status output for a resource + alloc Interact with allocations + job Interact with jobs + node Interact with nodes + agent Runs a Nomad agent + +Other commands: + acl Interact with ACL policies and tokens + action Run a pre-defined command from a given context + agent-info Display status information about the local agent + config Interact with configurations + deployment Interact with deployments + eval Interact with evaluations + exec Execute commands in task + fmt Rewrites Nomad config and job files to canonical format + license Interact with Nomad Enterprise License + login Login to Nomad using an auth method + monitor Stream logs from a Nomad agent + namespace Interact with namespaces + operator Provides cluster-level tools for Nomad operators + plugin Inspect plugins + quota Interact with quotas + recommendation Interact with the Nomad recommendation endpoint + scaling Interact with the Nomad scaling endpoint + sentinel Interact with Sentinel policies + server Interact with servers + service Interact with registered services + setup Interact with setup helpers + system Interact with the system API + tls Generate Self Signed TLS Certificates for Nomad + ui Open the Nomad Web UI + var Interact with variables + version Prints the Nomad version + volume Interact with volumes """ -@click.group( - "nomadtools", - help="Collection of useful tools for HashiCorp Nomad.", - epilog=EPILOG, -) -@namespace_option() -@common_options() -@main_options() -def cli(): - pass - - -cli.add_command(entry_constrainteval.cli) -cli.add_command(entry_go.cli) -cli.add_command(nomad_cp.cli) -cli.add_command(nomad_dockers.cli) -cli.add_command(nomad_downloadrelease.cli) -cli.add_command(nomad_gitlab_runner.cli) -cli.add_command(nomad_port.cli) -cli.add_command(nomad_vardir.cli) -cli.add_command(nomad_watch.cli) +def get_nomad_subcommands(): + return set(x.split()[0] for x in NOMAD_HELP.splitlines() if x.startswith(" ")) def main(): - cli(max_content_width=9999) + if len(sys.argv) > 1: + if sys.argv[1] in get_nomad_subcommands(): + os.execvp("nomad", ["nomad", *sys.argv[1:]]) + from . import entry + entry.main() if __name__ == "__main__": main() diff --git a/src/nomad_tools/nomadlib/connection.py b/src/nomad_tools/nomadlib/connection.py index 8f7d759..256faa0 100644 --- a/src/nomad_tools/nomadlib/connection.py +++ b/src/nomad_tools/nomadlib/connection.py @@ -4,13 +4,14 @@ import logging import os import ssl +import sys from abc import ABC, abstractmethod from typing import Any, Dict, Optional import requests.adapters import requests.auth -import websocket import urllib3 +import websocket from ..common_base import cached_property from . import types @@ -24,7 +25,7 @@ NOMAD_CLIENT_CERT = "NOMAD_CLIENT_CERT" NOMAD_CLIENT_KEY = "NOMAD_CLIENT_KEY" NOMAD_CACERT = "NOMAD_CACERT" -NOMAD_CAPATH = "NOMAD_CACPATH" +NOMAD_CAPATH = "NOMAD_CAPATH" NOMAD_SKIP_VERIFY = "NOMAD_SKIP_VERIFY" NOMAD_TLS_SERVER_NAME = "NOMAD_TLS_SERVER_NAME" @@ -33,16 +34,30 @@ def _default_session(): - s = requests.Session() + session = requests.Session() + # Override SNI if requested. + if NOMAD_TLS_SERVER_NAME in os.environ: + try: + from requests_toolbelt.adapters.host_header_ssl import HostHeaderSSLAdapter + except ImportError: + print( + "nomadtools: install requests_toolbelt to use NOMAD_TLS_SERVER_NAME", + file=sys.stderr, + ) + raise + + obj = HostHeaderSSLAdapter + else: + obj = requests.adapters.HTTPAdapter # Increase the number of connections. - a = requests.adapters.HTTPAdapter( + adapter = obj( pool_connections=1000, pool_maxsize=1000, max_retries=requests.adapters.Retry(3), ) - s.mount("http://", a) - s.mount("https://", a) - return s + session.mount("http://", adapter) + session.mount("https://", adapter) + return session class APIException(requests.HTTPError): @@ -181,24 +196,33 @@ def request( self.addr() + "/v1/" + url, *args, auth=( - requests.auth.HTTPBasicAuth(*os.environ[NOMAD_HTTP_AUTH].split(":", 2)) + requests.auth.HTTPBasicAuth(*os.environ[NOMAD_HTTP_AUTH].split(":", 1)) if NOMAD_HTTP_AUTH in os.environ else None ), - headers=( - {"X-Nomad-Token": os.environ[NOMAD_TOKEN]} - if NOMAD_TOKEN in os.environ - else None - ), + headers={ + **( + {"X-Nomad-Token": os.environ[NOMAD_TOKEN]} + if NOMAD_TOKEN in os.environ + else {} + ), + **( + {"Host": os.environ[NOMAD_TLS_SERVER_NAME]} + if NOMAD_TLS_SERVER_NAME in os.environ + else {} + ), + }, params=params, verify=( False if NOMAD_SKIP_VERIFY in os.environ - else os.environ[NOMAD_CACERT] - if NOMAD_CACERT in os.environ - else os.environ[NOMAD_CAPATH] - if NOMAD_CAPATH in os.environ - else True + else ( + os.environ[NOMAD_CACERT] + if NOMAD_CACERT in os.environ + else ( + os.environ[NOMAD_CAPATH] if NOMAD_CAPATH in os.environ else True + ) + ) ), cert=( (os.environ[NOMAD_CLIENT_CERT], os.environ[NOMAD_CLIENT_KEY]) @@ -276,7 +300,11 @@ def create_websocket_connection(path: str) -> websocket.WebSocket: sslopt["check_hostname"] = False cacert = os.environ.get(NOMAD_CACERT) if cacert: - sslopt["ca_cert_path"] = cacert + sslopt["ca_certs"] = cacert + else: + capath = os.environ.get(NOMAD_CAPATH) + if capath: + sslopt["ca_cert_path"] = capath cert = os.environ.get(NOMAD_CLIENT_CERT) key = os.environ.get(NOMAD_CLIENT_KEY) if cert and key: diff --git a/tests/integration/test_nomad_cp.py b/tests/integration/test_nomad_cp.py index 622691b..2166b1f 100644 --- a/tests/integration/test_nomad_cp.py +++ b/tests/integration/test_nomad_cp.py @@ -8,8 +8,8 @@ from nomad_tools import taskexec from nomad_tools.common import mynomad -from nomad_tools.nomad_cp import ArgPath -from tests.testlib import get_templatejob, run, run_nomad_cp, run_nomad_watch +from nomad_tools.entry_cp import ArgPath +from tests.testlib import get_templatejob, run, run_entry_cp, run_entry_watch class NomadTempdir: @@ -35,14 +35,14 @@ def __exit__(self, type, value, traceback): def run_temp_job(): hcl = get_templatejob(script="exec sleep 60") jobid = hcl.id - run_nomad_watch(f"-x purge {jobid}") + run_entry_watch(f"-x purge {jobid}") try: - run_nomad_watch("start -", input=hcl.hcl) + run_entry_watch("start -", input=hcl.hcl) with NomadTempdir(jobid) as nomaddir: with tempfile.TemporaryDirectory() as hostdir: yield jobid, nomaddir, hostdir finally: - run_nomad_watch(f"-x purge {jobid}") + run_entry_watch(f"-x purge {jobid}") def g(incomplete: str) -> List[str]: @@ -54,7 +54,7 @@ def g(incomplete: str) -> List[str]: return arr -def test_nomad_cp_complete(): +def test_entry_cp_complete(): with run_temp_job() as (jobid, nomaddir, hostdir): allocid = mynomad.get(f"job/{jobid}/allocations")[0]["ID"] task = group = jobid.replace("test-", "") @@ -75,24 +75,24 @@ def test_nomad_cp_complete(): assert g(f":{allocid[:15]}:{task}:{src}") == [dst], f"{src} {dst}" -def test_nomad_cp_dir(): +def test_entry_cp_dir(): with run_temp_job() as (jobname, nomaddir, hostdir): taskexec.run( *taskexec.find_job(jobname), split(f"sh -xeuc 'cd {nomaddir} && mkdir -p dir && touch dir/1 dir/2'"), ) - run_nomad_cp(f"{jobname}:{nomaddir}/dir {hostdir}/dir") - run_nomad_cp(f"{hostdir}/dir {jobname}:{nomaddir}/dir2") - run_nomad_cp(f"{jobname}:{nomaddir}/dir2 {hostdir}/dir2") + run_entry_cp(f"{jobname}:{nomaddir}/dir {hostdir}/dir") + run_entry_cp(f"{hostdir}/dir {jobname}:{nomaddir}/dir2") + run_entry_cp(f"{jobname}:{nomaddir}/dir2 {hostdir}/dir2") run(f"diff -r {hostdir}/dir {hostdir}/dir2") -def test_nomad_cp_file(): +def test_entry_cp_file(): with run_temp_job() as (jobname, nomaddir, hostdir): txt = f"{time.time()}" with Path(f"{hostdir}/file").open("w") as f: f.write(txt) - run_nomad_cp(f"{hostdir}/file {jobname}:{nomaddir}/file") - run_nomad_cp(f"{jobname}:{nomaddir}/file {hostdir}/file2") + run_entry_cp(f"{hostdir}/file {jobname}:{nomaddir}/file") + run_entry_cp(f"{jobname}:{nomaddir}/file {hostdir}/file2") with Path(f"{hostdir}/file2").open() as f: assert f.read() == txt diff --git a/tests/integration/test_nomad_dockers.py b/tests/integration/test_nomad_dockers.py index a8d1053..4c6d6a0 100644 --- a/tests/integration/test_nomad_dockers.py +++ b/tests/integration/test_nomad_dockers.py @@ -1,10 +1,10 @@ -from tests.testlib import get_testjobs, run_nomad_dockers +from tests.testlib import get_testjobs, run_entry_dockers -def test_nomad_dockers(): +def test_entry_dockers(): # This is an integration test, because nomad-vardir calls nomad executable to parse HCL. - run_nomad_dockers("", check=False) + run_entry_dockers("", check=False) jobf = get_testjobs()["test-listen"] - run_nomad_dockers(f"{jobf}", output=["busybox:stable"]) + run_entry_dockers(f"{jobf}", output=["busybox:stable"]) jobf = get_testjobs()["test-upgrade1"] - run_nomad_dockers(f"{jobf}", output=["busybox:stable"]) + run_entry_dockers(f"{jobf}", output=["busybox:stable"]) diff --git a/tests/integration/test_nomad_gitlab_runner.py b/tests/integration/test_nomad_gitlab_runner.py index 30fce9a..2a08fe2 100644 --- a/tests/integration/test_nomad_gitlab_runner.py +++ b/tests/integration/test_nomad_gitlab_runner.py @@ -32,10 +32,10 @@ def __post_init__(self): for k, v in defaults.items(): self.env.setdefault(k, v) - def nomad_gitlab_runner(self, cmd: str, check: List[int], **kwargs): + def entry_gitlab_runner(self, cmd: str, check: List[int], **kwargs): # [0, self.build_failure, self.system_failure], return run( - f"python3 -m nomad_tools.nomad_gitlab_runner -v -c {quote(self.configfile)} {cmd}", + f"python3 -m nomad_tools.entry_gitlab_runner -v -c {quote(self.configfile)} {cmd}", env=self.env, check=check, **kwargs, @@ -43,7 +43,7 @@ def nomad_gitlab_runner(self, cmd: str, check: List[int], **kwargs): def stage_config(self): driverconfig = json.loads( - self.nomad_gitlab_runner("config", check=[0], stdout=1).stdout + self.entry_gitlab_runner("config", check=[0], stdout=1).stdout ) assert isinstance(driverconfig["builds_dir"], str) assert isinstance(driverconfig["cache_dir"], str) @@ -53,15 +53,15 @@ def stage_config(self): self.env.update(driverenv) def stage_prepare(self): - return self.nomad_gitlab_runner("prepare", check=[0]) + return self.entry_gitlab_runner("prepare", check=[0]) def stage_script(self, scriptfile: str, stage: str): - return self.nomad_gitlab_runner( + return self.entry_gitlab_runner( f"run {quote(scriptfile)} {quote(stage)}", check=[0] ) def stage_cleanup(self): - return self.nomad_gitlab_runner("cleanup", check=[0]) + return self.entry_gitlab_runner("cleanup", check=[0]) def cycle(config: dict, script: str, env: Dict[str, str] = {}): @@ -91,14 +91,14 @@ def cycle(config: dict, script: str, env: Dict[str, str] = {}): } -def test_nomad_gitlab_runner_nomad_supports_bridge(): +def test_entry_gitlab_runner_nomad_supports_bridge(): run_nomadt("constrainteval '${attr.plugins.cni.version.bridge}' semver '>= 0.4.0'") -def test_nomad_gitlab_runner_raw_exec(): +def test_entry_gitlab_runner_raw_exec(): cycle(raw_exec_config, "echo hello world") -def test_nomad_gitlab_runner_docker(): +def test_entry_gitlab_runner_docker(): cycle(docker_config, "echo hello world ") @@ -107,7 +107,7 @@ def test_nomad_gitlab_runner_docker(): ) -def test_nomad_gitlab_runner_dockerd_tls(): +def test_entry_gitlab_runner_dockerd_tls(): cycle( docker_config, docker_test_script, @@ -121,7 +121,7 @@ def test_nomad_gitlab_runner_dockerd_tls(): ) -def test_nomad_gitlab_runner_dockerd_notls(): +def test_entry_gitlab_runner_dockerd_notls(): cycle( docker_config, docker_test_script, @@ -133,7 +133,7 @@ def test_nomad_gitlab_runner_dockerd_notls(): ) -def test_nomad_gitlab_runner_alias(): +def test_entry_gitlab_runner_alias(): cycle( { "default": { diff --git a/tests/integration/test_nomad_vardir.py b/tests/integration/test_nomad_vardir.py index 0fc6f46..d4d521b 100644 --- a/tests/integration/test_nomad_vardir.py +++ b/tests/integration/test_nomad_vardir.py @@ -1,7 +1,7 @@ import tempfile from nomad_tools.common import mynomad -from tests.testlib import caller, run, run_nomad_vardir +from tests.testlib import caller, run, run_entry_vardir class VardirCaller: @@ -9,7 +9,7 @@ def __init__(self, name: str): self.name = name def __call__(self, cmd, **kvargs): - return run_nomad_vardir(f"{self.name} {cmd}", **kvargs) + return run_entry_vardir(f"{self.name} {cmd}", **kvargs) def __enter__(self): return self @@ -18,7 +18,7 @@ def __exit__(self, exc_type, exc_value, traceback): run(f" nomad var purge {self.name}", check=None) -def test_nomad_vardir_1(): +def test_entry_vardir_1(): with VardirCaller(caller()) as vardir: with tempfile.TemporaryDirectory() as d: # @@ -47,7 +47,7 @@ def test_nomad_vardir_1(): vardir("rm c", cwd=d) -def test_nomad_vardir_setrm(): +def test_entry_vardir_setrm(): with VardirCaller(caller()) as vardir: vardir("set a avalue") vardir("cat a", output="avalue") diff --git a/tests/integration/test_nomad_watch.py b/tests/integration/test_nomad_watch.py index bae8c3d..d16a9d8 100644 --- a/tests/integration/test_nomad_watch.py +++ b/tests/integration/test_nomad_watch.py @@ -4,41 +4,41 @@ from typing import Dict, List from nomad_tools import nomadlib -from tests.testlib import caller, gen_job, job_exists, nomad_has_docker, run_nomad_watch +from tests.testlib import caller, gen_job, job_exists, nomad_has_docker, run_entry_watch -def test_nomad_watch_run_0(): +def test_entry_watch_run_0(): """Watch a simple jow that outputs hello world""" job = gen_job(script="echo hello world") - run_nomad_watch( + run_entry_watch( "--purge run -json -", input=json.dumps(job), output=["hello world"] ) -def test_nomad_watch_run(): +def test_entry_watch_run(): """Run a simple job, then purge it. Check if we have our uuid on output""" mark = "5581c3a0-cd72-4b84-8b95-799d1aebe1cd" exitstatus = 123 job = gen_job(script=f"echo {mark}; exit {exitstatus}") jobid = job["Job"]["ID"] - run_nomad_watch(f"-x purge {jobid}") - run_nomad_watch( + run_entry_watch(f"-x purge {jobid}") + run_entry_watch( "run -json -", input=json.dumps(job), check=exitstatus, output=[mark], ) - run_nomad_watch(f"purge {jobid}", check=exitstatus) + run_entry_watch(f"purge {jobid}", check=exitstatus) -def test_nomad_watch_start(): +def test_entry_watch_start(): mark = "7bc8413c-8619-48bf-a46d-f42727724632" exitstatus = 234 job = gen_job(script=f"sleep 2; echo {mark} ; exit {exitstatus}") jobid = job["Job"]["ID"] try: - run_nomad_watch("start -json -", input=json.dumps(job)) - assert mark in run_nomad_watch(f"started {jobid}", stdout=1).stdout + run_entry_watch("start -json -", input=json.dumps(job)) + assert mark in run_entry_watch(f"started {jobid}", stdout=1).stdout cmds = [ f"stop {jobid}", f"stopped {jobid}", @@ -49,13 +49,13 @@ def test_nomad_watch_start(): f"--no-follow -o all job {jobid}", ] for cmd in cmds: - assert mark in run_nomad_watch(cmd, check=exitstatus, stdout=1).stdout + assert mark in run_entry_watch(cmd, check=exitstatus, stdout=1).stdout finally: - run_nomad_watch(f"-o none stop {jobid}", check=exitstatus) - run_nomad_watch(f"-o none --purge stop {jobid}", check=exitstatus) + run_entry_watch(f"-o none stop {jobid}", check=exitstatus) + run_entry_watch(f"-o none --purge stop {jobid}", check=exitstatus) -def test_nomad_watch_run_short(): +def test_entry_watch_run_short(): name = caller() spec = f""" job "{name}" {{ @@ -79,14 +79,14 @@ def test_nomad_watch_run_short(): """ print(spec) try: - output = run_nomad_watch("-n -1 run -", input=spec, stdout=1).stdout + output = run_entry_watch("-n -1 run -", input=spec, stdout=1).stdout assert output.count("sleep 0.123") == 5 assert output.count("MARK ") == 10 finally: - run_nomad_watch(f"-x purge {name}") + run_entry_watch(f"-x purge {name}") -def test_nomad_watch_run_multiple(): +def test_entry_watch_run_multiple(): name = caller() now = datetime.datetime.now().strftime("%Y%m%dT%H%M%S") hastohave: List[str] = [] @@ -132,30 +132,30 @@ def test_nomad_watch_run_multiple(): } """ print(spec) - output = run_nomad_watch( + output = run_entry_watch( "--shutdown-timeout 3 --purge run -", input=spec, stdout=1 ).stdout for i in hastohave: assert output.count(i) == 2, f"{output}.count({i}) != 2" -def test_nomad_watch_purge_successful_0(): +def test_entry_watch_purge_successful_0(): job = gen_job("exit 0") jobid = job["Job"]["ID"] - run_nomad_watch("--purge-successful run -json -", input=json.dumps(job), check=[0]) + run_entry_watch("--purge-successful run -json -", input=json.dumps(job), check=[0]) assert not job_exists(jobid) -def test_nomad_watch_purge_successful_123(): +def test_entry_watch_purge_successful_123(): job = gen_job("exit 123") jobid = job["Job"]["ID"] try: - run_nomad_watch( + run_entry_watch( "--purge-successful run -json -", input=json.dumps(job), check=[123] ) assert job_exists(jobid) finally: - run_nomad_watch(f"-x --purge stop {jobid}") + run_entry_watch(f"-x --purge stop {jobid}") assert not job_exists(jobid) @@ -168,7 +168,7 @@ def gen_task(name: str, script: str, add: dict = {}): } -def test_nomad_watch_starting_with_preinit_tasks(): +def test_entry_watch_starting_with_preinit_tasks(): jobid = caller() job = { "Job": { @@ -211,7 +211,7 @@ def test_nomad_watch_starting_with_preinit_tasks(): } } try: - run_nomad_watch("start -json -", input=json.dumps(job)) + run_entry_watch("start -json -", input=json.dumps(job)) assert job_exists(jobid) allocs = [ nomadlib.Alloc(x) @@ -233,7 +233,7 @@ def test_nomad_watch_starting_with_preinit_tasks(): assert not states["poststop"].was_started() # finally: - run_nomad_watch(f"-x stop {jobid}") + run_entry_watch(f"-x stop {jobid}") assert job_exists(jobid) allocs = [ nomadlib.Alloc(x) for x in nomadlib.NomadConn().get(f"job/{jobid}/allocations") @@ -246,5 +246,5 @@ def test_nomad_watch_starting_with_preinit_tasks(): tmp = [f"name={n} finishedat={s.FinishedAt}" for n, s in states.items()] assert all([s.FinishedAt for s in states.values()]), f"{states} | {tmp}" # - run_nomad_watch(f"-xn0 --purge stop {jobid}") + run_entry_watch(f"-xn0 --purge stop {jobid}") assert not job_exists(jobid) diff --git a/tests/integration/test_nomad_watch2.py b/tests/integration/test_nomad_watch2.py index ee3b9db..8d90743 100644 --- a/tests/integration/test_nomad_watch2.py +++ b/tests/integration/test_nomad_watch2.py @@ -3,15 +3,15 @@ from typing import List, Union from nomad_tools.common import mynomad -from tests.testlib import get_testjobs, run_nomad_watch, run_nomadt +from tests.testlib import get_testjobs, run_entry_watch, run_nomadt testjobs = get_testjobs() -def test_nomad_watch2_run0(): +def test_entry_watch2_run0(): """Watch a simple jow that outputs hello world""" job = "test-run0" - run_nomad_watch( + run_entry_watch( f"--purge run {testjobs[job]}", output=[ "> hello world", @@ -20,10 +20,10 @@ def test_nomad_watch2_run0(): ) -def test_nomad_watch2_noutf(): +def test_entry_watch2_noutf(): """Watch a simple jow that outputs hello world""" job = "test-noutf" - run_nomad_watch( + run_entry_watch( f"--purge run {testjobs[job]}", output=[ "0xc0 byte: ", @@ -31,34 +31,34 @@ def test_nomad_watch2_noutf(): ) -def test_nomad_watch2_start(): +def test_entry_watch2_start(): job = "test-start" mark = "7bc8413c-8619-48bf-a46d-f42727724632" exitstatus = 234 script = f"echo {mark}; sleep 1; exit {exitstatus}" try: - run_nomad_watch(f"start -var script={quote(script)} {testjobs[job]}") - run_nomad_watch(f"started {job}", output=[mark]) + run_entry_watch(f"start -var script={quote(script)} {testjobs[job]}") + run_entry_watch(f"started {job}", output=[mark]) cmds = [ f"stop {job}", f"stopped {job}", f"--no-follow job {job}", ] for cmd in cmds: - run_nomad_watch(cmd, check=exitstatus, output=[mark]) + run_entry_watch(cmd, check=exitstatus, output=[mark]) finally: - run_nomad_watch(f"-o nolog stop {job}", check=exitstatus) - run_nomad_watch(f"-o nolog --purge stop {job}", check=exitstatus) + run_entry_watch(f"-o nolog stop {job}", check=exitstatus) + run_entry_watch(f"-o nolog --purge stop {job}", check=exitstatus) -def test_nomad_watch2_start2(): +def test_entry_watch2_start2(): job = "test-start2" mark = "7bc8413c-8619-48bf-a46d-f42727724632" exitstatus = 234 script = f"echo {mark}; sleep 1; exit {exitstatus}" try: - run_nomad_watch(f"start -var script={quote(script)} {testjobs[job]}") - run_nomad_watch(f"started {job}", output=[mark]) + run_entry_watch(f"start -var script={quote(script)} {testjobs[job]}") + run_entry_watch(f"started {job}", output=[mark]) cmds = [ f"--no-follow -o stdout job {job}", f"--no-follow -o stderr job {job}", @@ -66,23 +66,23 @@ def test_nomad_watch2_start2(): f"--no-follow -o all job {job}", ] for cmd in cmds: - run_nomad_watch(cmd, check=exitstatus, output=[mark]) + run_entry_watch(cmd, check=exitstatus, output=[mark]) finally: - run_nomad_watch(f"-o nolog stop {job}", check=exitstatus) - run_nomad_watch(f"-o nolog --purge stop {job}", check=exitstatus) + run_entry_watch(f"-o nolog stop {job}", check=exitstatus) + run_entry_watch(f"-o nolog --purge stop {job}", check=exitstatus) -def test_nomad_watch2_okpurge(): +def test_entry_watch2_okpurge(): job = "test-okpurge" try: # Run nice deployment. - run_nomad_watch(f"start -var ok=true {testjobs[job]}") - run_nomad_watch(f"-x stop {job}") + run_entry_watch(f"start -var ok=true {testjobs[job]}") + run_entry_watch(f"-x stop {job}") finally: - run_nomad_watch(f"-o nolog --debug events -x purge {job}") + run_entry_watch(f"-o nolog --debug events -x purge {job}") -def test_nomad_watch2_canary(): +def test_entry_watch2_canary(): """ Run a service that listens on a port. Check if nomad-tools port works. @@ -93,32 +93,32 @@ def test_nomad_watch2_canary(): output = ["+ hostname", "+ exec httpd", "Deployment completed successfully"] try: # Run nice deployment. - run_nomad_watch(f"start -var ok=true {testjobs[job]}", output=output) + run_entry_watch(f"start -var ok=true {testjobs[job]}", output=output) run_nomadt(f"port {job}", output=[re.compile(r"[0-9\.]+:[0-9]+")]) run_nomadt( f"port -l {job}", output=[re.compile(r"[0-9\.]+ [0-9]+ http [^ ]* [^ ]*")], ) # This should fail and revert deployment. - run_nomad_watch( + run_entry_watch( f"--shutdown-timeout 0 start -var ok=false {testjobs[job]}", output=[ "Failed due to unhealthy allocations - rolling back to job", ], check=False, ) - run_nomad_watch(f"start -var ok=true {testjobs[job]}", output=output) + run_entry_watch(f"start -var ok=true {testjobs[job]}", output=output) run_nomadt(f"port {job}", output=[re.compile(r"[0-9\.]+:[0-9]+")]) run_nomadt( f"port -l {job}", output=[re.compile(r"[0-9\.]+ [0-9]+ http [^ ]* [^ ]*")], ) - run_nomad_watch(f"-o nolog -x stop {job}") + run_entry_watch(f"-o nolog -x stop {job}") finally: - run_nomad_watch(f"-o nolog -x purge {job}") + run_entry_watch(f"-o nolog -x purge {job}") -def test_nomad_watch2_blocked(): +def test_entry_watch2_blocked(): """ Run a job that blocks because not enough memory. Then unblock it and run @@ -127,7 +127,7 @@ def test_nomad_watch2_blocked(): for i in "start run".split(): try: for j in range(2): - run_nomad_watch( + run_entry_watch( f"-o nolog {i} -var block=true {testjobs[job]}", timeout=10, check=124, @@ -137,22 +137,22 @@ def test_nomad_watch2_blocked(): "Dimension memory exhaused", ], ) - run_nomad_watch( + run_entry_watch( f"{i} -var block=false {testjobs[job]}", output=["+ true"] ) finally: - run_nomad_watch(f"-o nolog -x purge {job}") + run_entry_watch(f"-o nolog -x purge {job}") -def test_nomad_watch2_maintask(): +def test_entry_watch2_maintask(): """ Run a job that has all combinations of lifetime property. Check if proper tasks are started. """ job = "test-maintask" try: - run_nomad_watch(f"-x purge {job}") - out = run_nomad_watch( + run_entry_watch(f"-x purge {job}") + out = run_entry_watch( f"start {testjobs[job]}", output=[ "+ echo main", @@ -164,10 +164,10 @@ def test_nomad_watch2_maintask(): assert "+ echo poststop" not in out assert len(mynomad.get(f"job/{job}/allocations")) == 2 finally: - run_nomad_watch(f"-x purge {job}") + run_entry_watch(f"-x purge {job}") -def test_nomad_watch2_multiple(): +def test_entry_watch2_multiple(): job = "test-multiple" uuid = "876f767f-7dbb-4e1f-8625-4dcd39f1adaa" output: List[Union[str, re.Pattern]] = [] @@ -180,23 +180,23 @@ def test_nomad_watch2_multiple(): f"{pre} STOP", re.compile(rf"{pre} START[\S\n ]*{pre} STOP"), ] - run_nomad_watch(f"--purge run {testjobs[job]}", output=output) + run_entry_watch(f"--purge run {testjobs[job]}", output=output) -def test_nomad_watch2_invalidconfig(): +def test_entry_watch2_invalidconfig(): job = "test-invalidconfig" - run_nomad_watch( + run_entry_watch( f"--purge run {testjobs[job]}", check=126, output=["Failed Validation 3 errors occurred"], ) -def test_nomad_watch2_deploymulti(): +def test_entry_watch2_deploymulti(): job = "test-deploymulti" try: - run_nomad_watch(f"-x purge {job}") - run_nomad_watch( + run_entry_watch(f"-x purge {job}") + run_entry_watch( f"start {testjobs[job]}", output=[ re.compile(r"( Allocation .* started.*){2}", re.MULTILINE | re.DOTALL), @@ -206,7 +206,7 @@ def test_nomad_watch2_deploymulti(): re.compile("E>[0-9a-fA-F]*>v0>web> .*response"), ], ) - run_nomad_watch( + run_entry_watch( f"start {testjobs[job]}", output=[ re.compile(r"( Allocation .* started.*){2}", re.MULTILINE | re.DOTALL), @@ -220,7 +220,7 @@ def test_nomad_watch2_deploymulti(): re.compile("E>[0-9a-fA-F]*>v1>web> .*response"), ], ) - run_nomad_watch( + run_entry_watch( f"start -var ok=false {testjobs[job]}", output=[ "Failed due to unhealthy allocations - rolling back to job", @@ -229,14 +229,14 @@ def test_nomad_watch2_deploymulti(): check=False, ) finally: - run_nomad_watch(f" -o none -x purge {job}") + run_entry_watch(f" -o none -x purge {job}") -def test_nomad_watch2_onestays(): +def test_entry_watch2_onestays(): job = "test-onestays" try: - run_nomad_watch(f"-x purge {job}") - run_nomad_watch( + run_entry_watch(f"-x purge {job}") + run_entry_watch( f"start {testjobs[job]}", output=[ re.compile( @@ -250,11 +250,11 @@ def test_nomad_watch2_onestays(): ), ], ) - run_nomad_watch( + run_entry_watch( f"start {testjobs[job]}", output=[], ) - run_nomad_watch( + run_entry_watch( f"start {testjobs[job]}", output=[ # Version 1 @@ -270,6 +270,6 @@ def test_nomad_watch2_onestays(): ), ], ) - run_nomad_watch(f"purge {job}", check=False, timeout=20) + run_entry_watch(f"purge {job}", check=False, timeout=20) finally: - run_nomad_watch(f"-o none -x purge {job}") + run_entry_watch(f"-o none -x purge {job}") diff --git a/tests/integration/test_taskexec.py b/tests/integration/test_taskexec.py index 9a79621..6a6e2c5 100644 --- a/tests/integration/test_taskexec.py +++ b/tests/integration/test_taskexec.py @@ -3,21 +3,21 @@ import shutil from nomad_tools import taskexec -from tests.testlib import get_templatejob, run_nomad_watch +from tests.testlib import get_templatejob, run_entry_watch @contextlib.contextmanager def run_temp_job(): hcl = get_templatejob(script="exec sleep 60") jobid = hcl.id - run_nomad_watch(f"-q -o none -x purge {jobid}") + run_entry_watch(f"-q -o none -x purge {jobid}") try: - run_nomad_watch("-q -o none start -", input=hcl.hcl) + run_entry_watch("-q -o none start -", input=hcl.hcl) taskexec.log.setLevel(level=logging.DEBUG) yield jobid finally: taskexec.log.setLevel(level=logging.INFO) - run_nomad_watch(f"-q -o none -x purge {jobid}") + run_entry_watch(f"-q -o none -x purge {jobid}") def test_taskexec_noutf(): diff --git a/tests/localnomad.py b/tests/localnomad.py index 27a67ba..f992bfa 100755 --- a/tests/localnomad.py +++ b/tests/localnomad.py @@ -9,9 +9,18 @@ parser = argparse.ArgumentParser() parser.add_argument("-l", "--log-level", default="info") +parser.add_argument("-v", "--verbose", action="store_true") +parser.add_argument("--tls", action="store_true") parser.add_argument("version", nargs="?") args = parser.parse_args() -DIR: Path = Path(__file__).parent.parent +os.chdir(Path(__file__).parent.parent) +if args.verbose: + args.log_level = "debug" + +assert Path("/sys/module/bridge"), "ERROR: bridge module not loaded" +assert ( + subprocess.run("docker status".split()).returncode != 0 +), "ERROR: docker does not work" if not args.version: cmdstr: str = "python -m nomad_tools.entrypoint downloadrelease --showversion nomad" @@ -19,19 +28,18 @@ print(f"+ {cmdstr}") args.version = subprocess.check_output(cmd, text=True).strip() -exe: Path = DIR / f"build/bin/nomad{args.version}" +exe: Path = Path(f"./build/bin/nomad{args.version}") if not exe.exists(): cmdstr = f"python -m nomad_tools.entrypoint downloadrelease -p {quote(args.version)} nomad {quote(str(exe))}" cmd = split(cmdstr) print(f"+ {cmdstr}") subprocess.check_call(cmd) -config: Path = DIR / "tests/nomad.hcl" -assert config.exists() cmd: List[str] = [ *(["sudo"] if os.getuid() != 0 else []), str(exe), - *f"agent -dev -config {quote(str(config))} -log-level {args.log_level}".split(), + *f"agent -dev -config ./tests/nomad.d/nomad.hcl -log-level {args.log_level}".split(), + *(["-config", "./tests/nomad.d/tls.hcl"] if args.tls else []), ] cmdstr = " ".join(quote(x) for x in cmd) print(f"+ {cmdstr}") diff --git a/tests/nomad.d/capath/12b561f7.0 b/tests/nomad.d/capath/12b561f7.0 new file mode 120000 index 0000000..f245933 --- /dev/null +++ b/tests/nomad.d/capath/12b561f7.0 @@ -0,0 +1 @@ +global-client-nomad.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/94addf2d.0 b/tests/nomad.d/capath/94addf2d.0 new file mode 120000 index 0000000..1af1412 --- /dev/null +++ b/tests/nomad.d/capath/94addf2d.0 @@ -0,0 +1 @@ +global-server-nomad.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/cb1ff9e3.0 b/tests/nomad.d/capath/cb1ff9e3.0 new file mode 120000 index 0000000..45ea78b --- /dev/null +++ b/tests/nomad.d/capath/cb1ff9e3.0 @@ -0,0 +1 @@ +nomad-agent-ca.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/cb66180a.0 b/tests/nomad.d/capath/cb66180a.0 new file mode 120000 index 0000000..3f491db --- /dev/null +++ b/tests/nomad.d/capath/cb66180a.0 @@ -0,0 +1 @@ +global-cli-nomad.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/global-cli-nomad.pem b/tests/nomad.d/capath/global-cli-nomad.pem new file mode 120000 index 0000000..299f42d --- /dev/null +++ b/tests/nomad.d/capath/global-cli-nomad.pem @@ -0,0 +1 @@ +../global-cli-nomad.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/global-client-nomad.pem b/tests/nomad.d/capath/global-client-nomad.pem new file mode 120000 index 0000000..f2da327 --- /dev/null +++ b/tests/nomad.d/capath/global-client-nomad.pem @@ -0,0 +1 @@ +../global-client-nomad.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/global-server-nomad.pem b/tests/nomad.d/capath/global-server-nomad.pem new file mode 120000 index 0000000..1c7af36 --- /dev/null +++ b/tests/nomad.d/capath/global-server-nomad.pem @@ -0,0 +1 @@ +../global-server-nomad.pem \ No newline at end of file diff --git a/tests/nomad.d/capath/nomad-agent-ca.pem b/tests/nomad.d/capath/nomad-agent-ca.pem new file mode 120000 index 0000000..2091786 --- /dev/null +++ b/tests/nomad.d/capath/nomad-agent-ca.pem @@ -0,0 +1 @@ +../nomad-agent-ca.pem \ No newline at end of file diff --git a/tests/nomad.d/global-cli-nomad-key.pem b/tests/nomad.d/global-cli-nomad-key.pem new file mode 100644 index 0000000..1504a59 --- /dev/null +++ b/tests/nomad.d/global-cli-nomad-key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIHY52UDt19zDVnZEOiFCtTqLciCKsyYL/XMAn/VGb+3roAoGCCqGSM49 +AwEHoUQDQgAEvS9/8VqczPh8H+3zdjWmwahpqSfRM4a/xwclgUOqKIZs9RWGlcnR +ZTXImW1TqOSyn/v9T9LtBKhMVj4XI646Bw== +-----END EC PRIVATE KEY----- diff --git a/tests/nomad.d/global-cli-nomad.pem b/tests/nomad.d/global-cli-nomad.pem new file mode 100644 index 0000000..d66ccd6 --- /dev/null +++ b/tests/nomad.d/global-cli-nomad.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICojCCAkigAwIBAgIQYMLGirZofP0c0D/iHbOguDAKBggqhkjOPQQDAjCBxzEL +MAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2Nv +MRowGAYDVQQJExExMDEgU2Vjb25kIFN0cmVldDEOMAwGA1UEERMFOTQxMDUxFzAV +BgNVBAoTDkhhc2hpQ29ycCBJbmMuMQ4wDAYDVQQLEwVOb21hZDE+MDwGA1UEAxM1 +Tm9tYWQgQWdlbnQgQ0EgNzQxNDExODgwODYxMTYzNDA0NzEzMjU5OTU2MTE2MDIx +ODk5ODkwHhcNMjQwNzAxMTgzMjE4WhcNMjUwNzAxMTgzMjE4WjAbMRkwFwYDVQQD +ExBjbGkuZ2xvYmFsLm5vbWFkMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEvS9/ +8VqczPh8H+3zdjWmwahpqSfRM4a/xwclgUOqKIZs9RWGlcnRZTXImW1TqOSyn/v9 +T9LtBKhMVj4XI646B6OBwDCBvTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYI +KwYBBQUHAwIGCCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAwKQYDVR0OBCIEII/gh5+k +qQDP2dHBbRqTjs/rk5L4GSKqA/rPAU010gIkMCsGA1UdIwQkMCKAIKs8vj0O6+0f +LoPZ+MlJ6tpS5i5P5qx5Q3nhngLjiGqMMCYGA1UdEQQfMB2CEGNsaS5nbG9iYWwu +bm9tYWSCCWxvY2FsaG9zdDAKBggqhkjOPQQDAgNIADBFAiB4Oz9z47sRjSDydcht +DVsaSUOxn19xrx9BNeEJ1ynqSAIhAN0C4lU7s/4xCrx8DozfSMpf82YIYXAHYC66 +bW8TZBLK +-----END CERTIFICATE----- diff --git a/tests/nomad.d/global-client-nomad-key.pem b/tests/nomad.d/global-client-nomad-key.pem new file mode 100644 index 0000000..e6ad20e --- /dev/null +++ b/tests/nomad.d/global-client-nomad-key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIGDb6GqFmlpmi/5gHCPSnMrwIUWseRdOC/5RmYCIjPe1oAoGCCqGSM49 +AwEHoUQDQgAErEhq7wcryT5x7gCH80RVUoDKTUtbf2pdV/s9r5tDmckuvMt9mtmm +4MEaNoFFCgiVEG9V65ubMY+MEYj8YIVJhA== +-----END EC PRIVATE KEY----- diff --git a/tests/nomad.d/global-client-nomad.pem b/tests/nomad.d/global-client-nomad.pem new file mode 100644 index 0000000..14ba898 --- /dev/null +++ b/tests/nomad.d/global-client-nomad.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICrjCCAlSgAwIBAgIQPUFRSKSnKcQ296z38NjtjzAKBggqhkjOPQQDAjCBxzEL +MAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2Nv +MRowGAYDVQQJExExMDEgU2Vjb25kIFN0cmVldDEOMAwGA1UEERMFOTQxMDUxFzAV +BgNVBAoTDkhhc2hpQ29ycCBJbmMuMQ4wDAYDVQQLEwVOb21hZDE+MDwGA1UEAxM1 +Tm9tYWQgQWdlbnQgQ0EgNzQxNDExODgwODYxMTYzNDA0NzEzMjU5OTU2MTE2MDIx +ODk5ODkwHhcNMjQwNzAxMTgzMjEzWhcNMjUwNzAxMTgzMjEzWjAeMRwwGgYDVQQD +ExNjbGllbnQuZ2xvYmFsLm5vbWFkMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE +rEhq7wcryT5x7gCH80RVUoDKTUtbf2pdV/s9r5tDmckuvMt9mtmm4MEaNoFFCgiV +EG9V65ubMY+MEYj8YIVJhKOByTCBxjAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYw +FAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwKQYDVR0OBCIEIOzk +oYiBUa99TtDEURX8AuRjMjSzfRibg4kWzQlzvlSgMCsGA1UdIwQkMCKAIKs8vj0O +6+0fLoPZ+MlJ6tpS5i5P5qx5Q3nhngLjiGqMMC8GA1UdEQQoMCaCE2NsaWVudC5n +bG9iYWwubm9tYWSCCWxvY2FsaG9zdIcEfwAAATAKBggqhkjOPQQDAgNIADBFAiBj +vz3XWn2WKwelMdoaz7ystfRWm/2Y3qtA2bXz5pC8+gIhAK4Pa9vKTN+/BKgbi9Bw +G0ong7mg+uTT4sNhiX3IHv/L +-----END CERTIFICATE----- diff --git a/tests/nomad.d/global-server-nomad-key.pem b/tests/nomad.d/global-server-nomad-key.pem new file mode 100644 index 0000000..5519255 --- /dev/null +++ b/tests/nomad.d/global-server-nomad-key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIFN60gSc8G2N6pAxDc4aV+LfTj9SLIAfKUtOtAtYiQI+oAoGCCqGSM49 +AwEHoUQDQgAEWVU8/MKH4tUM/+ePhyiFvjj8wmM1Mxy4ZyWZ2FozQYHBaaW7Qa5R +9kL/jNjaN8vc8z18edzKNvRMC+qnV8Vnow== +-----END EC PRIVATE KEY----- diff --git a/tests/nomad.d/global-server-nomad.pem b/tests/nomad.d/global-server-nomad.pem new file mode 100644 index 0000000..77b69ab --- /dev/null +++ b/tests/nomad.d/global-server-nomad.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICsDCCAlWgAwIBAgIRAOrZIvnIFKcf01D4OPBOH3EwCgYIKoZIzj0EAwIwgccx +CzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNj +bzEaMBgGA1UECRMRMTAxIFNlY29uZCBTdHJlZXQxDjAMBgNVBBETBTk0MTA1MRcw +FQYDVQQKEw5IYXNoaUNvcnAgSW5jLjEOMAwGA1UECxMFTm9tYWQxPjA8BgNVBAMT +NU5vbWFkIEFnZW50IENBIDc0MTQxMTg4MDg2MTE2MzQwNDcxMzI1OTk1NjExNjAy +MTg5OTg5MB4XDTI0MDcwMTE4MzIwNloXDTI1MDcwMTE4MzIwNlowHjEcMBoGA1UE +AxMTc2VydmVyLmdsb2JhbC5ub21hZDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA +BFlVPPzCh+LVDP/nj4cohb44/MJjNTMcuGclmdhaM0GBwWmlu0GuUfZC/4zY2jfL +3PM9fHncyjb0TAvqp1fFZ6OjgckwgcYwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQW +MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMCkGA1UdDgQiBCBE +QdsiRSc1d2ptHLbWORRQFh8RSGnux3Xb+/9NaUs+EjArBgNVHSMEJDAigCCrPL49 +DuvtHy6D2fjJSeraUuYuT+aseUN54Z4C44hqjDAvBgNVHREEKDAmghNzZXJ2ZXIu +Z2xvYmFsLm5vbWFkgglsb2NhbGhvc3SHBH8AAAEwCgYIKoZIzj0EAwIDSQAwRgIh +AIxB2qBZl8nFPUorw3T9ww+f0DoeOhyhkviV3A5TXdRfAiEA05pYZJcH6O5FiK5W +TgzV/jr+7BMO1MHm5qudm5RvEXc= +-----END CERTIFICATE----- diff --git a/tests/nomad.d/nomad-agent-ca-key.pem b/tests/nomad.d/nomad-agent-ca-key.pem new file mode 100644 index 0000000..93101d4 --- /dev/null +++ b/tests/nomad.d/nomad-agent-ca-key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIBQDp7PPOj2RGuYwJb6CTlVcR9s1uE3kcVWToh4lke0loAoGCCqGSM49 +AwEHoUQDQgAETiMzL/TxQbwT0qre0P+CiRvai5qoah2bkO6tYoAfP0t4e6fpQaua +oE67oYLAmpGyx4cZsNqthv9Wvgi6dY6jeg== +-----END EC PRIVATE KEY----- diff --git a/tests/nomad.d/nomad-agent-ca.pem b/tests/nomad.d/nomad-agent-ca.pem new file mode 100644 index 0000000..8adf635 --- /dev/null +++ b/tests/nomad.d/nomad-agent-ca.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDCjCCAq+gAwIBAgIQN8cSy/bi87sayuHonV5+pTAKBggqhkjOPQQDAjCBxzEL +MAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2Nv +MRowGAYDVQQJExExMDEgU2Vjb25kIFN0cmVldDEOMAwGA1UEERMFOTQxMDUxFzAV +BgNVBAoTDkhhc2hpQ29ycCBJbmMuMQ4wDAYDVQQLEwVOb21hZDE+MDwGA1UEAxM1 +Tm9tYWQgQWdlbnQgQ0EgNzQxNDExODgwODYxMTYzNDA0NzEzMjU5OTU2MTE2MDIx +ODk5ODkwHhcNMjQwNzAxMTgzMjAwWhcNMjkwNjMwMTgzMjAwWjCBxzELMAkGA1UE +BhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRowGAYD +VQQJExExMDEgU2Vjb25kIFN0cmVldDEOMAwGA1UEERMFOTQxMDUxFzAVBgNVBAoT +Dkhhc2hpQ29ycCBJbmMuMQ4wDAYDVQQLEwVOb21hZDE+MDwGA1UEAxM1Tm9tYWQg +QWdlbnQgQ0EgNzQxNDExODgwODYxMTYzNDA0NzEzMjU5OTU2MTE2MDIxODk5ODkw +WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAROIzMv9PFBvBPSqt7Q/4KJG9qLmqhq +HZuQ7q1igB8/S3h7p+lBq5qgTruhgsCakbLHhxmw2q2G/1a+CLp1jqN6o3sweTAO +BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zApBgNVHQ4EIgQgqzy+PQ7r +7R8ug9n4yUnq2lLmLk/mrHlDeeGeAuOIaowwKwYDVR0jBCQwIoAgqzy+PQ7r7R8u +g9n4yUnq2lLmLk/mrHlDeeGeAuOIaowwCgYIKoZIzj0EAwIDSQAwRgIhAMskbbTc +A88pKYFoJAC0qiTIRFKdMUELR2GKq61KGkUrAiEAyiOh5VSBdXicwzkXpclACLRq +BHZ58p6JadCnWzGtZ1s= +-----END CERTIFICATE----- diff --git a/tests/nomad.hcl b/tests/nomad.d/nomad.hcl similarity index 99% rename from tests/nomad.hcl rename to tests/nomad.d/nomad.hcl index 0ab3acd..8687d81 100644 --- a/tests/nomad.hcl +++ b/tests/nomad.d/nomad.hcl @@ -5,6 +5,7 @@ server { enabled = true bootstrap_expect = 1 } + client { enabled = true gc_disk_usage_threshold = 100 @@ -16,14 +17,17 @@ client { } cni_path = "/opt/cni/bin:/usr/lib/cni" } + limits { http_max_conns_per_client = 10000 } + plugin "raw_exec" { config { enabled = true } } + plugin "docker" { config { allow_privileged = true @@ -35,6 +39,7 @@ plugin "docker" { } } } + consul { client_auto_join = false server_auto_join = false diff --git a/tests/nomad.d/tls.hcl b/tests/nomad.d/tls.hcl new file mode 100644 index 0000000..746fa33 --- /dev/null +++ b/tests/nomad.d/tls.hcl @@ -0,0 +1,9 @@ +tls { + http = true + rpc = true + ca_file = "./tests/nomad.d/nomad-agent-ca.pem" + cert_file = "./tests/nomad.d/global-server-nomad.pem" + key_file = "./tests/nomad.d/global-server-nomad-key.pem" + verify_server_hostname = true + verify_https_client = true +} diff --git a/tests/provision.sh b/tests/provision.sh index 4a9dc77..a5dc132 100755 --- a/tests/provision.sh +++ b/tests/provision.sh @@ -31,28 +31,41 @@ cni_install() { sudo rm cni-plugins*.tgz } -nomad_start() { - local pid now endtime - if pid=$(pgrep nomad); then - echo "nomad already running: $(xargs ps aux "$pid")" - return - fi - sudo nomad agent -dev -config ./tests/nomad.hcl & - NOMADPID=$! - # Wait for nomad +wait_for() { now=$(date +%s) endtime=$((now + 30)) - while ! nomad status >/dev/null; do + while ! "$@" >/dev/null; do sleep 0.5 now=$(date +%s) if ((now > endtime)); then - fatal "did not start nomad" + fatal "did not start $*" fi if ! kill -0 "$NOMADPID"; then - fatal "nomad exited" + fatal "$* exited" fi done - nomad status + "$@" +} + +# shellcheck disable=2120 +nomad_run() { + local pid now endtime + if pid=$(pgrep nomad); then + echo "nomad already running: $(xargs ps aux "$pid")" + return + fi + sudo nomad agent -dev -config ./tests/nomad.d/nomad.hcl "$@" & + declare -g NOMADPID=$! +} + +nomad_start() { + nomad_run + wait_for nomad status +} + +nomad_start_tls() { + nomad_run -config ./tests/nomad.d/tls.hcl + wait_for ./tests/tls_env.bash tls -- nomad status } nomad_restart() { @@ -79,10 +92,10 @@ vagrant() { } case "$1" in -cni_install | nomad_install | nomad_start | nomad_restart | vagrant) +cni_install | nomad_install | nomad_start | nomad_start_tls | nomad_restart | vagrant) "$@" ;; *) - fatal "" + fatal "Unknown command: $1" ;; esac diff --git a/tests/test_nomad_cp_complete.py b/tests/test_nomad_cp_complete.py index d99b376..6a5123c 100755 --- a/tests/test_nomad_cp_complete.py +++ b/tests/test_nomad_cp_complete.py @@ -3,7 +3,7 @@ import argparse import os -from nomad_tools.nomad_cp import ArgPath +from nomad_tools.entry_cp import ArgPath parser = argparse.ArgumentParser() parser.add_argument("-d", "--debug", action="store_true") diff --git a/tests/testlib.py b/tests/testlib.py index bbc02a8..466c69d 100644 --- a/tests/testlib.py +++ b/tests/testlib.py @@ -221,14 +221,14 @@ def inner(cmd: str, *args, **kwargs): return inner -run_nomad_cp = prefixed_run( +run_entry_cp = prefixed_run( "python3 -m nomad_tools.entrypoint cp -vv --no-stats --no-pv" ) -run_nomad_watch = prefixed_run( +run_entry_watch = prefixed_run( "python3 -m nomad_tools.entrypoint watch -v --lines -1 --shutdown-timeout 5" ) -run_nomad_vardir = prefixed_run("python3 -m nomad_tools.entrypoint vardir -v") -run_nomad_dockers = prefixed_run("python3 -m nomad_tools.entrypoint dockers -v") +run_entry_vardir = prefixed_run("python3 -m nomad_tools.entrypoint vardir -v") +run_entry_dockers = prefixed_run("python3 -m nomad_tools.entrypoint dockers -v") run_downloadrelease = prefixed_run("python3 -m nomad_tools.entrypoint downloadrelease") run_nomadt = prefixed_run("python3 -m nomad_tools.entrypoint") @@ -254,7 +254,7 @@ def run( input: Optional[str] = None, **kwargs, ): - return run_nomad_vardir( + return run_entry_vardir( f"{self.prefix} {cmds}", check=check, text=text, @@ -275,7 +275,7 @@ def Chdir(where: Union[Path, str]): @contextlib.contextmanager -def nomad_vardir_test(): +def entry_vardir_test(): with tempfile.TemporaryDirectory() as d: with Chdir(d): with tempfile.NamedTemporaryFile() as testf: diff --git a/tests/tls_env.bash b/tests/tls_env.bash new file mode 100755 index 0000000..c0ad62f --- /dev/null +++ b/tests/tls_env.bash @@ -0,0 +1,71 @@ +#!/bin/bash +_DIR="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")/nomad.d" +_r() { + echo "+ $*" >&2 + "$@" +} +_clear_envs() { + envs=$(compgen -v NOMAD_) + if [[ -n "$envs" ]]; then + # shellcheck disable=2086 + _r unset $envs + fi +} +while (($#)); do + case "$1" in + clear) + _clear_envs + ;; + tls) + _clear_envs + _r export NOMAD_ADDR=https://localhost:4646 + _r unset NOMAD_TLS_SERVER_NAME + _r export NOMAD_CACERT="$_DIR"/nomad-agent-ca.pem + _r unset NOMAD_CAPATH + _r export NOMAD_CLIENT_CERT="$_DIR"/global-cli-nomad.pem + _r export NOMAD_CLIENT_KEY="$_DIR"/global-cli-nomad-key.pem + ;; + capath) + _clear_envs + _r export NOMAD_ADDR=https://localhost:4646 + _r unset NOMAD_TLS_SERVER_NAME + _r unset NOMAD_CACERT + _r export NOMAD_CAPATH="$_DIR"/capath + _r export NOMAD_CLIENT_CERT="$_DIR"/global-cli-nomad.pem + _r export NOMAD_CLIENT_KEY="$_DIR"/global-cli-nomad-key.pem + ;; + sni) + _clear_envs + _r export NOMAD_ADDR=https://127.0.0.1:4646 + _r export NOMAD_TLS_SERVER_NAME=localhost + _r export NOMAD_CACERT="$_DIR"/nomad-agent-ca.pem + _r unset NOMAD_CAPATH + _r export NOMAD_CLIENT_CERT="$_DIR"/global-cli-nomad.pem + _r export NOMAD_CLIENT_KEY="$_DIR"/global-cli-nomad-key.pem + ;; + test) + _r export NOMAD_NAMESPACE=default + _r nomad status + _r nomadtools vardir -j nginx@nginx ls + _r python -m nomad_tools.taskexec test-forever test-forever echo Hello world + ;; + testall) + _r "$0" tls -- nomadtools watch start "$_DIR"/../../jobs/test-forever.nomad.hcl + echo + _r "$0" tls test + echo + _r "$0" capath test + echo + _r "$0" sni test + ;; + --) + shift + _r exec "$@" + ;; + *) + echo "Unknown arguments: $*" >&2 + exit 123 + ;; + esac + shift +done diff --git a/tests/unit/test_nomad_cp.py b/tests/unit/test_nomad_cp.py index f65300c..73f1bec 100644 --- a/tests/unit/test_nomad_cp.py +++ b/tests/unit/test_nomad_cp.py @@ -2,7 +2,7 @@ from pathlib import Path -def test_nomad_cp_test(): +def test_entry_cp_test(): script = Path(__file__).parent / "test_nomad_cp.sh" assert script.exists() subprocess.check_call(["bash", str(script)]) diff --git a/tests/unit/test_nomad_gitlab_runner.py b/tests/unit/test_nomad_gitlab_runner.py index b75c11a..52e038b 100644 --- a/tests/unit/test_nomad_gitlab_runner.py +++ b/tests/unit/test_nomad_gitlab_runner.py @@ -1,10 +1,10 @@ from textwrap import dedent -from nomad_tools import nomad_gitlab_runner +from nomad_tools import entry_gitlab_runner from tests.testlib import NamedTemporaryFileContent, run_nomadt -def test_nomad_gitlab_runner_showconfig(): +def test_entry_gitlab_runner_showconfig(): config = """ default: mode: docker @@ -13,14 +13,14 @@ def test_nomad_gitlab_runner_showconfig(): run_nomadt(f"gitlab-runner -vvc {configfile} showconfig") -def test_nomad_gitlab_runner_templater(): +def test_entry_gitlab_runner_templater(): txt = "$ ${ ${} ${fdsfa} $$" - assert nomad_gitlab_runner.OnlyBracedCustomEnvTemplate(txt).substitute() == txt + assert entry_gitlab_runner.OnlyBracedCustomEnvTemplate(txt).substitute() == txt txt = "${CUSTOM_ENV}" - assert nomad_gitlab_runner.OnlyBracedCustomEnvTemplate(txt).substitute() == txt + assert entry_gitlab_runner.OnlyBracedCustomEnvTemplate(txt).substitute() == txt txt = "${CUSTOM_ENV_ABC}" assert ( - nomad_gitlab_runner.OnlyBracedCustomEnvTemplate(txt).substitute( + entry_gitlab_runner.OnlyBracedCustomEnvTemplate(txt).substitute( {"CUSTOM_ENV_ABC": 123} ) == "123" diff --git a/tests/unit/test_nomad_vardir.py b/tests/unit/test_nomad_vardir.py index 19190cb..5e6b197 100644 --- a/tests/unit/test_nomad_vardir.py +++ b/tests/unit/test_nomad_vardir.py @@ -3,12 +3,12 @@ import pytest -from nomad_tools.nomad_vardir import human_size -from tests.testlib import nomad_vardir_test, run_bash +from nomad_tools.entry_vardir import human_size +from tests.testlib import entry_vardir_test, run_bash -def test_nomad_vardir_test(): - with nomad_vardir_test() as t: +def test_entry_vardir_test(): + with entry_vardir_test() as t: val = str(uuid.uuid4()) # putting works? t.run("ls", output=[re.compile("^$")]) @@ -25,8 +25,8 @@ def test_nomad_vardir_test(): t.run("diff a") -def test_nomad_vardir_test2(): - with nomad_vardir_test() as t: +def test_entry_vardir_test2(): + with entry_vardir_test() as t: t.run("put a", check=False) t.run("diff", check=False) t.run("get a", check=False) diff --git a/tests/unit/test_nomad_watch.py b/tests/unit/test_nomad_watch.py index 0f6370d..e089a50 100644 --- a/tests/unit/test_nomad_watch.py +++ b/tests/unit/test_nomad_watch.py @@ -1,6 +1,6 @@ -from tests.testlib import run_nomad_watch +from tests.testlib import run_entry_watch -def test_nomad_watch_multiple_log(): - rr = run_nomad_watch("--log-long --log-short job -", check=False) +def test_entry_watch_multiple_log(): + rr = run_entry_watch("--log-long --log-short job -", check=False) assert rr.returncode != 0