Skip to content

Commit bb3bdfa

Browse files
committed
Add ability to run tests in parallel [PULP-753]
1 parent b7327cf commit bb3bdfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+389
-408
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,5 @@ jobs:
115115
PULP_ENABLED_PLUGINS: "${{ matrix.pulp_enabled_plugins }}"
116116
OAS_VERSION: "${{ matrix.oas_version }}"
117117
run: |
118-
.ci/run_container.sh make livetest
118+
.ci/run_container.sh make paralleltest
119119
...

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ test: | tests/cli.toml
4141
livetest: | tests/cli.toml
4242
python3 -m pytest -v tests pulp-glue/tests -m live
4343

44+
paralleltest: | tests/cli.toml
45+
python3 -m pytest -v tests pulp-glue/tests -m live -n 8
46+
4447
unittest:
4548
python3 -m pytest -v tests pulp-glue/tests cookiecutter/pulp_filter_extension.py -m "not live"
4649

cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ jobs:
8787
OAS_VERSION: "${{ matrix.oas_version }}"
8888
{%- endraw %}
8989
run: |
90-
.ci/run_container.sh make {% if cookiecutter.unittests %}live{% endif %}test
90+
.ci/run_container.sh make {% if cookiecutter.unittests %}parallel{% endif %}test
9191
...

cookiecutter/ci/{{ cookiecutter.__project_name }}/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ test: | tests/cli.toml
6060
livetest: | tests/cli.toml
6161
python3 -m pytest -v tests {%- if cookiecutter.glue %} pulp-glue{{ cookiecutter.__app_label_suffix }}/tests {%- endif %} -m live
6262

63+
paralleltest: | tests/cli.toml
64+
python3 -m pytest -v tests {%- if cookiecutter.glue %} pulp-glue{{ cookiecutter.__app_label_suffix }}/tests {%- endif %} -m live -n 8
65+
6366
unittest:
6467
python3 -m pytest -v tests {%- if cookiecutter.glue %} pulp-glue{{ cookiecutter.__app_label_suffix }}/tests {%- endif %}
6568
{%- if cookiecutter.__app_label_suffix == "" %} cookiecutter/pulp_filter_extension.py {%- endif %} -m "not live"

pulpcore/cli/core/task.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ def cancel(
153153
states.append("running")
154154
if states:
155155
tasks = task_ctx.list(limit=1 << 64, offset=0, parameters={"state__in": states})
156+
if pulp_ctx.api._dry_run:
157+
raise click.ClickException(
158+
_("Trying to cancel {} tasks in safe-mode, aborting").format(len(tasks))
159+
)
156160
for task in tasks:
157161
task_ctx.cancel(task["pulp_href"], background=True)
158162
for task in tasks:

test_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Test requirements
22
pytest>=7.0.0,<8.5
3+
pytest-xdist
34
pytest-subtests>=0.12.0,<0.15
45
python-gnupg>=0.5.0,<0.6
56
trustme>=1.1.0,<1.3

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def pulp_cli_vars(pulp_cli_vars: t.Dict[str, str]) -> t.Dict[str, str]:
1414
result.update(
1515
{
1616
"FILE_REMOTE_URL": urljoin(PULP_FIXTURES_URL, "/file/PULP_MANIFEST"),
17+
"FILE_REMOTE2_URL": urljoin(PULP_FIXTURES_URL, "/file2/PULP_MANIFEST"),
1718
"FILE_LARGE_REMOTE_URL": urljoin(PULP_FIXTURES_URL, "/file-perf/PULP_MANIFEST"),
1819
"CONTAINER_REMOTE_URL": "https://quay.io",
1920
"CONTAINER_IMAGE": "libpod/alpine",

tests/scripts/pulp_ansible/test_content.sh

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,34 @@ set -eu
77
pulp debug has-plugin --name "ansible" || exit 23
88

99
cleanup() {
10-
pulp ansible repository destroy --name "cli_test_ansible_repository" || true
11-
pulp ansible repository destroy --name "cli_test_ansible_repository_verify" || true
12-
pulp ansible repository destroy --name "cli_test_ansible_repository_upload" || true
10+
pulp ansible repository destroy --name "cli_test_ansible_content_repository" || true
11+
pulp ansible repository destroy --name "cli_test_ansible_content_repository_verify" || true
12+
pulp ansible repository destroy --name "cli_test_ansible_content_repository_upload" || true
1313
}
1414
trap cleanup EXIT
1515

16-
pulp orphan cleanup --protection-time 0
1716

1817
if pulp debug has-plugin --name "ansible" --specifier ">=0.15.0"
1918
then
2019
gpg --output pulp_pubkey.key --armor --export "pulp-fixture-signing-key"
21-
expect_succ pulp ansible repository create --name "cli_test_ansible_repository_verify" --gpgkey @pulp_pubkey.key
20+
expect_succ pulp ansible repository create --name "cli_test_ansible_content_repository_verify" --gpgkey @pulp_pubkey.key
2221
else
23-
expect_succ pulp ansible repository create --name "cli_test_ansible_repository_verify"
22+
expect_succ pulp ansible repository create --name "cli_test_ansible_content_repository_verify"
2423
fi
2524

2625
# Test ansible collection-version upload
2726
wget "https://galaxy.ansible.com/download/ansible-posix-1.3.0.tar.gz"
2827
sha256=$(sha256sum ansible-posix-1.3.0.tar.gz | cut -d' ' -f1)
2928

30-
expect_succ pulp ansible repository create --name "cli_test_ansible_repository_upload"
31-
expect_succ pulp ansible content upload --file "ansible-posix-1.3.0.tar.gz" --repository "cli_test_ansible_repository_upload"
29+
expect_succ pulp ansible repository create --name "cli_test_ansible_content_repository_upload"
30+
expect_succ pulp ansible content upload --file "ansible-posix-1.3.0.tar.gz" --repository "cli_test_ansible_content_repository_upload"
3231
expect_succ pulp artifact list --sha256 "$sha256"
3332
test "$(echo "$OUTPUT" | jq -r length)" -eq "1"
3433
expect_succ pulp ansible content list --name "posix" --namespace "ansible" --version "1.3.0"
3534
test "$(echo "$OUTPUT" | jq -r length)" -eq "1"
3635
content_href="$(echo "$OUTPUT" | jq -r .[0].pulp_href)"
3736
expect_succ pulp ansible content show --href "$content_href"
38-
expect_succ pulp ansible repository content list --repository "cli_test_ansible_repository_upload" --version 1
37+
expect_succ pulp ansible repository content list --repository "cli_test_ansible_content_repository_upload" --version 1
3938
test "$(echo "$OUTPUT" | jq -r length)" -eq "1"
4039

4140
# Test ansible role upload
@@ -57,29 +56,29 @@ then
5756
tar --extract --file="ansible-posix-1.3.0.tar.gz" "MANIFEST.json"
5857
collection_path="$(realpath 'MANIFEST.json')"
5958
signature_path="$("$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")"/assets/sign_detached.sh "$collection_path" | jq -r .signature)"
60-
expect_succ pulp ansible content --type "signature" upload --file "$signature_path" --collection "$content_href" --repository "cli_test_ansible_repository_verify"
59+
expect_succ pulp ansible content --type "signature" upload --file "$signature_path" --collection "$content_href" --repository "cli_test_ansible_content_repository_verify"
6160
expect_succ pulp ansible content --type "signature" list --collection "$content_href" --pubkey-fingerprint "0C1A894EBB86AFAE218424CADDEF3019C2D4A8CF"
6261
test "$(echo "$OUTPUT" | jq -r length)" -eq "1"
6362
content3_href="$(echo "$OUTPUT" | jq -r .[0].pulp_href)"
6463
expect_succ pulp ansible content --type "signature" show --href "$content3_href"
6564
fi
6665

6766
# New content commands
68-
expect_succ pulp ansible repository create --name "cli_test_ansible_repository"
69-
expect_succ pulp ansible repository content add --repository "cli_test_ansible_repository" --name "posix" --namespace "ansible" --version "1.3.0"
70-
expect_succ pulp ansible repository content list --repository "cli_test_ansible_repository" --version 1
67+
expect_succ pulp ansible repository create --name "cli_test_ansible_content_repository"
68+
expect_succ pulp ansible repository content add --repository "cli_test_ansible_content_repository" --name "posix" --namespace "ansible" --version "1.3.0"
69+
expect_succ pulp ansible repository content list --repository "cli_test_ansible_content_repository" --version 1
7170
test "$(echo "$OUTPUT" | jq -r length)" -eq "1"
72-
expect_succ pulp ansible repository content --type "role" add --repository "cli_test_ansible_repository" --name "kubernetes-modules" --namespace "ansible" --version "0.0.1"
73-
expect_succ pulp ansible repository content --type "role" list --repository "cli_test_ansible_repository" --version 2
71+
expect_succ pulp ansible repository content --type "role" add --repository "cli_test_ansible_content_repository" --name "kubernetes-modules" --namespace "ansible" --version "0.0.1"
72+
expect_succ pulp ansible repository content --type "role" list --repository "cli_test_ansible_content_repository" --version 2
7473
test "$(echo "$OUTPUT" | jq -r length)" -eq "1"
7574

7675
if pulp debug has-plugin --name "core" --specifier ">=3.11.0"
7776
then
78-
expect_succ pulp ansible repository content list --repository "cli_test_ansible_repository" --version 2 --all-types
77+
expect_succ pulp ansible repository content list --repository "cli_test_ansible_content_repository" --version 2 --all-types
7978
test "$(echo "$OUTPUT" | jq -r length)" -eq "2"
8079
fi
8180

82-
expect_succ pulp ansible repository content remove --repository "cli_test_ansible_repository" --href "$content_href"
83-
expect_succ pulp ansible repository content remove --repository "cli_test_ansible_repository" --href "$content2_href"
84-
expect_succ pulp ansible repository content list --repository "cli_test_ansible_repository"
81+
expect_succ pulp ansible repository content remove --repository "cli_test_ansible_content_repository" --href "$content_href"
82+
expect_succ pulp ansible repository content remove --repository "cli_test_ansible_content_repository" --href "$content2_href"
83+
expect_succ pulp ansible repository content list --repository "cli_test_ansible_content_repository"
8584
test "$(echo "$OUTPUT" | jq -r length)" -eq "0"

tests/scripts/pulp_ansible/test_distribution.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ set -eu
77
pulp debug has-plugin --name "ansible" || exit 23
88

99
cleanup() {
10-
pulp ansible repository destroy --name "cli_test_ansible_repository" || true
10+
pulp ansible repository destroy --name "cli_test_ansible_distribution_repository" || true
1111
pulp ansible distribution destroy --name "cli_test_ansible_distro" || true
1212
pulp ansible distribution destroy --name "cli_test_ansible_ver_distro" || true
1313
}
1414
trap cleanup EXIT
1515

16-
expect_succ pulp ansible repository create --name "cli_test_ansible_repository"
16+
expect_succ pulp ansible repository create --name "cli_test_ansible_distribution_repository"
1717

1818
expect_succ pulp ansible distribution create --name "cli_test_ansible_distro" \
1919
--base-path "cli_test_ansible_distro" \
20-
--repository "cli_test_ansible_repository"
20+
--repository "cli_test_ansible_distribution_repository"
2121

2222
expect_succ pulp ansible distribution create --name "cli_test_ansible_ver_distro" \
2323
--base-path "cli_test_ansible_ver_distro" \
24-
--repository "cli_test_ansible_repository" \
24+
--repository "cli_test_ansible_distribution_repository" \
2525
--version "0"
2626

2727
expect_succ pulp ansible distribution list

tests/scripts/pulp_ansible/test_sign.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,24 @@ pulp debug has-plugin --name "ansible" --specifier ">=0.12.0" || exit 23
88
[ "$(pulp signing-service list --name "sign_ansible" | jq 'length')" = "1" ] || exit 23
99

1010
cleanup() {
11-
pulp ansible remote -t "collection" destroy --name "cli_test_ansible_collection_remote" || true
12-
pulp ansible repository destroy --name "cli_test_ansible_repository" || true
13-
pulp orphan cleanup || true
11+
pulp ansible remote -t "collection" destroy --name "cli_test_ansible_sign_remote" || true
12+
pulp ansible repository destroy --name "cli_test_ansible_sign_repository" || true
1413
}
1514
trap cleanup EXIT
1615

1716
# Prepare
18-
expect_succ pulp ansible remote -t "collection" create --name "cli_test_ansible_collection_remote" \
17+
expect_succ pulp ansible remote -t "collection" create --name "cli_test_ansible_sign_remote" \
1918
--url "$ANSIBLE_COLLECTION_REMOTE_URL" --requirements "collections:
2019
- robertdebock.ansible_development_environment"
21-
expect_succ pulp ansible repository create --name "cli_test_ansible_repository"
20+
expect_succ pulp ansible repository create --name "cli_test_ansible_sign_repository"
2221
HREF="$(echo "$OUTPUT" | jq -r '.pulp_href')"
23-
expect_succ pulp ansible repository sync --repository "cli_test_ansible_repository" --remote "cli_test_ansible_collection_remote"
22+
expect_succ pulp ansible repository sync --repository "cli_test_ansible_sign_repository" --remote "cli_test_ansible_sign_remote"
2423

2524
# Test sign
26-
expect_succ pulp ansible repository sign --repository "cli_test_ansible_repository" --signing-service "sign_ansible"
25+
expect_succ pulp ansible repository sign --repository "cli_test_ansible_sign_repository" --signing-service "sign_ansible"
2726

2827
# Verify sign
2928
expect_succ pulp ansible repository version list --repository "$HREF"
3029
test "$(echo "$OUTPUT" | jq -r length)" -eq 3
31-
expect_succ pulp ansible repository version show --repository "cli_test_ansible_repository" --version 2
30+
expect_succ pulp ansible repository version show --repository "cli_test_ansible_sign_repository" --version 2
3231
test "$(echo "$OUTPUT" | jq -r '.content_summary.present."ansible.collection_signature".count')" -gt 0

0 commit comments

Comments
 (0)