mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-28 15:41:32 -07:00
Update integration tests to account for nicType changes
Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
This commit is contained in:
parent
81fbe1debe
commit
24bba779d8
1 changed files with 140 additions and 0 deletions
|
@ -1,3 +1,143 @@
|
|||
---
|
||||
- name: Generated tests
|
||||
ansible.builtin.include_tasks: autogen.yml
|
||||
|
||||
- name: Test nic_type scenarios
|
||||
block:
|
||||
- name: Create disk for virtio
|
||||
google.cloud.gcp_compute_disk:
|
||||
name: "{{ resource_prefix }}-virtio"
|
||||
size_gb: 50
|
||||
source_image: projects/rhel-cloud/global/images/rhel-9-v20250513
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _virtio_disk
|
||||
|
||||
- name: Create disk for gVNIC
|
||||
google.cloud.gcp_compute_disk:
|
||||
name: "{{ resource_prefix }}-gvnic"
|
||||
size_gb: 50
|
||||
source_image: projects/rhel-cloud/global/images/rhel-9-v20250513
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _gvnic_disk
|
||||
|
||||
- name: Create network
|
||||
google.cloud.gcp_compute_network:
|
||||
name: "{{ resource_prefix }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
auto_create_subnetworks: true
|
||||
state: present
|
||||
register: _network
|
||||
|
||||
- name: Create virtio instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-virtio"
|
||||
machine_type: n1-standard-1
|
||||
disks:
|
||||
- auto_delete: "true"
|
||||
boot: "true"
|
||||
source: "{{ _virtio_disk }}"
|
||||
network_interfaces:
|
||||
- network: "{{ _network }}"
|
||||
nic_type: VIRTIO_NET
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _virtio_result
|
||||
|
||||
- name: Verify virtio instance was created
|
||||
google.cloud.gcp_compute_instance_info:
|
||||
filters:
|
||||
- name = {{ resource_name }}-virtio
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: _virtio_info
|
||||
|
||||
- name: Pass assertions
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _virtio_result.changed == true
|
||||
- _virtio_result.networkInterfaces[0].nicType == 'VIRTIO_NET'
|
||||
- _virtio_info.resources[0].networkInterfaces[0].nicType == 'VIRTIO_NET'
|
||||
|
||||
- name: Create gvnic instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-gvnic"
|
||||
machine_type: n1-standard-1
|
||||
disks:
|
||||
- auto_delete: "true"
|
||||
boot: "true"
|
||||
source: "{{ _gvnic_disk }}"
|
||||
network_interfaces:
|
||||
- network: "{{ _network }}"
|
||||
nic_type: GVNIC
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _gvnic_result
|
||||
|
||||
- name: Verify gvnic instance was created
|
||||
google.cloud.gcp_compute_instance_info:
|
||||
filters:
|
||||
- name = {{ resource_name }}-gvnic
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: _gvnic_info
|
||||
|
||||
- name: Pass assertions
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _gvnic_result.changed == true
|
||||
- _gvnic_result.networkInterfaces[0].nicType == 'GVNIC'
|
||||
- _gvnic_info.resources[0].networkInterfaces[0].nicType == 'GVNIC'
|
||||
|
||||
always:
|
||||
- name: Delete virtio instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-virtio"
|
||||
machine_type: n1-standard-1
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete gVNIC instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-gvnic"
|
||||
machine_type: n1-standard-1
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete network
|
||||
google.cloud.gcp_compute_network:
|
||||
name: "{{ resource_prefix }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
auto_create_subnetworks: true
|
||||
state: absent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue