Wait for wait

This commit is contained in:
mvdbeek
2022-06-19 15:56:54 +02:00
parent 5975f72d9c
commit 60b6c47b40
6 changed files with 34 additions and 15 deletions
+2 -2
View File
@@ -6,7 +6,6 @@ import json
import logging
import os
import re
import shlex
import subprocess
import tempfile
@@ -28,6 +27,7 @@ from galaxy.datatypes.sniff import (
)
from galaxy.util import (
nice_size,
shlex_join,
string_as_bool,
unicodify,
)
@@ -219,7 +219,7 @@ class Ipynb(Json):
ofilename = dataset.file_name
log.exception(
'Command "%s" failed. Could not convert the Jupyter Notebook to HTML, defaulting to plain text.',
" ".join(map(shlex.quote, cmd)),
shlex_join(cmd),
)
return open(ofilename, mode="rb"), headers
+2 -2
View File
@@ -4,7 +4,6 @@ import json
import logging
import os
import re
import shlex
import shutil
import sys
import tempfile
@@ -18,6 +17,7 @@ import packaging.version
from galaxy.util import (
commands,
listify,
shlex_join,
smart_str,
which,
)
@@ -237,7 +237,7 @@ class CondaContext(installable.InstallableContext):
env = {}
if self.condarc_override:
env["CONDARC"] = self.condarc_override
cmd_string = " ".join(map(shlex.quote, cmd))
cmd_string = shlex_join(cmd)
kwds = dict()
try:
if stdout_path:
@@ -12,7 +12,6 @@ Build a mulled image with:
import json
import logging
import os
import shlex
import shutil
import stat
import string
@@ -31,6 +30,7 @@ from galaxy.tool_util.deps.docker_util import command_list as docker_command_lis
from galaxy.util import (
commands,
safe_makedirs,
shlex_join,
unicodify,
)
from ._cli import arg_parser
@@ -301,7 +301,7 @@ def mull_targets(
involucro_args.insert(6, "-set")
involucro_args.insert(7, f"TEST_BINDS={','.join(test_bind)}")
cmd = involucro_context.build_command(involucro_args)
print(f"Executing: {' '.join(shlex.quote(_) for _ in cmd)}")
print(f"Executing: {shlex_join(cmd)}")
if dry_run:
return 0
ensure_installed(involucro_context, True)
+7
View File
@@ -13,6 +13,7 @@ import json
import os
import random
import re
import shlex
import shutil
import smtplib
import stat
@@ -77,6 +78,12 @@ from .path import ( # noqa: F401
safe_relpath,
)
try:
shlex_join = shlex.join # type: ignore[attr-defined]
except AttributeError:
# Python < 3.8
shlex_join = lambda split_command: " ".join(map(shlex.quote, split_command)) # noqa: E731
inflector = Inflector()
log = get_logger(__name__)
+1 -1
View File
@@ -365,7 +365,7 @@ def external_chown(path, pwent, external_chown_script, description="file"):
cmd = shlex.split(external_chown_script)
cmd.extend([path, pwent[0], str(pwent[3])])
log.debug(f"Changing ownership of {path} with: {' '.join(map(shlex.quote, cmd))}")
log.debug(f"Changing ownership of {path} with: '{galaxy.util.shlex_join(cmd)}'")
galaxy.util.commands.execute(cmd)
return True
except galaxy.util.commands.CommandLineException as e:
+20 -8
View File
@@ -11,10 +11,14 @@ import time
import pytest
from galaxy.util import unicodify
from galaxy.util import (
shlex_join,
unicodify,
)
from galaxy_test.base.populators import (
DatasetPopulator,
skip_without_tool,
wait_on,
)
from galaxy_test.driver import integration_util
from .test_containerized_jobs import MulledJobTestCases
@@ -323,13 +327,21 @@ class BaseKubernetesIntegrationTestCase(BaseJobEnvironmentIntegrationTestCase, M
self._wait_for_external_state(sa_session=sa_session, job=job, expected=app.model.Job.states.RUNNING)
external_id = job.job_runner_external_id
log_cmd = ["kubectl", "logs", "-l", f"job-name={external_id}"]
p = subprocess.run(log_cmd, capture_output=True, text=True)
if p.returncode:
raise Exception(
f"Command '{' '.join(log_cmd)}' failed with exit code: {p.returncode}.\nstdout: {p.stdout}\nstderr: {p.stderr}"
)
output = p.stdout
def get_kubectl_logs(allow_wait=True):
log_cmd = ["kubectl", "logs", "-l", f"job-name={external_id}"]
p = subprocess.run(log_cmd, capture_output=True, text=True)
if p.returncode:
if allow_wait and "is waiting to start" in p.stderr:
return None
raise Exception(
f"Command '{shlex_join}' failed with exit code: {p.returncode}.\nstdout: {p.stdout}\nstderr: {p.stderr}"
)
return p.stdout
wait_on(get_kubectl_logs, "k8s logs")
output = get_kubectl_logs(allow_wait=False)
EXPECTED_STDOUT = "The bool is not true"
EXPECTED_STDERR = "The bool is very not true"
assert EXPECTED_STDOUT in output