Skip to content

Commit b3e231e

Browse files
committed
Merge branch 'main' into run-id-always
* main: Switched from cmd to command (#615) Hotfix for check on frequency provider Tests run_until must be guard-claused with cleanup routine (#616) Fix check if stderr is empty (#613) Bump uvicorn[standard] from 0.24.0.post1 to 0.25.0 (#612) Fxing the network provider stderror
2 parents c9539a0 + ad03a9f commit b3e231e

File tree

7 files changed

+39
-20
lines changed

7 files changed

+39
-20
lines changed

docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
gunicorn==21.2.0
22
psycopg[binary]==3.1.16
33
fastapi==0.105.0
4-
uvicorn[standard]==0.24.0.post1
4+
uvicorn[standard]==0.25.0
55
pandas==2.1.4
66
PyYAML==6.0.1
77
anybadge==1.14.0

lib/schema_checker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def check_usage_scenario(self, usage_scenario):
102102
Optional("setup-commands"): [str],
103103
Optional("volumes"): self.single_or_list(str),
104104
Optional("folder-destination"):str,
105-
Optional("cmd"): str,
105+
Optional("command"): str,
106106
Optional("log-stdout"): bool,
107107
Optional("log-stderr"): bool,
108108
Optional("read-notes-stdout"): bool,
@@ -130,6 +130,7 @@ def check_usage_scenario(self, usage_scenario):
130130
Optional("compose-file"): Use(self.validate_compose_include)
131131
}, ignore_extra_keys=True)
132132

133+
133134
# This check is necessary to do in a seperate pass. If tried to bake into the schema object above,
134135
# it will not know how to handle the value passed when it could be either a dict or list
135136
if 'networks' in usage_scenario:
@@ -139,6 +140,8 @@ def check_usage_scenario(self, usage_scenario):
139140
service = usage_scenario['services'][service_name]
140141
if 'image' not in service and 'build' not in service:
141142
raise SchemaError("The 'image' key under services is required when 'build' key is not present.")
143+
if 'cmd' in service:
144+
raise SchemaError("The 'cmd' key under services is not supported anymore. Please migrate to 'command'")
142145

143146
usage_scenario_schema.validate(usage_scenario)
144147

metric_providers/cpu/frequency/sysfs/core/provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ def check_system(self):
2121
file.read()
2222
except PermissionError as exc:
2323
raise MetricProviderConfigurationError(f"{self._metric_name} provider could not be started.\nCannot read the path for the CPU frequency in sysfs.\n\nAre you running in a VM / cloud / shared hosting?\nIf so please disable the {self._metric_name} provider in the config.yml") from exc
24-
raise MetricProviderConfigurationError(f"{self._metric_name} provider could not be started.\nCould not find the path for the CPU frequency in sysfs.\n\nAre you running in a VM / cloud / shared hosting? \nIf so please disable the {self._metric_name} provider in the config.yml")
24+
else:
25+
raise MetricProviderConfigurationError(f"{self._metric_name} provider could not be started.\nCould not find the path for the CPU frequency in sysfs.\n\nAre you running in a VM / cloud / shared hosting? \nIf so please disable the {self._metric_name} provider in the config.yml")

runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,6 @@ def setup_services(self):
830830

831831
docker_run_string.append(self.clean_image_name(service['image']))
832832

833-
if 'cmd' in service: # must come last
834-
docker_run_string.append(service['cmd'])
835-
836833
# Before starting the container, check if the dependent containers are "ready".
837834
# If not, wait for some time. If the container is not ready after a certain time, throw an error.
838835
# Currently we consider "ready" only as "running".
@@ -861,6 +858,9 @@ def setup_services(self):
861858
if state != "running":
862859
raise RuntimeError(f"Dependent container '{dependent_container}' of '{container_name}' is not running after waiting for {time_waited} sec! Consider checking your service configuration, the entrypoint of the container or the logs of the container.")
863860

861+
if 'command' in service: # must come last
862+
docker_run_string.append(service['command'])
863+
864864
print(f"Running docker run with: {' '.join(docker_run_string)}")
865865

866866
# docker_run_string must stay as list, cause this forces items to be quoted and escaped and prevents
@@ -962,7 +962,7 @@ def start_metric_providers(self, allow_container=True, allow_other=True):
962962

963963
stderr_read = metric_provider.get_stderr()
964964
print(f"Stderr check on {metric_provider.__class__.__name__}")
965-
if stderr_read is not None:
965+
if stderr_read is not None and str(stderr_read):
966966
raise RuntimeError(f"Stderr on {metric_provider.__class__.__name__} was NOT empty: {stderr_read}")
967967

968968

@@ -1096,7 +1096,7 @@ def stop_metric_providers(self):
10961096
continue
10971097

10981098
stderr_read = metric_provider.get_stderr()
1099-
if stderr_read is not None:
1099+
if stderr_read is not None and str(stderr_read):
11001100
errors.append(f"Stderr on {metric_provider.__class__.__name__} was NOT empty: {stderr_read}")
11011101

11021102
metric_provider.stop_profiling()

tests/data/test_cases/subdir_volume_loading/subdir/usage_scenario_subdir.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
volumes:
1414
- ./subdir2/testfile2:/tmp/testfile2-correctly-mounted
1515
- ./subdir2/subdir3/testfile3:/tmp/testfile3-correctly-mounted
16-
cmd: sh
16+
command: sh
1717

1818
flow:
1919
- name: Cat Subdir2

tests/data/usage_scenarios/cmd_stress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
type: container
1010
image: gcb_stress
1111
build: .
12-
cmd: sh
12+
command: sh
1313

1414
flow:
1515
- name: Stress

tests/test_usage_scenario.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,22 +329,34 @@ def test_depends_on_huge():
329329

330330
def test_depends_on_error_not_running():
331331
runner = Tests.setup_runner(usage_scenario='depends_on_error_not_running.yml', dry_run=True)
332-
with pytest.raises(RuntimeError) as e:
333-
Tests.run_until(runner, 'setup_services')
332+
try:
333+
with pytest.raises(RuntimeError) as e:
334+
Tests.run_until(runner, 'setup_services')
335+
finally:
336+
runner.cleanup()
337+
334338
assert "Dependent container 'test-container-2' of 'test-container-1' is not running" in str(e.value) , \
335339
Tests.assertion_info('test-container-2 is not running', str(e.value))
336340

337341
def test_depends_on_error_cyclic_dependency():
338342
runner = Tests.setup_runner(usage_scenario='depends_on_error_cycle.yml', dry_run=True)
339-
with pytest.raises(RuntimeError) as e:
340-
Tests.run_until(runner, 'setup_services')
343+
try:
344+
with pytest.raises(RuntimeError) as e:
345+
Tests.run_until(runner, 'setup_services')
346+
finally:
347+
runner.cleanup()
348+
341349
assert "Cycle found in depends_on definition with service 'test-container-1'" in str(e.value) , \
342350
Tests.assertion_info('cycle in depends_on with test-container-1', str(e.value))
343351

344352
def test_depends_on_error_unsupported_long_form():
345353
runner = Tests.setup_runner(usage_scenario='depends_on_error_unsupported_long_form.yml', dry_run=True)
346-
with pytest.raises(RuntimeError) as e:
347-
Tests.run_until(runner, 'setup_services')
354+
try:
355+
with pytest.raises(RuntimeError) as e:
356+
Tests.run_until(runner, 'setup_services')
357+
finally:
358+
runner.cleanup()
359+
348360
assert "long form" in str(e.value) , \
349361
Tests.assertion_info('long form is not supported', str(e.value))
350362

@@ -411,7 +423,7 @@ def test_container_is_in_network():
411423
Tests.cleanup(runner)
412424
assert 'test-container' in inspect, Tests.assertion_info('test-container', inspect)
413425

414-
# cmd: [str] (optional)
426+
# command: [str] (optional)
415427
# Command to be executed when container is started.
416428
# When container does not have a daemon running typically a shell
417429
# is started here to have the container running like bash or sh
@@ -454,9 +466,12 @@ def test_uri_local_dir():
454466

455467
def test_uri_local_dir_missing():
456468
runner = Tests.setup_runner(usage_scenario='basic_stress.yml', uri='/tmp/missing')
457-
with pytest.raises(FileNotFoundError) as e:
458-
runner.run()
459-
expected_exception = 'No such file or directory: \'/tmp/missing\''
469+
try:
470+
with pytest.raises(FileNotFoundError) as e:
471+
runner.run()
472+
expected_exception = 'No such file or directory: \'/tmp/missing\''
473+
finally:
474+
runner.cleanup()
460475
assert expected_exception in str(e.value),\
461476
Tests.assertion_info(f"Exception: {expected_exception}", str(e.value))
462477

0 commit comments

Comments
 (0)