From ad9be1068bc4bfa7b571d977b4b4cf00d6db3917 Mon Sep 17 00:00:00 2001 From: Wojciech Sciesinski Date: Mon, 18 Feb 2019 17:42:12 +0100 Subject: [PATCH] Correct integration tests for the win_disk_facts module (#51044) (#51771) * Correct integration tests for the win_disk_facts module * Exclude W2K8, W2K8-R2 from tests run under CI --- .../integration/targets/win_disk_facts/aliases | 2 ++ .../targets/win_disk_facts/tasks/main.yml | 6 +++--- .../targets/win_disk_facts/tasks/tests.yml | 18 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/test/integration/targets/win_disk_facts/aliases b/test/integration/targets/win_disk_facts/aliases index 423ce391085..e4adbabbe27 100644 --- a/test/integration/targets/win_disk_facts/aliases +++ b/test/integration/targets/win_disk_facts/aliases @@ -1 +1,3 @@ shippable/windows/group2 +skip/windows/2008 # The Storage PowerShell module was introduced in W2K12 +skip/windows/2008-R2 # The Storage PowerShell module was introduced in W2K12 diff --git a/test/integration/targets/win_disk_facts/tasks/main.yml b/test/integration/targets/win_disk_facts/tasks/main.yml index 70a96a88f7d..b4b4fecb94c 100644 --- a/test/integration/targets/win_disk_facts/tasks/main.yml +++ b/test/integration/targets/win_disk_facts/tasks/main.yml @@ -1,12 +1,12 @@ # NOTE: The win_disk_facts module only works on Win2012R2+ - name: check whether storage module is available (windows 2008 r2 or later) - raw: PowerShell -Command Import-Module Storage + win_shell: '(Get-Module -Name Storage -ListAvailable | Measure-Object).Count -eq 1' register: win_feature_has_storage_module - ignore_errors: true + changed_when: false - name: Only run tests when Windows is capable - when: ( win_feature_has_storage_module is successful) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 3) + when: win_feature_has_storage_module.stdout | trim | bool == True block: - name: Test in normal mode diff --git a/test/integration/targets/win_disk_facts/tasks/tests.yml b/test/integration/targets/win_disk_facts/tasks/tests.yml index 8ba814a08b5..3b12d46210b 100644 --- a/test/integration/targets/win_disk_facts/tasks/tests.yml +++ b/test/integration/targets/win_disk_facts/tasks/tests.yml @@ -6,12 +6,12 @@ assert: that: - disks_found.changed == false - - disks_found.ansible_facts.disks[0].size is defined - - disks_found.ansible_facts.disks[0].number is defined - - disks_found.ansible_facts.disks[0].operational_status is defined - - disks_found.ansible_facts.disks[0].read_only is defined - - disks_found.ansible_facts.disks[0].clustered is defined - - disks_found.ansible_facts.disks[0].location is defined - - disks_found.ansible_facts.disks[0].guid is defined - - disks_found.ansible_facts.disks[0].path is defined - - disks_found.ansible_facts.disks[0].bootable is defined + - disks_found.ansible_facts.ansible_disks[0].number is defined + - disks_found.ansible_facts.ansible_disks[0].guid is defined + - disks_found.ansible_facts.ansible_disks[0].location is defined + - disks_found.ansible_facts.ansible_disks[0].path is defined + - disks_found.ansible_facts.ansible_disks[0].read_only is defined + - disks_found.ansible_facts.ansible_disks[0].clustered is defined + - disks_found.ansible_facts.ansible_disks[0].bootable is defined + - disks_found.ansible_facts.ansible_disks[0].physical_disk.size is defined + - disks_found.ansible_facts.ansible_disks[0].physical_disk.operational_status is defined