From bb5dcc00b63aac005dae0ae78b09450682c839bc Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Sat, 17 Oct 2015 14:01:02 +0200 Subject: [PATCH] cloudstack: add tests for cs_loadbalancer_rule and _member --- test/integration/cloudstack.yml | 1 + .../defaults/main.yml | 5 + .../test_cs_loadbalancer_rule/meta/main.yml | 3 + .../test_cs_loadbalancer_rule/tasks/main.yml | 211 ++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 test/integration/roles/test_cs_loadbalancer_rule/defaults/main.yml create mode 100644 test/integration/roles/test_cs_loadbalancer_rule/meta/main.yml create mode 100644 test/integration/roles/test_cs_loadbalancer_rule/tasks/main.yml diff --git a/test/integration/cloudstack.yml b/test/integration/cloudstack.yml index be36cc615a..93ba7876d8 100644 --- a/test/integration/cloudstack.yml +++ b/test/integration/cloudstack.yml @@ -21,3 +21,4 @@ - { role: test_cs_portforward, tags: test_cs_portforward } - { role: test_cs_account, tags: test_cs_account } - { role: test_cs_firewall, tags: test_cs_firewall } + - { role: test_cs_loadbalancer_rule, tags: test_cs_loadbalancer_rule } diff --git a/test/integration/roles/test_cs_loadbalancer_rule/defaults/main.yml b/test/integration/roles/test_cs_loadbalancer_rule/defaults/main.yml new file mode 100644 index 0000000000..5663384641 --- /dev/null +++ b/test/integration/roles/test_cs_loadbalancer_rule/defaults/main.yml @@ -0,0 +1,5 @@ +--- +test_cs_lb_public_ip: "1.2.3.4" +test_cs_instance_template: CentOS 5.3(64-bit) no GUI (Simulator) +test_cs_instance_offering_1: Small Instance +test_cs_lb_member: "{{ cs_resource_prefix }}_member1" diff --git a/test/integration/roles/test_cs_loadbalancer_rule/meta/main.yml b/test/integration/roles/test_cs_loadbalancer_rule/meta/main.yml new file mode 100644 index 0000000000..03e38bd4f7 --- /dev/null +++ b/test/integration/roles/test_cs_loadbalancer_rule/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - test_cs_common diff --git a/test/integration/roles/test_cs_loadbalancer_rule/tasks/main.yml b/test/integration/roles/test_cs_loadbalancer_rule/tasks/main.yml new file mode 100644 index 0000000000..030643615a --- /dev/null +++ b/test/integration/roles/test_cs_loadbalancer_rule/tasks/main.yml @@ -0,0 +1,211 @@ +--- +- name: setup + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + state: absent + register: lb +- name: verify setup + assert: + that: + - lb|success + +- name: setup instance + cs_instance: + name: "{{ test_cs_lb_member }}" + template: "{{ test_cs_instance_template }}" + service_offering: "{{ test_cs_instance_offering_1 }}" + register: instance +- name: verify create instance + assert: + that: + - instance|success + +- name: test rule requires params + cs_loadbalancer_rule: + ignore_errors: true + register: lb +- name: verify test rule requires params + assert: + that: + - lb|failed + - "'ip_address,name' in lb.msg" + +- name: test create rule + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + algorithm: roundrobin + public_port: 80 + private_port: 8080 + register: lb +- name: verify test create rule + assert: + that: + - lb|success + - lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "roundrobin" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + +- name: test create rule idempotence + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + algorithm: roundrobin + public_port: 80 + private_port: 8080 + register: lb +- name: verify test create rule idempotence + assert: + that: + - lb|success + - not lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "roundrobin" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + +- name: test update rule + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + algorithm: source + public_port: 80 + private_port: 8080 + register: lb +- name: verify test update rule + assert: + that: + - lb|success + - lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "source" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + +- name: test update rule idempotence + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + algorithm: source + public_port: 80 + private_port: 8080 + register: lb +- name: verify test update rule idempotence + assert: + that: + - lb|success + - not lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "source" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + +- name: test rule member requires params + cs_loadbalancer_rule_member: + ignore_errors: true + register: lb +- name: verify test rule requires params + assert: + that: + - lb|failed + - "'vms,name' in lb.msg" + +- name: test add members to rule + cs_loadbalancer_rule_member: + name: "{{ cs_resource_prefix }}_lb" + vm: "{{ test_cs_lb_member }}" + register: lb +- name: verify add members to rule + assert: + that: + - lb|success + - lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "source" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + - "'{{ test_cs_lb_member }}' in lb.vms" + +- name: test add members to rule idempotence + cs_loadbalancer_rule_member: + name: "{{ cs_resource_prefix }}_lb" + vm: "{{ test_cs_lb_member }}" + register: lb +- name: verify add members to rule idempotence + assert: + that: + - lb|success + - not lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "source" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + - "'{{ test_cs_lb_member }}' in lb.vms" + +- name: test remove members to rule + cs_loadbalancer_rule_member: + name: "{{ cs_resource_prefix }}_lb" + vm: "{{ test_cs_lb_member }}" + state: absent + register: lb +- name: verify remove members to rule + assert: + that: + - lb|success + - lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "source" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + - "'{{ test_cs_lb_member }}' not in lb.vms" + +- name: test remove members to rule idempotence + cs_loadbalancer_rule_member: + name: "{{ cs_resource_prefix }}_lb" + vm: "{{ test_cs_lb_member }}" + state: absent + register: lb +- name: verify remove members to rule + assert: + that: + - lb|success + - not lb|changed + +- name: test remove rule + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + state: absent + register: lb +- name: verify remove rule + assert: + that: + - lb|success + - lb|changed + - lb.name == "{{ cs_resource_prefix }}_lb" + - lb.algorithm == "source" + - lb.public_ip == "{{ test_cs_lb_public_ip }}" + - lb.public_port == 80 + - lb.private_port == 8080 + +- name: test remove rule idempotence + cs_loadbalancer_rule: + name: "{{ cs_resource_prefix }}_lb" + public_ip: "{{ test_cs_lb_public_ip }}" + state: absent + register: lb +- name: verify remove rule idempotence + assert: + that: + - lb|success + - not lb|changed