diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index 7d6d86c4cff..48ca9322ee1 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -10,3 +10,6 @@ - role: test_rax_clb tags: test_rax_clb + + - role: test_rax_clb_nodes + tags: test_rax_clb_nodes diff --git a/test/integration/roles/test_rax_clb_nodes/defaults/main.yml b/test/integration/roles/test_rax_clb_nodes/defaults/main.yml new file mode 100644 index 00000000000..4854b645cf5 --- /dev/null +++ b/test/integration/roles/test_rax_clb_nodes/defaults/main.yml @@ -0,0 +1,3 @@ +--- +rackspace_region: IAD +resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax_clb_nodes/tasks/main.yml b/test/integration/roles/test_rax_clb_nodes/tasks/main.yml new file mode 100644 index 00000000000..5a867b19eb6 --- /dev/null +++ b/test/integration/roles/test_rax_clb_nodes/tasks/main.yml @@ -0,0 +1,241 @@ +--- +- name: Check for required variables + assert: + that: + - resource_prefix is defined and resource_prefix + - rackspace_username is defined and rackspace_username + - rackspace_api_key is defined and rackspace_api_key + - rackspace_region is defined and rackspace_region + +# ============================================================ +- name: Test rax_clb_nodes with no args + rax_clb_nodes: + ignore_errors: true + register: rax_clb_nodes + +- name: Validate results of rax_clb_nodes with no args + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == 'missing required arguments: load_balancer_id' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with load_balancer_Id + rax_clb_nodes: + load_balancer_id: 1234 + ignore_errors: true + register: rax_clb_nodes + +- name: Validate results of rax_clb_nodes with load_balancer_id + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with credentials and load_balancer_id + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + load_balancer_id: 1234 + ignore_errors: true + register: rax_clb_nodes + +- name: Validate results of rax_clb_nodes with credentials and load_balancer_id + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with creds, region and load_balancer_id + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: 1234 + ignore_errors: true + register: rax_clb_nodes + +- name: Validate rax_clb_nodes creds, region and load_balancer_id + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == 'Load balancer not found' +# ============================================================ + + + +# ============================================================ +- name: Build a CLB to test rax_clb_nodes with + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-clb" + wait: true + register: rax_clb + +- name: Validate rax_clb creation + assert: + that: + - rax_clb|success + +- name: Set variable for CLB ID + set_fact: + rax_clb_id: "{{ rax_clb.balancer.id }}" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with creds, region and valid load_balancer_id + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: "{{ rax_clb_id }}" + ignore_errors: true + register: rax_clb_nodes + +- name: Validate rax_clb_nodes creds, region and valid load_balancer_id + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == 'You must include an address and a port when creating a node.' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with creds, region, load_balancer_id and address + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: "{{ rax_clb_id }}" + address: '10.10.10.10' + ignore_errors: true + register: rax_clb_nodes + +- name: Validate rax_clb_nodes creds, region, load_balancer_id and address + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == 'You must include an address and a port when creating a node.' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with creds, region, load_balancer_id, invalid address and port + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: "{{ rax_clb_id }}" + address: '10.10.10.10' + port: 80 + ignore_errors: true + register: rax_clb_nodes + +- name: Validate rax_clb_nodes creds, region, load_balancer_id, invalid address and port + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == "Invalid node address. The address '10.10.10.10' is currently not accepted for this request." +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with creds, region, load_balancer_id, address and port + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: "{{ rax_clb_id }}" + address: '172.16.0.1' + port: 80 + wait: true + register: rax_clb_nodes + +- name: Validate rax_clb_nodes creds, region, load_balancer_id, address and port + assert: + that: + - rax_clb_nodes|success + - rax_clb_nodes.node.address == '172.16.0.1' + - rax_clb_nodes.node.condition == 'ENABLED' + - rax_clb_nodes.node.port == 80 + - rax_clb_nodes.node.status == 'ONLINE' + - rax_clb_nodes.node.type == 'PRIMARY' + - rax_clb_nodes.node.weight == 1 + +- name: Delete integration 1 + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: "{{ rax_clb_id }}" + node_id: "{{ rax_clb_nodes.node.id }}" + state: absent + wait: true + register: rax_clb_nodes + +- name: Validate delete integration 1 + assert: + that: + - rax_clb_nodes|success +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb_nodes with creds, region, load_balancer_id, address, port and type + rax_clb_nodes: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + load_balancer_id: "{{ rax_clb_id }}" + address: '172.16.0.1' + port: 80 + type: secondary + wait: true + ignore_errors: true + register: rax_clb_nodes + +- name: Validate rax_clb_nodes creds, region, load_balancer_id, address, port and type + assert: + that: + - rax_clb_nodes|failed + - rax_clb_nodes.msg == 'you must enable health monitoring to use secondary nodes' +# ============================================================ + + + +# ============================================================ +- name: Delete CLB + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ rax_clb.balancer.name }}" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 3" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.id == rax_clb_id|int +# ============================================================