From 7007c68ab786e6d51ecab5d97d2e3b891bd476c9 Mon Sep 17 00:00:00 2001 From: David Lundgren Date: Mon, 3 May 2021 14:05:07 -0500 Subject: [PATCH] Clean up test entries from sysrc tests (#2330) * Clean up test entries from sysrc tests * sysrc: enable tests * sysrc: cache the files to be changed and restore them * Update the ezjail archive host and remove obsolete file * sysrc: set ezjail to use archives for 12.0 or less * sysrc: Detect the version to use ftp vs ftp-archive using http * sysrc: Skip ezjail test on FreeBSD 12.0 --- tests/integration/targets/sysrc/aliases | 1 - .../integration/targets/sysrc/tasks/main.yml | 21 ++++++++++++++++++- .../targets/sysrc/tasks/setup-testjail.yml | 9 +++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/sysrc/aliases b/tests/integration/targets/sysrc/aliases index c7d183fb65..360849e61b 100644 --- a/tests/integration/targets/sysrc/aliases +++ b/tests/integration/targets/sysrc/aliases @@ -3,4 +3,3 @@ needs/root skip/docker skip/osx skip/rhel -disabled # FIXME diff --git a/tests/integration/targets/sysrc/tasks/main.yml b/tests/integration/targets/sysrc/tasks/main.yml index c8b7de4160..b8292f785b 100644 --- a/tests/integration/targets/sysrc/tasks/main.yml +++ b/tests/integration/targets/sysrc/tasks/main.yml @@ -6,7 +6,11 @@ block: - name: Cache original contents of /etc/rc.conf shell: "cat /etc/rc.conf" - register: sysrc_original_content + register: cached_etc_rcconf_content + + - name: Cache original contents of /boot/loader.conf + shell: "cat /boot/loader.conf" + register: cached_boot_loaderconf_content ## ## sysrc - example - set mysqlpidfile @@ -130,6 +134,11 @@ ## sysrc - example - Enable nginx in testjail ## - name: Test within jail + # + # NOTE: FreeBSD 12.0 test runner receives a "connection reset by peer" after ~20% downloaded so we are + # only running this on 12.1 or higher + # + when: ansible_distribution_version is version('12.01', '>=') block: - name: Setup testjail include: setup-testjail.yml @@ -316,3 +325,13 @@ - not sysrc_value_absent_idempotent.changed - "'sysrc_delim=\"t1,t2\"' in sysrc_delim_content.stdout_lines" - "'sysrc_delim_delete' not in sysrc_delim_content.stdout_lines" + always: + - name: Restore /etc/rc.conf + copy: + content: "{{ cached_etc_rcconf_content }}" + dest: /etc/rc.conf + + - name: Restore /boot/loader.conf + copy: + content: "{{ cached_boot_loaderconf_content }}" + dest: /boot/loader.conf \ No newline at end of file diff --git a/tests/integration/targets/sysrc/tasks/setup-testjail.yml b/tests/integration/targets/sysrc/tasks/setup-testjail.yml index 9bd15320ae..e75957d19f 100644 --- a/tests/integration/targets/sysrc/tasks/setup-testjail.yml +++ b/tests/integration/targets/sysrc/tasks/setup-testjail.yml @@ -17,12 +17,19 @@ pkgng: name: ezjail +- name: Configure ezjail to use http + when: ansible_distribution_version is version('11.01', '>') + lineinfile: + dest: /usr/local/etc/ezjail.conf + regexp: ^ezjail_ftphost + line: ezjail_ftphost=http://ftp.freebsd.org + - name: Configure ezjail to use archive for old freebsd releases when: ansible_distribution_version is version('11.01', '<=') lineinfile: dest: /usr/local/etc/ezjail.conf regexp: ^ezjail_ftphost - line: ezjail_ftphost=ftp-archive.freebsd.org + line: ezjail_ftphost=http://ftp-archive.freebsd.org - name: Start ezjail ignore_errors: yes