Skip to content

Commit

Permalink
Merge branch 'fix/GCLOUD2-12819-fix-integration-tests' into 'master'
Browse files Browse the repository at this point in the history
GCLOUD2-12819: fix integration tests errors and warnings

See merge request cloudapi/ansible-provider!29
  • Loading branch information
IsabellaMerkulova committed Feb 5, 2024
2 parents c7b39fd + e5c3fa1 commit 7ef6602
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 68 deletions.
2 changes: 1 addition & 1 deletion plugins/doc_fragments/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ModuleDocFragment:
api_key:
description:
- GCore API auth key
- Can be passed as I(CLOUD_API_HOST) environment variable.
- Can be passed as I(CLOUD_API_KEY) environment variable.
type: str
api_timeout:
description:
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/targets/instance/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
ansible.builtin.assert:
that:
- created_instance.data.status == "ACTIVE"
- created_instance.data.instance_name == "{{ instance_name }}"
- created_instance.data.flavor.flavor_name == "{{ instance_flavor }}"
- created_instance.data.instance_name == instance_name
- created_instance.data.flavor.flavor_name == instance_flavor

- name: Update instance's name
gcore.cloud.instance:
Expand All @@ -50,4 +50,4 @@
- name: Verify new instance name
ansible.builtin.assert:
that:
- updated_instance.data.instance_name == "{{ new_instance_name }}"
- updated_instance.data.instance_name == new_instance_name
4 changes: 2 additions & 2 deletions tests/integration/targets/keypair/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- name: Verify created keypair
ansible.builtin.assert:
that:
- created_keypair.data.sshkey_name == "{{ keypair_name }}"
- created_keypair.data.sshkey_name == keypair_name
- created_keypair.data.state == "ACTIVE"
- created_keypair.data.shared_in_project == true

Expand Down Expand Up @@ -48,4 +48,4 @@

always:
- name: Cleanup keypairs
import_tasks: ./targets/common/tasks/cleanup_keypairs.yml
import_tasks: cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- vars:
api_key: "{{ API_KEY }}"
api_host: "{{ API_HOST }}"
project_id: "{{ PROJECT_ID }}"
region_id: "{{ REGION_ID }}"

block:
- name: List all test volumes
gcore.cloud.volume_info:
api_key: "{{ api_key }}"
api_host: "{{ api_host }}"
project_id: "{{ project_id }}"
region_id: "{{ region_id }}"
register: list_volumes

- name: Delete all test volumes
gcore.cloud.volume:
api_key: "{{ api_key }}"
api_host: "{{ api_host }}"
project_id: "{{ project_id }}"
region_id: "{{ region_id }}"
command: delete
volume_id: "{{ item.id }}"
ignore_errors: True
when:
- item.name.startswith('test_ansible')
with_items: "{{ list_volumes.data }}"
loop_control:
label: "{{ item.name }} ({{ item.id }})"
20 changes: 10 additions & 10 deletions tests/integration/targets/lifecycle_policy/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- name: Verify policy
ansible.builtin.assert:
that:
- created_policy.data["name"] == "{{ policy_name }}"
- created_policy.data["name"] == policy_name

- name: Update policy
gcore.cloud.lifecycle_policy:
Expand All @@ -36,7 +36,7 @@
lifecycle_policy_id: "{{ created_policy.data.id }}"
name: "{{ new_policy_name }}"
register: updated_policy

- name: Get policy by id
gcore.cloud.lifecycle_policy_info:
api_key: "{{ api_key }}"
Expand All @@ -45,13 +45,13 @@
region_id: "{{ region_id }}"
lifecycle_policy_id: "{{ updated_policy.data.id }}"
register: policy

- name: Verify policy
ansible.builtin.assert:
that:
- policy.data.name == "{{ new_policy_name }}"
- policy.data.action == "{{ policy_action }}"
- policy.data.name == new_policy_name
- policy.data.action == policy_action

- name: Add volume to policy
gcore.cloud.lifecycle_policy:
api_key: "{{ api_key }}"
Expand All @@ -75,11 +75,11 @@
- name: Validate policies volumes
ansible.builtin.assert:
that:
- policy_with_volumes.data.volumes[0].volume_id == "{{ created_volume.data.id }}"
- policy_with_volumes.data.volumes[0].volume_name == "{{ created_volume.data.name }}"
- policy_with_volumes.data.volumes[0].volume_id == created_volume.data.id
- policy_with_volumes.data.volumes[0].volume_name == created_volume.data.name

always:
- name: Cleanup policies
import_tasks: ./targets/common/tasks/cleanup_lifecycle_policy.yml
import_tasks: cleanup.yml
- name: Cleanup volumes
import_tasks: ./targets/common/tasks/cleanup_volumes.yml
import_tasks: cleanup_volumes.yml
6 changes: 3 additions & 3 deletions tests/integration/targets/loadbalancer/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- name: Verify loadbalancer
ansible.builtin.assert:
that:
- created_loadbalancer.data.name == "{{ loadbalancer_name }}"
- created_loadbalancer.data.name == loadbalancer_name

- name: Update existing loadbalancer's name
gcore.cloud.loadbalancer:
Expand All @@ -35,7 +35,7 @@
- name: Verify name updated
ansible.builtin.assert:
that:
- updated_loadbalancer.data.name == "{{ new_loadbalancer_name }}"
- updated_loadbalancer.data.name == new_loadbalancer_name

- name: Get loadbalancer with stats
gcore.cloud.loadbalancer_info:
Expand All @@ -50,4 +50,4 @@
- name: Verify get loadbalancer with params
ansible.builtin.assert:
that:
- loadbalancer_with_stats.data.stats.active_connections == 0
- loadbalancer_with_stats.data.stats.active_connections == 0
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
- name: Verify lb listener
ansible.builtin.assert:
that:
- created_lb_listener.data.name == "{{ lb_listener_name }}"
- created_lb_listener.data.protocol == "{{ listener_protocol }}"
- created_lb_listener.data.name == lb_listener_name
- created_lb_listener.data.protocol == listener_protocol

- name: Update listener's name
gcore.cloud.loadbalancer_listener:
Expand All @@ -40,4 +40,4 @@
- name: Verify new listener name
ansible.builtin.assert:
that:
- updated_lb_listener.data.name == "{{ new_lb_listener_name }}"
- updated_lb_listener.data.name == new_lb_listener_name
4 changes: 2 additions & 2 deletions tests/integration/targets/network/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- name: Verify network
ansible.builtin.assert:
that:
- created_network.data.name == "{{ network_name }}"
- created_network.data.name == network_name
- created_network.data.type == "vxlan"
- created_network.data.metadata[0].key == "ansible_key"

Expand All @@ -38,4 +38,4 @@
- name: Verify name updated
ansible.builtin.assert:
that:
- updated_network.data.name == "{{ new_network_name }}"
- updated_network.data.name == new_network_name
2 changes: 1 addition & 1 deletion tests/integration/targets/reserved_fixed_ip/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@

always:
- name: Cleanup reserved fixed ips
import_tasks: ./targets/common/tasks/cleanup_reserved_fixed_ips.yml
import_tasks: cleanup.yml
4 changes: 2 additions & 2 deletions tests/integration/targets/router/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- name: Verify router
ansible.builtin.assert:
that:
- created_router.data.name == "{{ router_name }}"
- created_router.data.name == router_name

- name: Update router
gcore.cloud.router:
Expand All @@ -35,4 +35,4 @@
- name: Verify router updating
ansible.builtin.assert:
that:
- updated_router.data.name == "{{ updated_router_name }}"
- updated_router.data.name == updated_router_name
4 changes: 2 additions & 2 deletions tests/integration/targets/secret/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
- name: Verify secret
ansible.builtin.assert:
that:
- created_secret.data.name == "{{ secret_name }}"
- created_secret.data.name == secret_name

always:
- name: Cleanup secrets
import_tasks: ./targets/common/tasks/cleanup_secrets.yml
import_tasks: cleanup.yml
30 changes: 30 additions & 0 deletions tests/integration/targets/securitygroup/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- vars:
api_key: "{{ API_KEY }}"
api_host: "{{ API_HOST }}"
project_id: "{{ PROJECT_ID }}"
region_id: "{{ REGION_ID }}"

block:
- name: List all test securitygroups
gcore.cloud.securitygroup_info:
api_key: "{{ api_key }}"
api_host: "{{ api_host }}"
project_id: "{{ project_id }}"
region_id: "{{ region_id }}"
register: list_securitygroups

- name: Delete all test securitygroups
gcore.cloud.securitygroup:
api_key: "{{ api_key }}"
api_host: "{{ api_host }}"
project_id: "{{ project_id }}"
region_id: "{{ region_id }}"
command: delete
securitygroup_id: "{{ item.id }}"
ignore_errors: True
when:
- item.name.startswith('test_ansible')
with_items: "{{ list_securitygroups.data }}"
loop_control:
label: "{{ item.name }} ({{ item.id }})"
12 changes: 6 additions & 6 deletions tests/integration/targets/securitygroup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- name: Verify securitygroup
ansible.builtin.assert:
that:
- created_securitygroup.data.name == "{{ securitygroup_name }}"
- created_securitygroup.data.name == securitygroup_name
- created_securitygroup.data.security_group_rules | list | length >= 1

- name: Update securitygroup
Expand All @@ -42,7 +42,7 @@
- name: Verify updating securitygroup
ansible.builtin.assert:
that:
- updated_securitygroup.data.name == "{{ updated_securitygroup_name }}"
- updated_securitygroup.data.name == updated_securitygroup_name

- name: Copy securitygroup
gcore.cloud.securitygroup:
Expand All @@ -57,8 +57,8 @@
- name: Verify securitygroup copy
ansible.builtin.assert:
that:
- copied_securitygroup.data.name == "{{ copied_securitygroup_name }}"
- copied_securitygroup.data.name == copied_securitygroup_name

- name: Get list securitygroup
gcore.cloud.securitygroup_info:
api_key: "{{ api_key }}"
Expand All @@ -82,8 +82,8 @@
- name: Verify securitygroup
ansible.builtin.assert:
that:
- copied_securitygroup.data.name == "{{ copied_securitygroup_name }}"
- copied_securitygroup.data.name == copied_securitygroup_name

always:
- name: Cleanup securitygroups
import_tasks: ./targets/common/tasks/cleanup_securitygroups.yml
import_tasks: cleanup.yml
30 changes: 30 additions & 0 deletions tests/integration/targets/securitygroup_rule/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- vars:
api_key: "{{ API_KEY }}"
api_host: "{{ API_HOST }}"
project_id: "{{ PROJECT_ID }}"
region_id: "{{ REGION_ID }}"

block:
- name: List all test securitygroups
gcore.cloud.securitygroup_info:
api_key: "{{ api_key }}"
api_host: "{{ api_host }}"
project_id: "{{ project_id }}"
region_id: "{{ region_id }}"
register: list_securitygroups

- name: Delete all test securitygroups
gcore.cloud.securitygroup:
api_key: "{{ api_key }}"
api_host: "{{ api_host }}"
project_id: "{{ project_id }}"
region_id: "{{ region_id }}"
command: delete
securitygroup_id: "{{ item.id }}"
ignore_errors: True
when:
- item.name.startswith('test_ansible')
with_items: "{{ list_securitygroups.data }}"
loop_control:
label: "{{ item.name }} ({{ item.id }})"
4 changes: 2 additions & 2 deletions tests/integration/targets/securitygroup_rule/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- name: Verify rule
ansible.builtin.assert:
that:
- created_rule.data.security_group_id == "{{ created_securitygroup.data.id }}"
- created_rule.data.security_group_id == created_securitygroup.data.id
- created_rule.data.direction == "ingress"
- created_rule.data.ethertype == "IPv4"

Expand Down Expand Up @@ -62,4 +62,4 @@

always:
- name: Cleanup securitygroups
import_tasks: ./targets/common/tasks/cleanup_securitygroups.yml
import_tasks: cleanup.yml
6 changes: 3 additions & 3 deletions tests/integration/targets/servergroup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
- name: Verify servergroup
ansible.builtin.assert:
that:
- created_servergroup.data.name == "{{ servergroup_name }}"
- created_servergroup.data.policy == "{{ servergroup_policy }}"
- created_servergroup.data.name == servergroup_name
- created_servergroup.data.policy == servergroup_policy
- created_servergroup.data.instances | list | length == 0

- name: Get servergroup list
Expand All @@ -40,4 +40,4 @@

always:
- name: Cleanup servergroups
import_tasks: ./targets/common/tasks/cleanup_servergroups.yml
import_tasks: cleanup.yml
18 changes: 6 additions & 12 deletions tests/integration/targets/subnet/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
- name: Verify subnet
ansible.builtin.assert:
that:
- created_subnet.data.name == "{{ subnet_name }}"
- created_subnet.data.name == subnet_name
- created_subnet.data.has_router == false
- created_subnet.data.dns_nameservers == ['8.8.8.8', '8.8.4.4']
- created_subnet.data.cidr == "{{ subnet_cidr }}"
- created_subnet.data.network_id == "{{ created_network.data.id }}"
- created_subnet.data.cidr == subnet_cidr
- created_subnet.data.network_id == created_network.data.id
- created_subnet.data.metadata[0].key == "ansible_key"

- name: Update existing subnet
Expand All @@ -50,11 +50,11 @@
- name: Verify updated subnet
ansible.builtin.assert:
that:
- updated_subnet.data.name == "{{ new_subnet_name }}"
- updated_subnet.data.dns_nameservers == {{ dns_nameservers }}
- updated_subnet.data.name == new_subnet_name
- updated_subnet.data.dns_nameservers == dns_nameservers
- updated_subnet.data.enable_dhcp == false
- updated_subnet.data.host_routes | list | length == 0

- name: Update routes for subnet
gcore.cloud.subnet:
api_key: "{{ api_key }}"
Expand All @@ -69,9 +69,3 @@
ansible.builtin.assert:
that:
- subnet_with_routes.data.host_routes | list | length == 1

always:
- name: Cleanup subnets
import_tasks: ./targets/common/tasks/cleanup_subnets.yml
- name: Cleanup newtworks
import_tasks: ./targets/common/tasks/cleanup_networks.yml
2 changes: 1 addition & 1 deletion tests/integration/targets/volume/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
- import_tasks: tests.yml
always:
- name: Cleanup volumes
import_tasks: ./targets/common/tasks/cleanup_volumes.yml
import_tasks: cleanup.yml
Loading

0 comments on commit 7ef6602

Please sign in to comment.