From dd55c3c3bb159b43faab3330b0ad47a7152ca8e1 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 18 Dec 2020 11:48:28 +0100 Subject: [PATCH] Fix AZP CI (#1508) * Fix 2.9/2.10 cloud * Fix splunk callback tests. * ansible_virtualization_type on AZP can be one of container/containerd instead of docker for dockerized tests. * Disable nomad tests. * Work around AZP bugs. --- .azure-pipelines/azure-pipelines.yml | 12 ++++++------ tests/integration/targets/filesystem/tasks/main.yml | 2 +- tests/integration/targets/nomad/aliases | 1 + tests/unit/plugins/callback/test_splunk.py | 9 ++++++++- tests/utils/shippable/shippable.sh | 3 +++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 3c9cf03dc5..fbbbb71876 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -273,20 +273,20 @@ stages: jobs: - template: templates/matrix.yml parameters: - nameFormat: Python 3.6 {0} - testFormat: 2.10/cloud/3.6/{0}/1 + nameFormat: Python {0} + testFormat: 2.10/cloud/{0}/1 targets: - - test: '' + - test: 3.6 - stage: Cloud_2_9 displayName: Cloud 2.9 dependsOn: [] jobs: - template: templates/matrix.yml parameters: - nameFormat: Python 3.6 {0} - testFormat: 2.9/cloud/3.6/{0}/1 + nameFormat: Python {0} + testFormat: 2.9/cloud/{0}/1 targets: - - test: '' + - test: 3.6 - stage: Summary condition: succeededOrFailed() dependsOn: diff --git a/tests/integration/targets/filesystem/tasks/main.yml b/tests/integration/targets/filesystem/tasks/main.yml index ba79b1e95f..81e5a6b380 100644 --- a/tests/integration/targets/filesystem/tasks/main.yml +++ b/tests/integration/targets/filesystem/tasks/main.yml @@ -33,7 +33,7 @@ - 'not (item.0.key == "btrfs" and (ansible_distribution == "Ubuntu" and ansible_distribution_release == "trusty"))' - 'not (item.0.key == "btrfs" and (ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version("8", ">=")))' - 'not (item.0.key == "lvm" and ansible_system == "FreeBSD")' # LVM not available on FreeBSD - - 'not (item.0.key == "lvm" and ansible_virtualization_type == "docker")' # Tests use losetup which can not be used inside unprivileged container + - 'not (item.0.key == "lvm" and ansible_virtualization_type in ["docker", "container", "containerd"])' # Tests use losetup which can not be used inside unprivileged container - 'not (item.0.key == "ocfs2" and ansible_os_family != "Debian")' # ocfs2 only available on Debian based distributions - 'not (item.0.key == "f2fs" and ansible_system == "FreeBSD")' # f2fs-tools package not available with RHEL/CentOS diff --git a/tests/integration/targets/nomad/aliases b/tests/integration/targets/nomad/aliases index 3141aee60b..82c6f51606 100644 --- a/tests/integration/targets/nomad/aliases +++ b/tests/integration/targets/nomad/aliases @@ -4,3 +4,4 @@ destructive skip/aix skip/centos6 skip/freebsd +disabled # FIXME diff --git a/tests/unit/plugins/callback/test_splunk.py b/tests/unit/plugins/callback/test_splunk.py index 291fb691ad..df4db38d56 100644 --- a/tests/unit/plugins/callback/test_splunk.py +++ b/tests/unit/plugins/callback/test_splunk.py @@ -25,7 +25,10 @@ import json class TestSplunkClient(unittest.TestCase): - def setUp(self): + @patch('ansible_collections.community.general.plugins.callback.splunk.socket') + def setUp(self, mock_socket): + mock_socket.gethostname.return_value = 'my-host' + mock_socket.gethostbyname.return_value = '1.2.3.4' self.splunk = SplunkHTTPCollectorSource() self.mock_task = Mock('MockTask') self.mock_task._role = 'myrole' @@ -46,6 +49,8 @@ class TestSplunkClient(unittest.TestCase): sent_data = json.loads(args[1]) self.assertEqual(sent_data['event']['timestamp'], '2020-12-01 00:00:00.000000 +0000') + self.assertEqual(sent_data['event']['host'], 'my-host') + self.assertEqual(sent_data['event']['ip_address'], '1.2.3.4') @patch('ansible_collections.community.general.plugins.callback.splunk.datetime') @patch('ansible_collections.community.general.plugins.callback.splunk.open_url') @@ -59,3 +64,5 @@ class TestSplunkClient(unittest.TestCase): sent_data = json.loads(args[1]) self.assertEqual(sent_data['event']['timestamp'], '2020-12-01 00:00:00 +0000') + self.assertEqual(sent_data['event']['host'], 'my-host') + self.assertEqual(sent_data['event']['ip_address'], '1.2.3.4') diff --git a/tests/utils/shippable/shippable.sh b/tests/utils/shippable/shippable.sh index 2bd05d1695..5547c0c73c 100755 --- a/tests/utils/shippable/shippable.sh +++ b/tests/utils/shippable/shippable.sh @@ -14,6 +14,9 @@ function join { echo "$*"; } +# Ensure we can write other collections to this dir +sudo chown "$(whoami)" "${PWD}/../../" + test="$(join / "${args[@]:1}")" docker images ansible/ansible