From 107ae1a4f38e6793da0eb254d90830703a05d8f2 Mon Sep 17 00:00:00 2001 From: Yunge Zhu <37337818+yungezz@users.noreply.github.com> Date: Mon, 3 Sep 2018 09:52:22 +0800 Subject: [PATCH] improve vmss test (#44892) * improve vmss test * fix lint * fix lint * fix lint * fix test bug --- .../tasks/main.yml | 171 +++++------------- 1 file changed, 48 insertions(+), 123 deletions(-) diff --git a/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml b/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml index 1ae6ebab9c..7f98e2280a 100644 --- a/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml +++ b/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml @@ -38,6 +38,51 @@ resource_group: "{{ resource_group_secondary }}" name: testNetworkSecurityGroup2 +- name: Create VMSS (check mode) + azure_rm_virtualmachine_scaleset: + resource_group: "{{ resource_group }}" + name: testVMSS{{ rpfx }} + vm_size: Standard_DS1_v2 + admin_username: testuser + ssh_password_enabled: true + admin_password: "Password1234!" + capacity: 2 + virtual_network_name: testVnet + subnet_name: testSubnet + load_balancer: testLB + upgrade_policy: Manual + tier: Standard + managed_disk_type: Standard_LRS + os_disk_caching: ReadWrite + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest + data_disks: + - lun: 0 + disk_size_gb: 64 + caching: ReadWrite + managed_disk_type: Standard_LRS + register: results + check_mode: yes + +- name: Assert that VMSS can be created + assert: + that: results.changed + +- name: Get VMSS to assert no VMSS is created in check mode + azure_rm_virtualmachine_scaleset_facts: + resource_group: "{{ resource_group }}" + name: testVMSS{{ rpfx }} + format: curated + register: output_scaleset + +- name: Assert no VMSS created in check mode + assert: + that: + - output_scaleset.ansible_facts.azure_vmss | length == 0 + - name: Create VMSS azure_rm_virtualmachine_scaleset: resource_group: "{{ resource_group }}" @@ -135,85 +180,6 @@ assert: that: not results.changed -- name: Delete VMSS - azure_rm_virtualmachine_scaleset: - resource_group: "{{ resource_group }}" - name: testVMSS{{ rpfx }} - state: absent - remove_on_absent: ['all'] - vm_size: Standard_DS1_v2 - capacity: 2 - image: - offer: CoreOS - publisher: CoreOS - sku: Stable - version: latest - -- name: Create VMSS (check mode) - azure_rm_virtualmachine_scaleset: - resource_group: "{{ resource_group }}" - name: testVMSS{{ rpfx }}1 - vm_size: Standard_DS1_v2 - admin_username: testuser - ssh_password_enabled: true - admin_password: "Password1234!" - capacity: 2 - virtual_network_name: testVnet - subnet_name: testSubnet - load_balancer: testLB - upgrade_policy: Manual - tier: Standard - managed_disk_type: Standard_LRS - os_disk_caching: ReadWrite - image: - offer: CoreOS - publisher: CoreOS - sku: Stable - version: latest - data_disks: - - lun: 0 - disk_size_gb: 64 - caching: ReadWrite - managed_disk_type: Standard_LRS - register: results - check_mode: yes - -- name: Assert that VMSS can be created - assert: - that: results.changed - -- name: Create VMSS - azure_rm_virtualmachine_scaleset: - resource_group: "{{ resource_group }}" - name: testVMSS{{ rpfx }}1 - vm_size: Standard_DS1_v2 - admin_username: testuser - ssh_password_enabled: true - admin_password: "Password1234!" - capacity: 2 - virtual_network_name: testVnet - subnet_name: testSubnet - load_balancer: testLB - upgrade_policy: Manual - tier: Standard - managed_disk_type: Standard_LRS - os_disk_caching: ReadWrite - image: - offer: CoreOS - publisher: CoreOS - sku: Stable - version: latest - data_disks: - - lun: 0 - disk_size_gb: 64 - caching: ReadWrite - managed_disk_type: Standard_LRS - register: results - -- name: Assert that VMSS ran - assert: - that: results.changed - - name: Delete VMSS azure_rm_virtualmachine_scaleset: resource_group: "{{ resource_group }}" @@ -282,51 +248,10 @@ - 'results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.enableAcceleratedNetworking == true' - 'results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.networkSecurityGroup != {}' -- name: Delete VMSS +- name: update VMSS with security group in different resource group. azure_rm_virtualmachine_scaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 - state: absent - remove_on_absent: ['all'] - vm_size: Standard_D3_v2 - capacity: 1 - image: - offer: CoreOS - publisher: CoreOS - sku: Stable - version: latest - -- name: Create VMSS with security group in different resource group(check mode). - azure_rm_virtualmachine_scaleset: - resource_group: "{{ resource_group }}" - name: testVMSS{{ rpfx }}3 - vm_size: Standard_DS1_v2 - capacity: 1 - virtual_network_name: testVnet - subnet_name: testSubnet - admin_username: testuser - ssh_password_enabled: true - admin_password: "Password1234!" - image: - offer: CoreOS - publisher: CoreOS - sku: Stable - version: latest - upgrade_policy: Manual - security_group: - name: testNetworkSecurityGroup2 - resource_group: "{{ resource_group_secondary }}" - register: results - check_mode: yes - -- name: Assert that VMSS ran - assert: - that: results.changed - -- name: Create VMSS with security group in different resource group. - azure_rm_virtualmachine_scaleset: - resource_group: "{{ resource_group }}" - name: testVMSS{{ rpfx }}3 vm_size: Standard_DS1_v2 capacity: 1 virtual_network_name: testVnet @@ -345,7 +270,7 @@ resource_group: "{{ resource_group_secondary }}" register: results -- name: Assert that VMSS ran +- name: Assert that security group is correct assert: that: - 'results.changed' @@ -354,7 +279,7 @@ - name: Delete VMSS azure_rm_virtualmachine_scaleset: resource_group: "{{ resource_group }}" - name: testVMSS{{ rpfx }}3 + name: testVMSS{{ rpfx }}2 state: absent remove_on_absent: ['all'] vm_size: Standard_DS1_v2