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 f0183b2
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 93 deletions.
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("list", self.result["ssh_keys"]):
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
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"
62 changes: 31 additions & 31 deletions tests/integration/targets/instance/tasks/present.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
Expand All @@ -74,8 +74,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"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
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,7 +203,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.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
- 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
20 changes: 10 additions & 10 deletions tests/integration/targets/instance/tasks/present_display_name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
Expand All @@ -45,7 +45,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"
- instance.ssh_key == cs_resource_prefix + "-sshkey"
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 f0183b2

Please sign in to comment.