Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: setup new temporary project service for integration tests #316

Merged
merged 5 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_certificate_name: "{{ hcloud_ns }}"
hcloud_dns_test_domain: "{{ hcloud_ns }}-{{ 100 | random }}.hc-certs.de"
hcloud_dns_test_domain: "{{ (hcloud_ns + 100 | random | string) | md5 }}.hc-integrations-test.de"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_snapshot_id: 10164049
hcloud_snapshot_name: always-there-snapshot
hcloud_server_name: "{{ hcloud_ns }}"
hcloud_snapshot_name: "{{ hcloud_ns }}"
hcloud_image_name: ubuntu-22.04
3 changes: 3 additions & 0 deletions tests/integration/targets/hcloud_image_info/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- setup_hcloud_cli
5 changes: 5 additions & 0 deletions tests/integration/targets/hcloud_image_info/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Cleanup test_server
hetzner.hcloud.hcloud_server:
name: "{{ hcloud_server_name }}"
state: absent
23 changes: 23 additions & 0 deletions tests/integration/targets/hcloud_image_info/tasks/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Create test_server
hetzner.hcloud.hcloud_server:
name: "{{ hcloud_server_name }}"
server_type: cx11
image: ubuntu-22.04
state: stopped
register: test_server

- name: Create test_snapshot
ansible.builtin.script:
cmd: >
{{ hcloud_cli_path }} server create-image
--type snapshot
--description "{{ hcloud_snapshot_name }}"
--label key=value
"{{ test_server.hcloud_server.id }}"
| awk '{print $2}'
jooola marked this conversation as resolved.
Show resolved Hide resolved
register: test_snapshot

- name: Set test_snapshot_id
ansible.builtin.set_fact:
test_snapshot_id: "{{ test_snapshot.stdout_lines[0] }}"
4 changes: 2 additions & 2 deletions tests/integration/targets/hcloud_image_info/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

- name: Gather hcloud_image_info with correct id
hetzner.hcloud.hcloud_image_info:
id: "{{ hcloud_snapshot_id }}"
id: "{{ test_snapshot_id }}"
type: snapshot
register: result
- name: Verify hcloud_image_info with correct id
Expand All @@ -40,7 +40,7 @@

- name: Gather hcloud_image_info with wrong id
hetzner.hcloud.hcloud_image_info:
id: "{{ hcloud_snapshot_id }}4321"
id: "{{ test_snapshot_id }}4321"
type: snapshot
ignore_errors: true
register: result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
---
hcloud_server_name: "{{ hcloud_ns }}"
hcloud_load_balancer_name: "{{ hcloud_ns }}"
hcloud_testing_ip: "176.9.59.39"

hetzner_server_ip: 142.132.203.104
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@
- name: test create ip target
hetzner.hcloud.hcloud_load_balancer_target:
type: "ip"
load_balancer: "{{hcloud_load_balancer_name}}"
ip: "{{hcloud_testing_ip}}"
load_balancer: "{{ hcloud_load_balancer_name }}"
ip: "{{ hetzner_server_ip }}"
state: present
register: load_balancer_target
- name: verify create ip target
assert:
that:
- load_balancer_target is changed
- load_balancer_target.hcloud_load_balancer_target.type == "ip"
- load_balancer_target.hcloud_load_balancer_target.ip == hcloud_testing_ip
- load_balancer_target.hcloud_load_balancer_target.ip == hetzner_server_ip
- load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name

- name: cleanup load_balancer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
hcloud_network_name: "{{ hcloud_ns }}"
hetzner_vswitch_id: 15311
hetzner_vswitch_id: 43065
16 changes: 16 additions & 0 deletions tests/integration/targets/setup_hcloud_cli/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Create temporary file for hcloud_cli_path
ansible.builtin.tempfile:
state: directory
register: _tmp_hcloud_cli

- name: Download hcloud cli from Github releases
ansible.builtin.unarchive:
src: https://github.com/hetznercloud/cli/releases/download/v1.37.0/hcloud-linux-amd64.tar.gz
dest: "{{ _tmp_hcloud_cli.path }}"
remote_src: true
extra_opts: [hcloud]

- name: Set hcloud_cli_path
ansible.builtin.set_fact:
hcloud_cli_path: "{{ _tmp_hcloud_cli.path }}/hcloud"