From baf1cdec09c6d8434ad5a91e7a015ca3a4713356 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Sat, 12 Jul 2025 03:34:18 -0700 Subject: [PATCH] Enable hg integration test (#10385) Fixes: #10044 Signed-off-by: Abhijeet Kasurde --- .../integration/targets/hg/tasks/install.yml | 19 ++------------ tests/integration/targets/hg/tasks/main.yml | 18 ------------- .../targets/hg/tasks/run-tests.yml | 26 ++++++------------- .../targets/hg/tasks/uninstall.yml | 16 ++---------- 4 files changed, 12 insertions(+), 67 deletions(-) diff --git a/tests/integration/targets/hg/tasks/install.yml b/tests/integration/targets/hg/tasks/install.yml index caa2e21512..efc0549e95 100644 --- a/tests/integration/targets/hg/tasks/install.yml +++ b/tests/integration/targets/hg/tasks/install.yml @@ -26,11 +26,11 @@ shell: apt-get -y update && apt-get -y install mercurial when: ansible_facts.pkg_mgr == 'apt' -- name: install packages (apk) +- name: install mercurial package package: name: mercurial state: present - when: ansible_facts.pkg_mgr in ['apk', 'community.general.apk'] + when: ansible_facts.pkg_mgr in ['apk', 'community.general.apk', 'pacman', 'community.general.pacman', 'pkgng', 'community.general.pkgng', 'zypper', 'community.general.zypper'] - name: install mercurial (dnf) dnf: @@ -42,21 +42,6 @@ name: mercurial when: ansible_facts.pkg_mgr == 'yum' -- name: install mercurial (pacman) - package: - name: mercurial - when: ansible_facts.pkg_mgr in ['pacman', 'community.general.pacman'] - -- name: install mercurial (pkgng) - package: - name: mercurial - when: ansible_facts.pkg_mgr in ['pkgng', 'community.general.pkgng'] - -- name: install mercurial (zypper) - package: - name: mercurial - when: ansible_facts.pkg_mgr in ['zypper', 'community.general.zypper'] - - name: preserve the updated python command: cp -av "{{ which_python.stdout }}" "{{ which_python.stdout }}.updated" diff --git a/tests/integration/targets/hg/tasks/main.yml b/tests/integration/targets/hg/tasks/main.yml index 8c79d20b86..842f4c6570 100644 --- a/tests/integration/targets/hg/tasks/main.yml +++ b/tests/integration/targets/hg/tasks/main.yml @@ -14,13 +14,6 @@ register: has_hg ignore_errors: true -- name: warn if the underlying system is not capable of running these tests - debug: - msg: >- - The mercurial client is not able to check out Bitbucket repositories as per the changes mentioned here: - https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01 . Therefore these tests are skipped. - when: (ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04") or ansible_python_version is version("2.7.9", "<") - - block: - name: install mercurial include_tasks: install.yml @@ -32,14 +25,3 @@ - name: uninstall mercurial include_tasks: uninstall.yml when: has_hg is failed - - # As per the bitbucket changes in https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01 , this - # test will fail under certain circumstances, to avoid false positives, we skip these tests under the following - # circumstances: - # - # - The ubuntu 14.04 image used on shippable runs python 2.7.6, so we skip explicitly for this image. - # - When ansible_python_version is not 2.7.9 or higher, mercurial is likely to also run using this same (old) - # python version, which causes issues as per the link above. - when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04") - - ansible_python_version is version("2.7.9", ">=") diff --git a/tests/integration/targets/hg/tasks/run-tests.yml b/tests/integration/targets/hg/tasks/run-tests.yml index 928b7cb68d..07aa08d225 100644 --- a/tests/integration/targets/hg/tasks/run-tests.yml +++ b/tests/integration/targets/hg/tasks/run-tests.yml @@ -4,17 +4,13 @@ # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later - -- name: set where to extract the repo +- name: set variables for tests set_fact: + repo: "http://hg.code.sf.net/p/cg-hg-test-repo/hgtest" checkout_dir: "{{ remote_tmp_dir }}/hg_project_test" -- name: set what repo to use - set_fact: - repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test" - - name: clean out the remote_tmp_dir - shell: rm -rf {{ remote_tmp_dir }}/* + shell: rm -rf "{{ checkout_dir }}" - name: verify that mercurial is installed so this test can continue shell: which hg @@ -25,8 +21,6 @@ dest: "{{ checkout_dir }}" register: hg_result -- debug: var=hg_result - - shell: ls {{ checkout_dir }} - name: verify information about the initial clone @@ -45,23 +39,20 @@ - debug: var=hg_result2 -- name: check for tags +- name: check if tags exists stat: path: "{{ checkout_dir }}/.hgtags" - register: tags + register: hg_tags - name: check for remotes stat: path: "{{ checkout_dir }}/.hg/branch" register: branches -- debug: var=tags -- debug: var=branches - - name: assert presence of tags/trunk/branches assert: that: - - "tags.stat.isreg" + - "hg_tags.stat.isreg" - "branches.stat.isreg" - name: verify on a re-clone things are marked unchanged @@ -71,7 +62,7 @@ - name: Checkout non-existent repo clone hg: - repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test_1" + repo: "http://hg.code.sf.net/p/cg-hg-test-repo1" clone: false update: false register: hg_result3 @@ -80,6 +71,5 @@ - name: Verify result of non-existent repo clone assert: that: - - hg_result3.msg - - "'abort: HTTP Error 404: Not Found' in hg_result3.msg" + - "'abort: HTTP Error' in hg_result3.msg" - "not hg_result3.changed" diff --git a/tests/integration/targets/hg/tasks/uninstall.yml b/tests/integration/targets/hg/tasks/uninstall.yml index b2274caf1f..73c50f4909 100644 --- a/tests/integration/targets/hg/tasks/uninstall.yml +++ b/tests/integration/targets/hg/tasks/uninstall.yml @@ -16,12 +16,6 @@ line: "#!{{ stat_hg_interpreter.stat.path }}" when: stat_hg_interpreter.stat.islnk -- name: uninstall packages which were not originally installed (apk) - package: - name: mercurial - state: absent - when: ansible_facts.pkg_mgr in ['apk', 'community.general.apk'] - # using the apt module prevents autoremove from working, so call apt-get via shell instead - name: uninstall packages which were not originally installed (apt) shell: apt-get -y remove mercurial && apt-get -y autoremove @@ -39,11 +33,11 @@ shell: yum -y autoremove mercurial when: ansible_facts.pkg_mgr == 'yum' -- name: uninstall packages which were not originally installed (pacman) +- name: uninstall packages which were not originally installed package: name: mercurial state: absent - when: ansible_facts.pkg_mgr in ['pacman', 'community.general.pacman'] + when: ansible_facts.pkg_mgr in ['pacman', 'community.general.pacman', 'zypper', 'community.general.zypper', 'apk', 'community.general.apk'] - name: uninstall packages which were not originally installed (pkgng) package: @@ -52,12 +46,6 @@ autoremove: true when: ansible_facts.pkg_mgr in ['pkgng', 'community.general.pkgng'] -- name: uninstall packages which were not originally installed (zypper) - package: - name: mercurial - state: absent - when: ansible_facts.pkg_mgr in ['zypper', 'community.general.zypper'] - - name: restore the default python raw: mv "{{ which_python.stdout }}.default" "{{ which_python.stdout }}"