From ab949957fa7d467c638146160f3a8784ee3a8d2e Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Tue, 24 Oct 2017 19:40:05 -0400 Subject: [PATCH] Add ability to enable/disable SELinux during tests Add a pair of variables to control whether or not SELinux is enabled during particular tests. In all cases, make sure it's re-enabled afterwards. Signed-off-by: Chris Evich --- contrib/test/integration/e2e.yml | 12 ++++++++---- contrib/test/integration/test.yml | 9 ++++++++- contrib/test/integration/vars.yml | 5 +++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/contrib/test/integration/e2e.yml b/contrib/test/integration/e2e.yml index 52d0b750..5520b4f4 100644 --- a/contrib/test/integration/e2e.yml +++ b/contrib/test/integration/e2e.yml @@ -48,15 +48,16 @@ &> {{ artifacts }}/e2e.log # Fix vim syntax hilighting: " -- name: disable SELinux - command: setenforce 0 - - block: - name: Disable swap during e2e tests command: 'swapoff -a' when: not e2e_swap_enabled + - name: Disable selinux during e2e tests + command: 'setenforce 0' + when: not e2e_selinux_enabled + - name: run e2e tests shell: "{{ e2e_shell_cmd | regex_replace('\\s+', ' ') }}" args: @@ -64,5 +65,8 @@ always: - - name: Re-enable swap after e2e tests + - name: Re-enable SELinux after e2e tsts + command: 'setenforce 1' + + - name: Re-enalbe swap after e2e tests command: 'swapon -a' diff --git a/contrib/test/integration/test.yml b/contrib/test/integration/test.yml index 87c5b2ad..e9023e77 100644 --- a/contrib/test/integration/test.yml +++ b/contrib/test/integration/test.yml @@ -26,6 +26,10 @@ command: 'swapoff -a' when: not integration_swap_enabled + - name: Disable selinux during integration tests + command: 'setenforce 0' + when: not integration_selinux_enabled + - name: run integration tests shell: "CGROUP_MANAGER=cgroupfs STORAGE_OPTIONS='--storage-driver=overlay{{ extra_storage_opts | default('') }}' make localintegration >& {{ artifacts }}/testout.txt" args: @@ -35,5 +39,8 @@ always: - - name: Re-enable swap after integration tests + - name: Re-enable SELinux after integration tsts + command: 'setenforce 1' + + - name: Re-enalbe swap after integration tests command: 'swapon -a' diff --git a/contrib/test/integration/vars.yml b/contrib/test/integration/vars.yml index 05f6ec6a..801eb1bc 100644 --- a/contrib/test/integration/vars.yml +++ b/contrib/test/integration/vars.yml @@ -8,6 +8,11 @@ swapfileGB: 8 integration_swap_enabled: False e2e_swap_enabled: True +# When False, disable SELinux on the system only during +# particular tests. +integration_selinux_enabled: True +e2e_selinux_enabled: False + # For results.yml Paths use rsync 'source' conventions artifacts: "/tmp/artifacts" # Base-directory for collection crio_integration_filepath: "{{ artifacts }}/testout.txt"