From b34aa1326e1126187d150937ad4b1e949c88705e Mon Sep 17 00:00:00 2001 From: Ross Williams Date: Wed, 13 Oct 2021 02:23:29 +0000 Subject: [PATCH] pkgng: make integration test package more flexible Make integration test package building template-based, so more flexible if in the future the name of the test package, currently `zsh`, must change. --- .../pkgng/files/zsh_test_package_manifests/COMPACT_MANIFEST | 1 - .../targets/pkgng/files/zsh_test_package_manifests/MANIFEST | 1 - .../integration/targets/pkgng/tasks/create-outofdate-pkg.yml | 4 ++-- .../templates/test_package_manifests/COMPACT_MANIFEST.json.j2 | 1 + .../pkgng/templates/test_package_manifests/MANIFEST.json.j2 | 1 + .../templates/test_package_manifests/test_package_metadata.j2 | 1 + tests/integration/targets/pkgng/vars/main.yml | 3 ++- 7 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 tests/integration/targets/pkgng/files/zsh_test_package_manifests/COMPACT_MANIFEST delete mode 100644 tests/integration/targets/pkgng/files/zsh_test_package_manifests/MANIFEST create mode 100644 tests/integration/targets/pkgng/templates/test_package_manifests/COMPACT_MANIFEST.json.j2 create mode 100644 tests/integration/targets/pkgng/templates/test_package_manifests/MANIFEST.json.j2 create mode 100644 tests/integration/targets/pkgng/templates/test_package_manifests/test_package_metadata.j2 diff --git a/tests/integration/targets/pkgng/files/zsh_test_package_manifests/COMPACT_MANIFEST b/tests/integration/targets/pkgng/files/zsh_test_package_manifests/COMPACT_MANIFEST deleted file mode 100644 index 86613b56ed..0000000000 --- a/tests/integration/targets/pkgng/files/zsh_test_package_manifests/COMPACT_MANIFEST +++ /dev/null @@ -1 +0,0 @@ -{"name":"zsh","origin":"shells/zsh","version":"0","comment":"The Z shell (bogus test package)","maintainer":"bapt@FreeBSD.org","www":"https://www.zsh.org/","abi":"FreeBSD:*:*","arch":"freebsd:*:*","prefix":"/usr/local","flatsize":0,"licenselogic":"single","licenses":["ZSH"],"desc":"Zsh is the Swiss Army knife of shells. It combines the most popular\nfeatures of every other shell, and then lets you customize every\ninch of it. Users of bourne-style and C-style shells will feel at\nhome in it.\n\nZsh does intelligent completion, spell-checking, has a rich syntax\nfor precise globbing, and is fully extensible through plugin\nsystems.\n\nTo fire up the zsh completion system, type the following commands:\n\n\t$ autoload -U compinstall\n\t$ compinstall\n\nWWW: https://www.zsh.org/","categories":["shells"]} diff --git a/tests/integration/targets/pkgng/files/zsh_test_package_manifests/MANIFEST b/tests/integration/targets/pkgng/files/zsh_test_package_manifests/MANIFEST deleted file mode 100644 index 37ae7ed49d..0000000000 --- a/tests/integration/targets/pkgng/files/zsh_test_package_manifests/MANIFEST +++ /dev/null @@ -1 +0,0 @@ -{"name":"zsh","origin":"shells/zsh","version":"0","comment":"The Z shell (bogus test package)","maintainer":"bapt@FreeBSD.org","www":"https://www.zsh.org/","abi":"FreeBSD:*:*","arch":"freebsd:*:*","prefix":"/usr/local","flatsize":0,"licenselogic":"single","licenses":["ZSH"],"desc":"Zsh is the Swiss Army knife of shells. It combines the most popular\nfeatures of every other shell, and then lets you customize every\ninch of it. Users of bourne-style and C-style shells will feel at\nhome in it.\n\nZsh does intelligent completion, spell-checking, has a rich syntax\nfor precise globbing, and is fully extensible through plugin\nsystems.\n\nTo fire up the zsh completion system, type the following commands:\n\n\t$ autoload -U compinstall\n\t$ compinstall\n\nWWW: https://www.zsh.org/","categories":["shells"],"files":{}} diff --git a/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml b/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml index 4370a17557..8eb890217c 100644 --- a/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml +++ b/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml @@ -16,8 +16,8 @@ path: '{{ pkgng_test_outofdate_pkg_tempdir }}' - name: Copy intentionally out-of-date package manifests to testhost - copy: - src: zsh_test_package_manifests/{{ item }} + template: + src: test_package_manifests/{{ item }}.json.j2 # Plus-sign must be added at the destination # CI doesn't like files with '+' in them in the repository dest: '{{ pkgng_test_outofdate_pkg_tempdir }}/+{{ item }}' diff --git a/tests/integration/targets/pkgng/templates/test_package_manifests/COMPACT_MANIFEST.json.j2 b/tests/integration/targets/pkgng/templates/test_package_manifests/COMPACT_MANIFEST.json.j2 new file mode 100644 index 0000000000..3274d88e1f --- /dev/null +++ b/tests/integration/targets/pkgng/templates/test_package_manifests/COMPACT_MANIFEST.json.j2 @@ -0,0 +1 @@ +{{ '{' }}{% include "test_package_metadata.j2" -%}{{ '}' }} diff --git a/tests/integration/targets/pkgng/templates/test_package_manifests/MANIFEST.json.j2 b/tests/integration/targets/pkgng/templates/test_package_manifests/MANIFEST.json.j2 new file mode 100644 index 0000000000..0a91ef16b2 --- /dev/null +++ b/tests/integration/targets/pkgng/templates/test_package_manifests/MANIFEST.json.j2 @@ -0,0 +1 @@ +{{ '{' }}{% include "test_package_metadata.j2" -%},"files":{}{{ '}' }} diff --git a/tests/integration/targets/pkgng/templates/test_package_manifests/test_package_metadata.j2 b/tests/integration/targets/pkgng/templates/test_package_manifests/test_package_metadata.j2 new file mode 100644 index 0000000000..ee9ead1e64 --- /dev/null +++ b/tests/integration/targets/pkgng/templates/test_package_manifests/test_package_metadata.j2 @@ -0,0 +1 @@ +"name":"{{ pkgng_test_pkg_name }}","origin":"{{ pkgng_test_pkg_category }}/{{ pkgng_test_pkg_name }}","version":"0","comment":"{{ pkgng_test_pkg_name }} (Ansible Integration Test Package)","maintainer":"ansible-devel@googlegroups.com","www":"https://github.com/ansible-collections/community.general","abi":"FreeBSD:*:*","arch":"freebsd:*:*","prefix":"/usr/local","flatsize":0,"licenselogic":"single","licenses":["GPLv3"],"desc":"This package is only installed temporarily for integration testing of the community.general.pkgng Ansible module.\nIts version number is 0 so that ANY version of the real package, with the same name, will be considered an upgrade.\nIts architecture and abi are FreeBSD:*:* so that it will install on any version or architecture of FreeBSD,\nthus future-proof as long as the package MANIFEST format does not change\nand a wildcard in the version portion of the abi or arch field is not prohibited.","categories":["{{ pkgng_test_pkg_category }}"] diff --git a/tests/integration/targets/pkgng/vars/main.yml b/tests/integration/targets/pkgng/vars/main.yml index 20f32c9808..d5aca65cdd 100644 --- a/tests/integration/targets/pkgng/vars/main.yml +++ b/tests/integration/targets/pkgng/vars/main.yml @@ -1,4 +1,5 @@ --- -pkgng_test_outofdate_pkg_path: "/tmp/zsh-0__test.pkg" +pkgng_test_outofdate_pkg_path: "/tmp/ansible_pkgng_test_package.pkg" pkgng_test_pkg_name: zsh +pkgng_test_pkg_category: shells pkgng_test_pkg_sentinelfile_path: /usr/local/bin/zsh