Skip to content

Commit

Permalink
fix instance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed Nov 26, 2024
1 parent 5413316 commit b996458
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ansible-branch:
- stable-2.17
group:
- 3
- 4
container-version:
- 1.7.0
steps:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,10 @@ def restore_instance(self):
def get_result(self, resource):
super(AnsibleCloudStackInstance, self).get_result(resource)
if resource:
# 4.18 does not return keypairs as list as doc claims
if "ssh_keys" in self.result and not isinstance(self.result["ssh_keys"], list):
self.result["ssh_keys"] = [self.result["ssh_keys"]]

self.result["user_data"] = self._get_instance_user_data(resource)
if "securitygroup" in resource:
security_groups = []
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/instance/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cloud/cs
cs/group1
cs/group3
cs/group4
14 changes: 7 additions & 7 deletions tests/integration/targets/instance/tasks/host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.host is not defined
- instance.state == "Stopped"

Expand All @@ -63,7 +63,7 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.host == host.name
- instance.state == "Running"

Expand All @@ -78,7 +78,7 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.host == host.name
- instance.state == "Running"

Expand All @@ -101,7 +101,7 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.host != host.name
- instance.state == "Running"

Expand All @@ -116,7 +116,7 @@
assert:
that:
- instance is changed
- instance.name cs_resource_prefix + "-vm-" + instance_number
- instance.name cs_resource_prefix + "-vm-" + instance_number|string
- instance.host == host.name
- instance.state == "Running"

Expand All @@ -131,7 +131,7 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.host == host.name
- instance.state == "Running"
68 changes: 34 additions & 34 deletions tests/integration/targets/instance/tasks/present.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
- 'cs_resource_prefix + "-sshkey" in instance.ssh_keys'
- not instance.tags

- name: test create instance idempotence
Expand All @@ -74,11 +74,11 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
- 'cs_resource_prefix + "-sshkey" in instance.ssh_keys'
- not instance.tags

- name: gather host infos of running instance
Expand All @@ -96,8 +96,8 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -111,8 +111,8 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -127,8 +127,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -142,8 +142,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Stopped"

Expand Down Expand Up @@ -171,8 +171,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Stopped"

Expand All @@ -187,8 +187,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_2
- instance.state == "Stopped"

Expand All @@ -203,8 +203,8 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_2
- instance.state == "Stopped"

Expand All @@ -218,8 +218,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_2
- instance.state == "Running"

Expand All @@ -233,8 +233,8 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_2
- instance.state == "Running"

Expand All @@ -250,8 +250,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_2
- instance.state == "Running"

Expand All @@ -266,8 +266,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -282,8 +282,8 @@
assert:
that:
- instance is not changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -299,8 +299,8 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1

- name: test restore instance
Expand All @@ -314,6 +314,6 @@
assert:
that:
- instance is changed
- instance.name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-display-" + instance_number
- instance.name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.display_name == cs_resource_prefix + "-display-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
24 changes: 12 additions & 12 deletions tests/integration/targets/instance/tasks/present_display_name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
assert:
that:
- instance is changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
- 'cs_resource_prefix + "-sshkey" in instance.ssh_keys'
- not instance.tags

- name: test create instance with display_name idempotence
Expand All @@ -45,10 +45,10 @@
assert:
that:
- instance is not changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
- 'cs_resource_prefix + "-sshkey" in instance.ssh_keys'
- not instance.tags

- name: test running instance with display_name not updated
Expand All @@ -61,7 +61,7 @@
assert:
that:
- instance is not changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -75,7 +75,7 @@
assert:
that:
- instance is changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Stopped"

Expand All @@ -101,7 +101,7 @@
assert:
that:
- instance is changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
- instance.state == "Stopped"

Expand All @@ -115,7 +115,7 @@
assert:
that:
- instance is changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
- instance.state == "Running"

Expand All @@ -129,7 +129,7 @@
assert:
that:
- instance is not changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
- instance.state == "Running"

Expand All @@ -144,7 +144,7 @@
assert:
that:
- instance is changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -159,7 +159,7 @@
assert:
that:
- instance is not changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
- instance.state == "Running"

Expand All @@ -174,5 +174,5 @@
assert:
that:
- instance is changed
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number
- instance.display_name == cs_resource_prefix + "-vm-" + instance_number|string
- instance.service_offering == test_cs_instance_offering_1
Loading

0 comments on commit b996458

Please sign in to comment.