|
1 | 1 | """Tests for docker engine."""
|
| 2 | +import json |
2 | 3 | import re
|
3 | 4 | from pathlib import Path
|
4 | 5 | from shutil import which
|
5 | 6 |
|
| 7 | +import pytest |
| 8 | + |
6 | 9 | from cwltool.main import main
|
7 | 10 |
|
8 |
| -from .util import get_data, get_main_output, needs_docker |
| 11 | +from .util import ( |
| 12 | + get_data, |
| 13 | + get_main_output, |
| 14 | + needs_docker, |
| 15 | + needs_podman, |
| 16 | + needs_singularity, |
| 17 | +) |
9 | 18 |
|
10 | 19 |
|
11 | 20 | @needs_docker
|
@@ -136,3 +145,121 @@ def test_docker_strict_memory_limit_warning(tmp_path: Path) -> None:
|
136 | 145 | stderr = re.sub(r"\s\s+", " ", stderr)
|
137 | 146 | assert result_code == 0
|
138 | 147 | assert "Skipping Docker software container '--memory' limit" in stderr
|
| 148 | + |
| 149 | + |
| 150 | +@needs_docker |
| 151 | +def test_docker_required_secfile(tmp_path: Path) -> None: |
| 152 | + result_code, stdout, stderr = get_main_output( |
| 153 | + [ |
| 154 | + "--outdir", |
| 155 | + str(tmp_path), |
| 156 | + get_data("tests/secondary-files-required-container.cwl"), |
| 157 | + ] |
| 158 | + ) |
| 159 | + assert result_code == 0, stderr |
| 160 | + assert ( |
| 161 | + json.loads(stdout)["output"]["secondaryFiles"][0]["checksum"] |
| 162 | + == "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709" |
| 163 | + ) |
| 164 | + |
| 165 | + |
| 166 | +@needs_podman |
| 167 | +def test_podman_required_secfile(tmp_path: Path) -> None: |
| 168 | + result_code, stdout, stderr = get_main_output( |
| 169 | + [ |
| 170 | + "--podman", |
| 171 | + "--outdir", |
| 172 | + str(tmp_path), |
| 173 | + get_data("tests/secondary-files-required-container.cwl"), |
| 174 | + ] |
| 175 | + ) |
| 176 | + assert result_code == 0, stderr |
| 177 | + assert ( |
| 178 | + json.loads(stdout)["output"]["secondaryFiles"][0]["checksum"] |
| 179 | + == "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709" |
| 180 | + ) |
| 181 | + |
| 182 | + |
| 183 | +@needs_singularity |
| 184 | +def test_singularity_required_secfile(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: |
| 185 | + singularity_dir = tmp_path / "singularity" |
| 186 | + singularity_dir.mkdir() |
| 187 | + monkeypatch.setenv("CWL_SINGULARITY_CACHE", str(singularity_dir)) |
| 188 | + |
| 189 | + result_code, stdout, stderr = get_main_output( |
| 190 | + [ |
| 191 | + "--singularity", |
| 192 | + "--outdir", |
| 193 | + str(tmp_path / "out"), |
| 194 | + get_data("tests/secondary-files-required-container.cwl"), |
| 195 | + ] |
| 196 | + ) |
| 197 | + assert result_code == 0, stderr |
| 198 | + assert ( |
| 199 | + json.loads(stdout)["output"]["secondaryFiles"][0]["checksum"] |
| 200 | + == "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709" |
| 201 | + ) |
| 202 | + |
| 203 | + |
| 204 | +@needs_docker |
| 205 | +def test_docker_required_missing_secfile(tmp_path: Path) -> None: |
| 206 | + result_code, stdout, stderr = get_main_output( |
| 207 | + [ |
| 208 | + "--outdir", |
| 209 | + str(tmp_path), |
| 210 | + get_data("tests/secondary-files-required-missing-container.cwl"), |
| 211 | + ] |
| 212 | + ) |
| 213 | + assert result_code == 1, stderr |
| 214 | + stderr = re.sub(r"\s\s+", " ", stderr) |
| 215 | + assert "Job error:" in stderr |
| 216 | + assert "Error collecting output for parameter 'output'" in stderr |
| 217 | + assert ( |
| 218 | + "tests/secondary-files-required-missing-container.cwl:16:5: Missing required secondary file" |
| 219 | + ) |
| 220 | + assert "file.ext3" in stderr |
| 221 | + |
| 222 | + |
| 223 | +@needs_podman |
| 224 | +def test_podman_required_missing_secfile(tmp_path: Path) -> None: |
| 225 | + result_code, stdout, stderr = get_main_output( |
| 226 | + [ |
| 227 | + "--podman", |
| 228 | + "--outdir", |
| 229 | + str(tmp_path), |
| 230 | + get_data("tests/secondary-files-required-missing-container.cwl"), |
| 231 | + ] |
| 232 | + ) |
| 233 | + assert result_code == 1, stderr |
| 234 | + stderr = re.sub(r"\s\s+", " ", stderr) |
| 235 | + assert "Job error:" in stderr |
| 236 | + assert "Error collecting output for parameter 'output'" in stderr |
| 237 | + assert ( |
| 238 | + "tests/secondary-files-required-missing-container.cwl:16:5: Missing required secondary file" |
| 239 | + ) |
| 240 | + assert "file.ext3" in stderr |
| 241 | + |
| 242 | + |
| 243 | +@needs_singularity |
| 244 | +def test_singularity_required_missing_secfile( |
| 245 | + tmp_path: Path, monkeypatch: pytest.MonkeyPatch |
| 246 | +) -> None: |
| 247 | + singularity_dir = tmp_path / "singularity" |
| 248 | + singularity_dir.mkdir() |
| 249 | + monkeypatch.setenv("CWL_SINGULARITY_CACHE", str(singularity_dir)) |
| 250 | + result_code, stdout, stderr = get_main_output( |
| 251 | + [ |
| 252 | + "--singularity", |
| 253 | + "--outdir", |
| 254 | + str(tmp_path), |
| 255 | + get_data("tests/secondary-files-required-missing-container.cwl"), |
| 256 | + ] |
| 257 | + ) |
| 258 | + assert result_code == 1, stderr |
| 259 | + stderr = re.sub(r"\s\s+", " ", stderr) |
| 260 | + assert "Job error:" in stderr |
| 261 | + assert "Error collecting output for parameter 'output'" in stderr |
| 262 | + assert ( |
| 263 | + "tests/secondary-files-required-missing-container.cwl:16:5: Missing required secondary file" |
| 264 | + ) |
| 265 | + assert "file.ext3" in stderr |
0 commit comments