From 0bdf9b62ba95e3375cffe96438cdc5198988c7d3 Mon Sep 17 00:00:00 2001 From: Lubos Mjachky Date: Thu, 16 Nov 2023 12:56:34 +0100 Subject: [PATCH] Include test cases from former pulp-ostree issues closes #59 --- .github/workflows/test.yml | 4 +- CHANGES/59.misc | 1 + .../test_importing_commits_with_import_all.sh | 66 +++++++++++++++++ ..._importing_commits_with_import_commits.sh} | 0 .../pulp_ostree/test_importing_two_refs.sh | 70 +++++++++++++++++++ ...y_content.sh => test_modifying_content.sh} | 0 ...lish.sh => test_syncing_and_publishing.sh} | 0 7 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 CHANGES/59.misc create mode 100755 tests/scripts/pulp_ostree/test_importing_commits_with_import_all.sh rename tests/scripts/pulp_ostree/{test_import_publish.sh => test_importing_commits_with_import_commits.sh} (100%) create mode 100755 tests/scripts/pulp_ostree/test_importing_two_refs.sh rename tests/scripts/pulp_ostree/{test_modify_content.sh => test_modifying_content.sh} (100%) rename tests/scripts/pulp_ostree/{test_sync_publish.sh => test_syncing_and_publishing.sh} (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce1a5c0..5d52b6f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,8 +30,10 @@ jobs: image_tag: "3.24" pulp_api_root: "/relocated/djnd/" - python: "3.10" - image_tag: "3.23" + image_tag: "3.35" lower_bounds: true + - python: "3.11" + image_tag: "latest" steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 diff --git a/CHANGES/59.misc b/CHANGES/59.misc new file mode 100644 index 0000000..200dcda --- /dev/null +++ b/CHANGES/59.misc @@ -0,0 +1 @@ +Added more tests to verify the functionality of importing child commits. diff --git a/tests/scripts/pulp_ostree/test_importing_commits_with_import_all.sh b/tests/scripts/pulp_ostree/test_importing_commits_with_import_all.sh new file mode 100755 index 0000000..a1d046c --- /dev/null +++ b/tests/scripts/pulp_ostree/test_importing_commits_with_import_all.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +# shellcheck source=tests/scripts/config.source +. "$(dirname "$(dirname "$(realpath "$0")")")/config.source" + +cleanup() { + pulp ostree repository destroy --name "cli_test_ostree_repository_import_all_only" || true + pulp ostree distribution destroy --name "cli_test_ostree_distro_import_all_only" || true + pulp orphan cleanup || true +} +trap cleanup EXIT + +# workflow fixed in 2.2, https://github.com/pulp/pulp_ostree/issues/279 +if pulp debug has-plugin --name "ostree" --min-version "2.2.0" +then + workdir=$(mktemp -d) + cd "${workdir}" + + # prepare pulp + expect_succ pulp ostree repository create --name "cli_test_ostree_repository_import_all_only" + expect_succ pulp ostree distribution create --name "cli_test_ostree_distro_import_all_only" \ + --repository "cli_test_ostree_repository_import_all_only" \ + --base-path "cli_test_ostree_distro_import_all_only" + + BASE_URL=$(echo "$OUTPUT" | jq -r ".base_url") + + # first commit + mkdir "${workdir}/first" + cd "${workdir}/first" + ostree --repo="${workdir}/first/repo" init --mode=archive + mkdir "${workdir}/first/files" + echo "one" > files/file.txt + commit=$( + ostree commit --repo "${workdir}/first/repo" --branch ostree-main "${workdir}/first/files/" + ) + + cd "${workdir}/first" + tar czvf repo.tar "repo/" + + # first upload + expect_succ pulp ostree repository import-all --name "cli_test_ostree_repository_import_all_only" \ + --file "repo.tar" \ + --repository_name "repo" + + # second commit + mkdir "${workdir}/second" + cd "${workdir}/second" + mkdir files + echo "two" > files/file2.txt + ostree --repo="${workdir}/second/repo" init --mode=archive + ostree commit --repo repo --branch ostree-main files/ --parent="${commit}" + tar czvf repo.tar repo/ + + # second upload + echo "Uploading and importing second repo" + expect_succ pulp ostree repository import-all --name "cli_test_ostree_repository_import_all_only" \ + --file "repo.tar" \ + --repository_name "repo" + + # local remote repo + ostree --repo="${workdir}/rremote" init + ostree --repo="${workdir}/rremote" remote add --no-gpg-verify iot "$BASE_URL" + expect_succ ostree --repo="${workdir}/rremote" remote refs iot + expect_succ ostree --repo="${workdir}/rremote" remote summary iot + expect_succ ostree --repo="${workdir}/rremote" pull iot ostree-main +fi diff --git a/tests/scripts/pulp_ostree/test_import_publish.sh b/tests/scripts/pulp_ostree/test_importing_commits_with_import_commits.sh similarity index 100% rename from tests/scripts/pulp_ostree/test_import_publish.sh rename to tests/scripts/pulp_ostree/test_importing_commits_with_import_commits.sh diff --git a/tests/scripts/pulp_ostree/test_importing_two_refs.sh b/tests/scripts/pulp_ostree/test_importing_two_refs.sh new file mode 100755 index 0000000..374efeb --- /dev/null +++ b/tests/scripts/pulp_ostree/test_importing_two_refs.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# shellcheck source=tests/scripts/config.source +. "$(dirname "$(dirname "$(realpath "$0")")")/config.source" + +cleanup() { + pulp ostree repository destroy --name "cli_test_ostree_repository_two_refs" || true + pulp ostree distribution destroy --name "cli_test_ostree_distro_two_refs" || true + pulp orphan cleanup || true +} +trap cleanup EXIT + +# workflow fixed in 2.2, https://github.com/pulp/pulp_ostree/issues/277 +if pulp debug has-plugin --name "ostree" --min-version "2.2.0" +then + workdir=$(mktemp -d) + cd "${workdir}" + + # prepare pulp + expect_succ pulp ostree repository create --name "cli_test_ostree_repository_two_refs" + expect_succ pulp ostree distribution create --name "cli_test_ostree_distro_two_refs" \ + --repository "cli_test_ostree_repository_two_refs" \ + --base-path "cli_test_ostree_distro_two_refs" + + BASE_URL=$(echo "$OUTPUT" | jq -r ".base_url") + + # first commit + mkdir "${workdir}/first" + cd "${workdir}/first" + ostree --repo="${workdir}/first/repo" init --mode=archive + mkdir "${workdir}/first/files" + echo "one" > files/file.txt + ostree commit --repo "${workdir}/first/repo" --branch first "${workdir}/first/files/" + + cd "${workdir}/first" + tar czvf repo.tar "repo/" + + # first upload + expect_succ pulp ostree repository import-all \ + --name "cli_test_ostree_repository_two_refs" \ + --file "repo.tar" \ + --repository_name "repo" + + # local remote repo + ostree --repo="${workdir}/rremote" init + ostree --repo="${workdir}/rremote" remote add --no-gpg-verify iot "$BASE_URL" + expect_succ ostree --repo="${workdir}/rremote" remote refs iot + expect_succ ostree --repo="${workdir}/rremote" remote summary iot + + # second commit + mkdir "${workdir}/second" + cd "${workdir}/second" + mkdir files + echo "two" > files/file2.txt + ostree --repo="${workdir}/second/repo" init --mode=archive + ostree commit --repo repo --branch second files/ + tar czvf repo.tar repo/ + + # second upload + expect_succ pulp ostree repository import-all \ + --name "cli_test_ostree_repository_two_refs" \ + --file "repo.tar" \ + --repository_name "repo" + + # fetch refs + expect_succ ostree --repo="${workdir}/rremote" remote refs iot + expect_succ ostree --repo="${workdir}/rremote" remote summary iot + expect_succ ostree --repo="${workdir}/rremote" pull iot second + expect_succ ostree --repo="${workdir}/rremote" pull iot first +fi diff --git a/tests/scripts/pulp_ostree/test_modify_content.sh b/tests/scripts/pulp_ostree/test_modifying_content.sh similarity index 100% rename from tests/scripts/pulp_ostree/test_modify_content.sh rename to tests/scripts/pulp_ostree/test_modifying_content.sh diff --git a/tests/scripts/pulp_ostree/test_sync_publish.sh b/tests/scripts/pulp_ostree/test_syncing_and_publishing.sh similarity index 100% rename from tests/scripts/pulp_ostree/test_sync_publish.sh rename to tests/scripts/pulp_ostree/test_syncing_and_publishing.sh