From 7ba7e3bd698fb4204ff5202aff3f4e4f8801e19d Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 15 Jan 2015 11:38:20 -0600 Subject: [PATCH 01/17] Add tests for rax_clb --- test/integration/cleanup_rax.py | 29 +- test/integration/rackspace.yml | 3 + .../roles/test_rax_clb/defaults/main.yml | 3 + .../roles/test_rax_clb/tasks/main.yml | 851 ++++++++++++++++++ 4 files changed, 885 insertions(+), 1 deletion(-) create mode 100644 test/integration/roles/test_rax_clb/defaults/main.yml create mode 100644 test/integration/roles/test_rax_clb/tasks/main.yml diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index 5fdd15d8a1d..f396bbdb68d 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +import re import yaml import argparse @@ -11,6 +12,19 @@ except ImportError: HAS_PYRAX = False +def rax_list_iterator(svc, *args, **kwargs): + method = kwargs.pop('method', 'list') + items = getattr(svc, method)(*args, **kwargs) + while items: + retrieved = getattr(svc, method)(*args, marker=items[-1].id, **kwargs) + if items and retrieved and items[-1].id == retrieved[0].id: + del items[-1] + items.extend(retrieved) + if len(retrieved) < 2: + break + return items + + def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('-y', '--yes', action='store_true', dest='assumeyes', @@ -53,15 +67,27 @@ def prompt_and_delete(item, prompt, assumeyes): def delete_rax(args): """Function for deleting CloudServers""" + search_opts = dict(name='^%s' % args.match_re) for region in pyrax.identity.services.compute.regions: cs = pyrax.connect_to_cloudservers(region=region) - servers = cs.servers.list(search_opts=dict(name='^%s' % args.match_re)) + servers = rax_list_iterator(cs.servers, search_opts=search_opts) for server in servers: prompt_and_delete(server, 'Delete matching %s? [y/n]: ' % server, args.assumeyes) +def delete_rax_clb(args): + """Function for deleting Cloud Load Balancers""" + for region in pyrax.identity.services.load_balancer.regions: + clb = pyrax.connect_to_cloud_loadbalancers(region=region) + for lb in rax_list_iterator(clb): + if re.search(args.match_re, lb.name): + prompt_and_delete(lb, + 'Delete matching %s? [y/n]: ' % lb, + args.assumeyes) + + def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') @@ -69,6 +95,7 @@ def main(): args = parse_args() authenticate() delete_rax(args) + delete_rax_clb(args) if __name__ == '__main__': diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index fd3079e9de0..7d6d86c4cff 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -7,3 +7,6 @@ roles: - role: test_rax tags: test_rax + + - role: test_rax_clb + tags: test_rax_clb diff --git a/test/integration/roles/test_rax_clb/defaults/main.yml b/test/integration/roles/test_rax_clb/defaults/main.yml new file mode 100644 index 00000000000..4854b645cf5 --- /dev/null +++ b/test/integration/roles/test_rax_clb/defaults/main.yml @@ -0,0 +1,3 @@ +--- +rackspace_region: IAD +resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax_clb/tasks/main.yml b/test/integration/roles/test_rax_clb/tasks/main.yml new file mode 100644 index 00000000000..9cc282e5eb0 --- /dev/null +++ b/test/integration/roles/test_rax_clb/tasks/main.yml @@ -0,0 +1,851 @@ +--- +- 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 with no args + rax_clb: + ignore_errors: true + register: rax_clb + +- name: Validate results of rax_clb with no args + assert: + that: + - rax_clb|failed + - rax_clb.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with credentials + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + ignore_errors: true + register: rax_clb + +- name: Validate results of rax_clb with only creds + assert: + that: + - rax_clb|failed + - rax_clb.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds and region + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + ignore_errors: true + register: rax_clb + +## This assertion is currently failing, due to the module not providing the correct name of the missing argument +- name: Validate rax_clb creds and region + assert: + that: + - rax_clb|failed + - rax_clb.msg == 'name is required for rax_clb' + ignore_errors: true +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region and name + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region and name + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 80 + - rax_clb.balancer.protocol == 'HTTP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + - rax_clb.balancer.algorithm == 'LEAST_CONNECTIONS' + +- name: "Delete integration 1" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 1" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-1" + +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name and protocol + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + protocol: TCP + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name and protocol + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 80 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 2" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 2" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-2" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol and port + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + protocol: TCP + port: 8080 + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol and port + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 3" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 3" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-3" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port and type + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + protocol: TCP + port: 8080 + type: SERVICENET + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol and type + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 4" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 4" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-4" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid timeout + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - rax_clb.msg == '"timeout" must be greater than or equal to 30' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port, type and timeout + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-5" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 60 + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol, type and timeout + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 60 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 5" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-5" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 5" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-5" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port, type, timeout and algorithm + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 60 + algorithm: RANDOM + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol, type, timeout and algorithm + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 60 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + - rax_clb.balancer.algorithm == 'RANDOM' + +- name: "Delete integration 6" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 6" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-6" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid type + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + type: BAD + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - "rax_clb.msg == 'value of type must be one of: PUBLIC,SERVICENET, got: BAD'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid protocol + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + protocol: BAD + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - "rax_clb.msg == 'value of protocol must be one of: DNS_TCP,DNS_UDP,FTP,HTTP,HTTPS,IMAPS,IMAPv4,LDAP,LDAPS,MYSQL,POP3,POP3S,SMTP,TCP,TCP_CLIENT_FIRST,UDP,UDP_STREAM,SFTP, got: BAD'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid algorithm + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + algorithm: BAD + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - "rax_clb.msg == 'value of algorithm must be one of: RANDOM,LEAST_CONNECTIONS,ROUND_ROBIN,WEIGHTED_LEAST_CONNECTIONS,WEIGHTED_ROUND_ROBIN, got: BAD'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port, type, timeout, algorithm and metadata + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-7" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 60 + algorithm: RANDOM + meta: + foo: bar + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol, type, timeout, algorithm and metadata + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 60 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.status == 'ACTIVE' + - rax_clb.balancer.algorithm == 'RANDOM' + - rax_clb.balancer.metadata.0.key == 'foo' + - rax_clb.balancer.metadata.0.value == 'bar' + +- name: "Delete integration 7" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-7" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 7" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-7" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with shared VIP HTTP + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTP" + wait: true + register: rax_clb_http + +- name: Validate rax_clb with shared VIP HTTP + assert: + that: + - rax_clb_http|success + - rax_clb_http.balancer.protocol == 'HTTP' + - rax_clb_http.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb_http.balancer.status == 'ACTIVE' + +- name: Test rax_clb with shared VIP HTTPS + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTPS" + protocol: HTTPS + port: 443 + wait: true + vip_id: "{{ (rax_clb_http.balancer.virtual_ips|first).id }}" + register: rax_clb_https + +- name: Validate Test rax_clb with shared VIP + assert: + that: + - rax_clb_https|success + - rax_clb_https.balancer.protocol == 'HTTPS' + - rax_clb_https.balancer.status == 'ACTIVE' + - rax_clb_http.balancer.virtual_ips == rax_clb_https.balancer.virtual_ips + +- name: "Delete integration 8 HTTP" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTP" + state: absent + wait: true + register: rax_clb_http + +- name: "Delete integration 8 HTTPS" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTPS" + state: absent + wait: true + register: rax_clb_http + +- name: "Validate delete integration 8" + assert: + that: + - rax_clb_http|changed + - rax_clb_https|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated protocol 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-9" + wait: true + register: rax_clb_p1 + +- name: Validate rax_clb with updated protocol 1 + assert: + that: + - rax_clb_p1|success + - rax_clb_p1.balancer.protocol == 'HTTP' + - rax_clb_p1.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb_p1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated protocol 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-9" + protocol: TCP + wait: true + register: rax_clb_p2 + +- name: Validate rax_clb with updated protocol 2 + assert: + that: + - rax_clb_p1.balancer.id == rax_clb_p2.balancer.id + - rax_clb_p2|success + - rax_clb_p2|changed + - rax_clb_p2.balancer.protocol == 'TCP' + - rax_clb_p2.balancer.status == 'ACTIVE' + +- name: Delete integration 9 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-9" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 9" + assert: + that: + - rax_clb|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated algorithm 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-10" + wait: true + register: rax_clb_a1 + +- name: Validate rax_clb with updated algorithm 1 + assert: + that: + - rax_clb_a1|success + - rax_clb_a1.balancer.algorithm == 'LEAST_CONNECTIONS' + - rax_clb_a1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated algoritm 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-10" + algorithm: RANDOM + wait: true + register: rax_clb_a2 + +- name: Validate rax_clb with updated algorithm 2 + assert: + that: + - rax_clb_a1.balancer.id == rax_clb_a2.balancer.id + - rax_clb_a2|success + - rax_clb_a2|changed + - rax_clb_a2.balancer.algorithm == 'RANDOM' + - rax_clb_a2.balancer.status == 'ACTIVE' + +- name: Delete integration 10 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-10" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 10" + assert: + that: + - rax_clb|changed + - rax_clb_a1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated port 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-11" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with updated port 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.port == 80 + - rax_clb_1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated port 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-11" + port: 8080 + wait: true + register: rax_clb_2 + +- name: Validate rax_clb with updated port 2 + assert: + that: + - rax_clb_1.balancer.id == rax_clb_2.balancer.id + - rax_clb_2|success + - rax_clb_2|changed + - rax_clb_2.balancer.port == 8080 + - rax_clb_2.balancer.status == 'ACTIVE' + +- name: Delete integration 11 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-11" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 11" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated timeout 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-12" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with updated timeout 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.timeout == 30 + - rax_clb_1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated timeout 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-12" + timeout: 60 + wait: true + register: rax_clb_2 + +- name: Validate rax_clb with updated timeout 2 + assert: + that: + - rax_clb_1.balancer.id == rax_clb_2.balancer.id + - rax_clb_2|success + - rax_clb_2|changed + - rax_clb_2.balancer.timeout == 60 + - rax_clb_2.balancer.status == 'ACTIVE' + +- name: Delete integration 12 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-12" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 12" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid updated type 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-13" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with invalid updated type 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with invalid updated type 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-13" + type: SERVICENET + wait: true + register: rax_clb_2 + ignore_errors: true + +- name: Validate rax_clb with updated timeout 2 + assert: + that: + - rax_clb_2|failed + - rax_clb_2.msg == 'Load balancer Virtual IP type cannot be changed' + +- name: Delete integration 13 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-13" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 13" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated meta 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-14" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with updated meta 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.status == 'ACTIVE' + - rax_clb_1.balancer.metadata is not defined + +- name: Test rax_clb with updated meta 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-14" + meta: + foo: bar + wait: true + register: rax_clb_2 + +- name: Validate rax_clb with updated meta 2 + assert: + that: + - rax_clb_1.balancer.id == rax_clb_2.balancer.id + - rax_clb_2|success + - rax_clb_2|changed + - rax_clb_2.balancer.metadata.0.key == 'foo' + - rax_clb_2.balancer.metadata.0.value == 'bar' + - rax_clb_2.balancer.status == 'ACTIVE' + +- name: Delete integration 14 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-14" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 14" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ From b8e7211661a9ab877dab169e3dc48aa954ab7322 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 15 Jan 2015 19:39:57 -0600 Subject: [PATCH 02/17] Update rax_clb tests for fixes in the module --- .../roles/test_rax_clb/tasks/main.yml | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/integration/roles/test_rax_clb/tasks/main.yml b/test/integration/roles/test_rax_clb/tasks/main.yml index 9cc282e5eb0..b52094035e1 100644 --- a/test/integration/roles/test_rax_clb/tasks/main.yml +++ b/test/integration/roles/test_rax_clb/tasks/main.yml @@ -14,6 +14,22 @@ register: rax_clb - name: Validate results of rax_clb with no args + assert: + that: + - rax_clb|failed + - rax_clb.msg == 'missing required arguments: name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with name + rax_clb: + name: fail + ignore_errors: true + register: rax_clb + +- name: Validate results of rax_clb with only creds assert: that: - rax_clb|failed @@ -23,10 +39,11 @@ # ============================================================ -- name: Test rax_clb with credentials +- name: Test rax_clb with name and credentials rax_clb: username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" + name: fail ignore_errors: true register: rax_clb @@ -48,13 +65,11 @@ ignore_errors: true register: rax_clb -## This assertion is currently failing, due to the module not providing the correct name of the missing argument - name: Validate rax_clb creds and region assert: that: - rax_clb|failed - - rax_clb.msg == 'name is required for rax_clb' - ignore_errors: true + - rax_clb.msg == 'missing required arguments: name' # ============================================================ From b151c7ffac8a94d39ec82cac04b654608ea9f678 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 15 Jan 2015 19:40:35 -0600 Subject: [PATCH 03/17] Add some additional output to cleanup_rax.py --- test/integration/cleanup_rax.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index f396bbdb68d..87084d06e92 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -67,6 +67,7 @@ def prompt_and_delete(item, prompt, assumeyes): def delete_rax(args): """Function for deleting CloudServers""" + print ("--- Cleaning CloudServers matching '%s'" % args.match_re) search_opts = dict(name='^%s' % args.match_re) for region in pyrax.identity.services.compute.regions: cs = pyrax.connect_to_cloudservers(region=region) @@ -79,6 +80,7 @@ def delete_rax(args): def delete_rax_clb(args): """Function for deleting Cloud Load Balancers""" + print ("--- Cleaning Cloud Load Balancers matching '%s'" % args.match_re) for region in pyrax.identity.services.load_balancer.regions: clb = pyrax.connect_to_cloud_loadbalancers(region=region) for lb in rax_list_iterator(clb): From 5a862328f0c9784a641a43e023ca1f3f41d22922 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 15 Jan 2015 19:41:02 -0600 Subject: [PATCH 04/17] Add test_rax_clb_nodes --- test/integration/rackspace.yml | 3 + .../test_rax_clb_nodes/defaults/main.yml | 3 + .../roles/test_rax_clb_nodes/tasks/main.yml | 241 ++++++++++++++++++ 3 files changed, 247 insertions(+) create mode 100644 test/integration/roles/test_rax_clb_nodes/defaults/main.yml create mode 100644 test/integration/roles/test_rax_clb_nodes/tasks/main.yml 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 +# ============================================================ From dab9c30584185714bfced8328ebd28c1975042ff Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 16 Jan 2015 10:04:05 -0600 Subject: [PATCH 05/17] Add some extra vars and create a dependent role prepare_rax_tests --- test/integration/Makefile | 5 +- test/integration/rackspace.yml | 5 + .../roles/prepare_rax_tests/defaults/main.yml | 7 + .../roles/prepare_rax_tests/tasks/main.yml | 11 ++ .../roles/test_rax/defaults/main.yml | 3 - test/integration/roles/test_rax/meta/main.yml | 3 + .../integration/roles/test_rax/tasks/main.yml | 131 ++++++++---------- .../roles/test_rax_clb/defaults/main.yml | 3 - .../roles/test_rax_clb/meta/main.yml | 3 + .../roles/test_rax_clb/tasks/main.yml | 9 -- .../test_rax_clb_nodes/defaults/main.yml | 3 - .../roles/test_rax_clb_nodes/meta/main.yml | 3 + .../roles/test_rax_clb_nodes/tasks/main.yml | 9 -- 13 files changed, 97 insertions(+), 98 deletions(-) create mode 100644 test/integration/roles/prepare_rax_tests/defaults/main.yml create mode 100644 test/integration/roles/prepare_rax_tests/tasks/main.yml delete mode 100644 test/integration/roles/test_rax/defaults/main.yml create mode 100644 test/integration/roles/test_rax/meta/main.yml delete mode 100644 test/integration/roles/test_rax_clb/defaults/main.yml create mode 100644 test/integration/roles/test_rax_clb/meta/main.yml delete mode 100644 test/integration/roles/test_rax_clb_nodes/defaults/main.yml create mode 100644 test/integration/roles/test_rax_clb_nodes/meta/main.yml diff --git a/test/integration/Makefile b/test/integration/Makefile index c708e08e402..1322871593d 100644 --- a/test/integration/Makefile +++ b/test/integration/Makefile @@ -115,7 +115,10 @@ gce: $(CREDENTIALS_FILE) CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make gce_cleanup ; \ exit $$RC; -rackspace: $(CREDENTIALS_FILE) +rackspace_prepare: + ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) -t prepare + +rackspace: rackspace_prepare $(CREDENTIALS_FILE) ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \ RC=$$? ; \ CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make rackspace_cleanup ; \ diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index 48ca9322ee1..5d4d389f8d3 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -5,6 +5,11 @@ tags: - rackspace roles: + - role: prepare_rax_tests + tags: + - prepare + - prepare_rax_tests + - role: test_rax tags: test_rax diff --git a/test/integration/roles/prepare_rax_tests/defaults/main.yml b/test/integration/roles/prepare_rax_tests/defaults/main.yml new file mode 100644 index 00000000000..ccead866c7e --- /dev/null +++ b/test/integration/roles/prepare_rax_tests/defaults/main.yml @@ -0,0 +1,7 @@ +--- +rackspace_region: IAD +rackspace_image_human_id: "ubuntu-1404-lts-trusty-tahr-pvhvm" +rackspace_image_id: "753a7703-4960-488b-aab4-a3cdd4b276dc" +rackspace_image_name: "Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)" +rackspace_flavor: "performance1-1" +resource_prefix: ansible-testing diff --git a/test/integration/roles/prepare_rax_tests/tasks/main.yml b/test/integration/roles/prepare_rax_tests/tasks/main.yml new file mode 100644 index 00000000000..60cc52830f6 --- /dev/null +++ b/test/integration/roles/prepare_rax_tests/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- 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 + - rackspace_image_human_id is defined and rackspace_image_human_id + - rackspace_image_id is defined and rackspace_image_id + - rackspace_image_name is defined and rackspace_image_name diff --git a/test/integration/roles/test_rax/defaults/main.yml b/test/integration/roles/test_rax/defaults/main.yml deleted file mode 100644 index 4854b645cf5..00000000000 --- a/test/integration/roles/test_rax/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -rackspace_region: IAD -resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax/meta/main.yml b/test/integration/roles/test_rax/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax/tasks/main.yml b/test/integration/roles/test_rax/tasks/main.yml index e4422d88592..4fe820a3c23 100644 --- a/test/integration/roles/test_rax/tasks/main.yml +++ b/test/integration/roles/test_rax/tasks/main.yml @@ -1,12 +1,3 @@ ---- -- 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 with no args rax: @@ -63,7 +54,7 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin + image: "{{ rackspace_image_id }}" ignore_errors: true register: rax @@ -82,8 +73,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" ignore_errors: true register: rax @@ -102,8 +93,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-1" register: rax @@ -123,8 +114,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-1" state: absent wait: true @@ -146,8 +137,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-2" wait: true register: rax @@ -168,8 +159,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-2" wait: true register: rax @@ -189,8 +180,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-2" state: absent wait: true @@ -214,8 +205,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-3" meta: foo: bar @@ -239,8 +230,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-3" meta: foo: bar @@ -262,8 +253,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-3" state: absent meta: @@ -289,8 +280,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-4" count: 2 wait: true @@ -310,8 +301,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-4" count: 2 wait: true @@ -331,8 +322,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-4" count: 3 wait: true @@ -352,8 +343,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-4" count: 3 state: absent @@ -378,8 +369,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-5-%02d" count: 2 group: "{{ resource_prefix }}-5" @@ -401,8 +392,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-5-%02d" count: 2 group: "{{ resource_prefix }}-5" @@ -428,8 +419,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-6-%02d" count: 2 group: "{{ resource_prefix }}-6" @@ -451,8 +442,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-6-%02d" count: 2 group: "{{ resource_prefix }}-6" @@ -473,8 +464,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-6-%02d" count: 4 group: "{{ resource_prefix }}-6" @@ -500,8 +491,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-7-%02d" count: 2 exact_count: true @@ -524,8 +515,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-7-%02d" count: 2 exact_count: true @@ -547,8 +538,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-7-%02d" count: 4 exact_count: true @@ -572,8 +563,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-7-%02d" count: 0 exact_count: true @@ -599,8 +590,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-8" count: 2 group: "{{ resource_prefix }}-8" @@ -623,8 +614,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-8" count: 2 group: "{{ resource_prefix }}-8" @@ -651,8 +642,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-9" count: 2 exact_count: true @@ -675,8 +666,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-9" count: 0 exact_count: true @@ -702,8 +693,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-10-%03d" count: 2 count_offset: 10 @@ -727,8 +718,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-10-%03d" count: 0 count_offset: 10 @@ -755,8 +746,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-10-%03d" count: 2 count_offset: 10 @@ -780,8 +771,8 @@ username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" - image: ubuntu-1204-lts-precise-pangolin - flavor: performance1-1 + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" name: "{{ resource_prefix }}-10-%03d" count: 0 count_offset: 10 diff --git a/test/integration/roles/test_rax_clb/defaults/main.yml b/test/integration/roles/test_rax_clb/defaults/main.yml deleted file mode 100644 index 4854b645cf5..00000000000 --- a/test/integration/roles/test_rax_clb/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -rackspace_region: IAD -resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax_clb/meta/main.yml b/test/integration/roles/test_rax_clb/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_clb/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_clb/tasks/main.yml b/test/integration/roles/test_rax_clb/tasks/main.yml index b52094035e1..8f6a990ceb2 100644 --- a/test/integration/roles/test_rax_clb/tasks/main.yml +++ b/test/integration/roles/test_rax_clb/tasks/main.yml @@ -1,12 +1,3 @@ ---- -- 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 with no args rax_clb: diff --git a/test/integration/roles/test_rax_clb_nodes/defaults/main.yml b/test/integration/roles/test_rax_clb_nodes/defaults/main.yml deleted file mode 100644 index 4854b645cf5..00000000000 --- a/test/integration/roles/test_rax_clb_nodes/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -rackspace_region: IAD -resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax_clb_nodes/meta/main.yml b/test/integration/roles/test_rax_clb_nodes/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_clb_nodes/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_clb_nodes/tasks/main.yml b/test/integration/roles/test_rax_clb_nodes/tasks/main.yml index 5a867b19eb6..01bbf9dd9a3 100644 --- a/test/integration/roles/test_rax_clb_nodes/tasks/main.yml +++ b/test/integration/roles/test_rax_clb_nodes/tasks/main.yml @@ -1,12 +1,3 @@ ---- -- 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: From 340b845c38b646de05ea4397832959b614d2953d Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 16 Jan 2015 10:04:28 -0600 Subject: [PATCH 06/17] Add test_rax_facts --- test/integration/rackspace.yml | 3 + .../roles/test_rax_facts/meta/main.yml | 3 + .../roles/test_rax_facts/tasks/main.yml | 279 ++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 test/integration/roles/test_rax_facts/meta/main.yml create mode 100644 test/integration/roles/test_rax_facts/tasks/main.yml diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index 5d4d389f8d3..bf4696d3e73 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -13,6 +13,9 @@ - role: test_rax tags: test_rax + - role: test_rax_facts + tags: test_rax_facts + - role: test_rax_clb tags: test_rax_clb diff --git a/test/integration/roles/test_rax_facts/meta/main.yml b/test/integration/roles/test_rax_facts/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_facts/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_facts/tasks/main.yml b/test/integration/roles/test_rax_facts/tasks/main.yml new file mode 100644 index 00000000000..374fd8c7c03 --- /dev/null +++ b/test/integration/roles/test_rax_facts/tasks/main.yml @@ -0,0 +1,279 @@ +# ============================================================ +- name: Test rax_facts with no args + rax_facts: + ignore_errors: true + register: rax_facts + +- name: Validate results of rax_facts with no args + assert: + that: + - rax_facts|failed + - rax_facts.msg == 'one of the following is required: address,id,name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with credentials and address + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + address: '1.2.3.4' + ignore_errors: true + register: rax_facts + +- name: Validate results of rax_facts with only creds + assert: + that: + - rax_facts|failed + - rax_facts.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region and address + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: '1.2.3.4' + ignore_errors: true + register: rax_facts + +- name: Validate rax_facts creds, region and address + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts == {} + - not rax_facts|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region and id + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: '1234' + ignore_errors: true + register: rax_facts + +- name: Validate rax_facts creds, region and id + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts == {} + - not rax_facts|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region and name + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: 'bad' + ignore_errors: true + register: rax_facts + +- name: Validate rax_facts creds, region and name + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts == {} + - not rax_facts|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region, address, id and name + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: '1.2.3.4' + id: '1234' + name: 'bad' + ignore_errors: true + register: rax_facts + +- name: Validate rax_facts creds, region, address, id and name + assert: + that: + - rax_facts|failed + - "rax_facts.msg == 'parameters are mutually exclusive: [\\'address\\', \\'id\\', \\'name\\']'" +# ============================================================ + + + +# ============================================================ +- name: Build CloudServer for rax_facts tests + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" + name: "{{ resource_prefix }}-rax_facts" + wait: true + register: rax + +- name: Validate build + assert: + that: + - rax|success + - rax|changed + - rax.action == 'create' + - rax.instances|length == 1 + - rax.instances[0].name == "{{ resource_prefix }}-rax_facts" +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region, and valid public IPv4 address + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: "{{ rax.success.0.rax_accessipv4 }}" + register: rax_facts + + +- name: Validate rax_facts creds, region, and valid public IPv4 address + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts.rax_flavor == rax.success.0.rax_flavor + - rax_facts.ansible_facts.rax_image == rax.success.0.rax_image + - rax_facts.ansible_facts.rax_addresses == rax.success.0.rax_addresses + - rax_facts.ansible_facts.rax_id == rax.success.0.rax_id + - rax_facts.ansible_facts.rax_name == rax.success.0.rax_name + - rax_facts.ansible_facts.rax_hostid == rax.success.0.rax_hostid +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region, and valid public IPv6 address + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: "{{ rax.success.0.rax_accessipv6 }}" + register: rax_facts + + +- name: Validate rax_facts creds, region, and valid public IPv6 address + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts.rax_flavor == rax.success.0.rax_flavor + - rax_facts.ansible_facts.rax_image == rax.success.0.rax_image + - rax_facts.ansible_facts.rax_addresses == rax.success.0.rax_addresses + - rax_facts.ansible_facts.rax_id == rax.success.0.rax_id + - rax_facts.ansible_facts.rax_name == rax.success.0.rax_name + - rax_facts.ansible_facts.rax_hostid == rax.success.0.rax_hostid +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region, and valid private IPv4 address + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: "{{ rax.success.0.rax_networks.private|first }}" + register: rax_facts + + +- name: Validate rax_facts creds, region, and valid private IPv4 address + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts.rax_flavor == rax.success.0.rax_flavor + - rax_facts.ansible_facts.rax_image == rax.success.0.rax_image + - rax_facts.ansible_facts.rax_addresses == rax.success.0.rax_addresses + - rax_facts.ansible_facts.rax_id == rax.success.0.rax_id + - rax_facts.ansible_facts.rax_name == rax.success.0.rax_name + - rax_facts.ansible_facts.rax_hostid == rax.success.0.rax_hostid +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region, and valid ID + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: "{{ rax.success.0.rax_id }}" + register: rax_facts + + +- name: Validate rax_facts creds, region, and valid ID + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts.rax_flavor == rax.success.0.rax_flavor + - rax_facts.ansible_facts.rax_image == rax.success.0.rax_image + - rax_facts.ansible_facts.rax_addresses == rax.success.0.rax_addresses + - rax_facts.ansible_facts.rax_id == rax.success.0.rax_id + - rax_facts.ansible_facts.rax_name == rax.success.0.rax_name + - rax_facts.ansible_facts.rax_hostid == rax.success.0.rax_hostid +# ============================================================ + + + +# ============================================================ +- name: Test rax_facts with creds, region, and valid name + rax_facts: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ rax.success.0.rax_name }}" + register: rax_facts + + +- name: Validate rax_facts creds, region, and valid name + assert: + that: + - rax_facts|success + - rax_facts.ansible_facts.rax_flavor == rax.success.0.rax_flavor + - rax_facts.ansible_facts.rax_image == rax.success.0.rax_image + - rax_facts.ansible_facts.rax_addresses == rax.success.0.rax_addresses + - rax_facts.ansible_facts.rax_id == rax.success.0.rax_id + - rax_facts.ansible_facts.rax_name == rax.success.0.rax_name + - rax_facts.ansible_facts.rax_hostid == rax.success.0.rax_hostid +# ============================================================ + + + +# ============================================================ +- name: "Delete CloudServer" + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" + name: "{{ resource_prefix }}-rax_facts" + state: absent + wait: true + register: rax + +- name: "Validate delete" + assert: + that: + - rax|changed + - rax|success + - rax.action == 'delete' + - rax.success[0].name == "{{ resource_prefix }}-rax_facts" +# ============================================================ From 9878ebf0eedcb8665f80c264047bdad587abc0e1 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 16 Jan 2015 14:09:18 -0600 Subject: [PATCH 07/17] Add tests for rax instance_ids with state=absent --- .../integration/roles/test_rax/tasks/main.yml | 61 ++++++++++++++++--- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/test/integration/roles/test_rax/tasks/main.yml b/test/integration/roles/test_rax/tasks/main.yml index 4fe820a3c23..e91c0a949fe 100644 --- a/test/integration/roles/test_rax/tasks/main.yml +++ b/test/integration/roles/test_rax/tasks/main.yml @@ -748,11 +748,11 @@ region: "{{ rackspace_region }}" image: "{{ rackspace_image_id }}" flavor: "{{ rackspace_flavor }}" - name: "{{ resource_prefix }}-10-%03d" + name: "{{ resource_prefix }}-11-%03d" count: 2 count_offset: 10 exact_count: true - group: "{{ resource_prefix }}-10" + group: "{{ resource_prefix }}-11" wait: true register: rax @@ -764,24 +764,24 @@ - rax.action == 'create' - rax.instances|length == 2 - rax.instances == rax.success - - rax.instances|map(attribute='rax_name')|unique|list|sort == ['{{ resource_prefix }}-10-010', '{{ resource_prefix }}-10-011'] + - rax.instances|map(attribute='rax_name')|unique|list|sort == ['{{ resource_prefix }}-11-010', '{{ resource_prefix }}-11-011'] -- name: "Test delete integration 10" +- name: "Test delete integration 11" rax: username: "{{ rackspace_username }}" api_key: "{{ rackspace_api_key }}" region: "{{ rackspace_region }}" image: "{{ rackspace_image_id }}" flavor: "{{ rackspace_flavor }}" - name: "{{ resource_prefix }}-10-%03d" + name: "{{ resource_prefix }}-11-%03d" count: 0 count_offset: 10 exact_count: true - group: "{{ resource_prefix }}-10" + group: "{{ resource_prefix }}-11" wait: true register: rax -- name: "Validate delete integration 10" +- name: "Validate delete integration 11" assert: that: - rax|success @@ -790,3 +790,50 @@ - rax.success|length == 2 - not rax.instances # ============================================================ + + + +# ============================================================ +- name: Test rax instance_ids absent 1 (create) + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" + name: "{{ resource_prefix }}-12" + wait: true + register: rax + +- name: Validate rax instance_ids absent 1 (create) + assert: + that: + - rax|success + - rax|changed + - rax.action == 'create' + - rax.instances|length == 1 + - rax.instances[0].name == "{{ resource_prefix }}-12" + - rax.instances[0] == rax.success[0] + - rax.instances[0].rax_status == 'ACTIVE' + +- name: Test rax instance_ids absent 2 (delete) + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" + instance_ids: + - "{{ rax.success.0.rax_id }}" + state: absent + wait: true + register: rax2 + +- name: Validate rax instance_ids absent 2 (delete) + assert: + that: + - rax2|success + - rax2|changed + - rax2.action == 'delete' + - rax2.success.0.rax_id == rax.success.0.rax_id +# ============================================================ From abac45dafc6cfaa00baec7846c3b8c7fe6cdc57f Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 16 Jan 2015 14:11:50 -0600 Subject: [PATCH 08/17] Add test_rax_meta role --- test/integration/Makefile | 5 +- test/integration/rackspace.yml | 3 + .../roles/test_rax_meta/meta/main.yml | 3 + .../roles/test_rax_meta/tasks/main.yml | 334 ++++++++++++++++++ 4 files changed, 341 insertions(+), 4 deletions(-) create mode 100644 test/integration/roles/test_rax_meta/meta/main.yml create mode 100644 test/integration/roles/test_rax_meta/tasks/main.yml diff --git a/test/integration/Makefile b/test/integration/Makefile index 1322871593d..c708e08e402 100644 --- a/test/integration/Makefile +++ b/test/integration/Makefile @@ -115,10 +115,7 @@ gce: $(CREDENTIALS_FILE) CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make gce_cleanup ; \ exit $$RC; -rackspace_prepare: - ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) -t prepare - -rackspace: rackspace_prepare $(CREDENTIALS_FILE) +rackspace: $(CREDENTIALS_FILE) ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \ RC=$$? ; \ CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make rackspace_cleanup ; \ diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index bf4696d3e73..5d3670cdaf5 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -16,6 +16,9 @@ - role: test_rax_facts tags: test_rax_facts + - role: test_rax_meta + tags: test_rax_meta + - role: test_rax_clb tags: test_rax_clb diff --git a/test/integration/roles/test_rax_meta/meta/main.yml b/test/integration/roles/test_rax_meta/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_meta/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_meta/tasks/main.yml b/test/integration/roles/test_rax_meta/tasks/main.yml new file mode 100644 index 00000000000..b31336fc54a --- /dev/null +++ b/test/integration/roles/test_rax_meta/tasks/main.yml @@ -0,0 +1,334 @@ +# ============================================================ +- name: Test rax_meta with no args + rax_meta: + ignore_errors: true + register: rax_meta + +- name: Validate results of rax_meta with no args + assert: + that: + - rax_meta|failed + - rax_meta.msg == 'one of the following is required: address,id,name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with credentials and address + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + address: '1.2.3.4' + ignore_errors: true + register: rax_meta + +- name: Validate results of rax_meta with only creds + assert: + that: + - rax_meta|failed + - rax_meta.msg.startswith('None is not a valid region') +# ============================================================ + + +# ============================================================ +- name: Test rax_meta with creds, region and address + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: '1.2.3.4' + ignore_errors: true + register: rax_meta + +- name: Validate rax_meta creds, region and address + assert: + that: + - rax_meta|failed + - rax_meta.msg == 'Failed to find a server matching provided search parameters' +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region and id + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: '1234' + ignore_errors: true + register: rax_meta + +- name: Validate rax_meta creds, region and id + assert: + that: + - rax_meta|failed + - rax_meta.msg == 'Failed to find a server matching provided search parameters' +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region and name + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: 'bad' + ignore_errors: true + register: rax_meta + +- name: Validate rax_meta creds, region and name + assert: + that: + - rax_meta|failed + - rax_meta.msg == 'Failed to find a server matching provided search parameters' +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, address, id and name + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: '1.2.3.4' + id: '1234' + name: 'bad' + ignore_errors: true + register: rax_meta + +- name: Validate rax_meta creds, region, address, id and name + assert: + that: + - rax_meta|failed + - "rax_meta.msg == 'parameters are mutually exclusive: [\\'address\\', \\'id\\', \\'name\\']'" +# ============================================================ + + +# ============================================================ +- name: Build CloudServer for rax_meta tests + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" + name: "{{ resource_prefix }}-rax_meta" + meta: + foo: bar + wait: true + register: rax + +- name: Validate build + assert: + that: + - rax|success + - rax|changed + - rax.action == 'create' + - rax.instances|length == 1 + - rax.instances[0].name == "{{ resource_prefix }}-rax_meta" +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid public IPv4 address + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: "{{ rax.success.0.rax_accessipv4 }}" + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid public IPv4 address + assert: + that: + - rax_meta|success + - rax_meta.meta == {} +# ============================================================ + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid public IPv6 address + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: "{{ rax.success.0.rax_accessipv6 }}" + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid public IPv6 address + assert: + that: + - rax_meta|success + - rax_meta.meta == {} +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid private IPv4 address + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + address: "{{ rax.success.0.rax_networks.private|first }}" + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid private IPv4 address + assert: + that: + - rax_meta|success + - rax_meta.meta == {} +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid ID + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: "{{ rax.success.0.rax_id }}" + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid ID + assert: + that: + - rax_meta|success + - rax_meta.meta == {} +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid name + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ rax.success.0.rax_name }}" + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid name + assert: + that: + - rax_meta|success + - rax_meta.meta == {} +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid ID set foo=bar + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: "{{ rax.success.0.rax_id }}" + meta: + foo: bar + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid ID set foo=bar + assert: + that: + - rax_meta|success + - rax_meta|changed + - "rax_meta.meta == {'foo': 'bar'}" +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid ID set bar=baz + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: "{{ rax.success.0.rax_id }}" + meta: + bar: baz + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid ID set bar=baz + assert: + that: + - rax_meta|success + - "rax_meta.meta == {'bar': 'baz'}" +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid ID set bar=baz (idempotent) + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: "{{ rax.success.0.rax_id }}" + meta: + bar: baz + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid ID set bar=baz + assert: + that: + - rax_meta|success + - not rax_meta|changed + - "rax_meta.meta == {'bar': 'baz'}" +# ============================================================ + + + +# ============================================================ +- name: Test rax_meta with creds, region, and valid ID delete meta + rax_meta: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + id: "{{ rax.success.0.rax_id }}" + register: rax_meta + + +- name: Validate rax_meta creds, region, and valid ID delete meta + assert: + that: + - rax_meta|success + - rax_meta|changed + - rax_meta.meta == {} +# ============================================================ + + + +# ============================================================ +- name: "Delete CloudServer" + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + instance_ids: + - "{{ rax.success.0.rax_id }}" + state: absent + wait: true + register: rax + +- name: "Validate delete" + assert: + that: + - rax|changed + - rax|success + - rax.action == 'delete' + - rax.success[0].name == "{{ resource_prefix }}-rax_meta" +# ============================================================ From e54c45ee6d15ab522c653a60284483b9efb7b61b Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 16 Jan 2015 14:54:28 -0600 Subject: [PATCH 09/17] Add test_rax_keypair role --- test/integration/cleanup_rax.py | 14 +- test/integration/rackspace.yml | 3 + .../roles/prepare_rax_tests/defaults/main.yml | 3 + .../roles/test_rax_keypair/meta/main.yml | 3 + .../roles/test_rax_keypair/tasks/main.yml | 245 ++++++++++++++++++ 5 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 test/integration/roles/test_rax_keypair/meta/main.yml create mode 100644 test/integration/roles/test_rax_keypair/tasks/main.yml diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index 87084d06e92..4d1c55b1e03 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -90,6 +90,18 @@ def delete_rax_clb(args): args.assumeyes) +def delete_rax_keypair(args): + """Function for deleting Rackspace Key pairs""" + print ("--- Cleaning Key Pairs matching '%s'" % args.match_re) + for region in pyrax.identity.services.compute.regions: + cs = pyrax.connect_to_cloudservers(region=region) + for keypair in cs.keypairs.list(): + if re.search(args.match_re, keypair.name): + prompt_and_delete(keypair, + 'Delete matching %s? [y/n]: ' % keypair, + args.assumeyes) + + def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') @@ -98,7 +110,7 @@ def main(): authenticate() delete_rax(args) delete_rax_clb(args) - + delete_rax_keypair(args) if __name__ == '__main__': main() diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index 5d3670cdaf5..c37b3892f49 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -19,6 +19,9 @@ - role: test_rax_meta tags: test_rax_meta + - role: test_rax_keypair + tags: test_rax_keypair + - role: test_rax_clb tags: test_rax_clb diff --git a/test/integration/roles/prepare_rax_tests/defaults/main.yml b/test/integration/roles/prepare_rax_tests/defaults/main.yml index ccead866c7e..ffa72294b8c 100644 --- a/test/integration/roles/prepare_rax_tests/defaults/main.yml +++ b/test/integration/roles/prepare_rax_tests/defaults/main.yml @@ -4,4 +4,7 @@ rackspace_image_human_id: "ubuntu-1404-lts-trusty-tahr-pvhvm" rackspace_image_id: "753a7703-4960-488b-aab4-a3cdd4b276dc" rackspace_image_name: "Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)" rackspace_flavor: "performance1-1" + +rackspace_keypair_pub: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDymofzvt86DUA6XSSxc7eDHwUNvcOSmUWjB76jFvhYc6PbS5QmTzBtCka1ORdaW0Z2i3EjfFvzA8WvuY3qP/FpIVDL25ZqZHgxSfGN5pbJ2tAeXK165kNPXBuuISrMhmdLFbRZNn6PwKHEmtrtfEQ3w6ay9+MhqlEr0OX2r6bCXLj+f50QnQXamU6Fm4IpkTsb60osvHNi569Dd8cADEv92oLZpNMa8/MPGnlipjauhzNtEDTUeZwtrAQUXe6CzJ0QmIlyKDglDZLuAKU/VRumo1FRsn4AwJnVsbP2CHBPkbNoYt6LhQiQqXypEIWGmIln0dlO6gZTr3dYC4BVGREl" + resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax_keypair/meta/main.yml b/test/integration/roles/test_rax_keypair/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_keypair/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_keypair/tasks/main.yml b/test/integration/roles/test_rax_keypair/tasks/main.yml new file mode 100644 index 00000000000..f7f10a46783 --- /dev/null +++ b/test/integration/roles/test_rax_keypair/tasks/main.yml @@ -0,0 +1,245 @@ +# ============================================================ +- name: Test rax_keypair with no args + rax_keypair: + ignore_errors: true + register: rax_keypair + +- name: Validate results of rax_keypair with no args + assert: + that: + - rax_keypair|failed + - rax_keypair.msg == 'missing required arguments: name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_keypair with name + rax_keypair: + name: fail + ignore_errors: true + register: rax_keypair + +- name: Validate results of rax_keypair with no args + assert: + that: + - rax_keypair|failed + - rax_keypair.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_keypair with name and credentials + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + name: fail + ignore_errors: true + register: rax_keypair + +- name: Validate results of rax_keypair with name and credentials + assert: + that: + - rax_keypair|failed + - rax_keypair.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Create public key file for tests + copy: + content: "{{ rackspace_keypair_pub }}" + dest: "{{ output_dir|expanduser }}/{{ resource_prefix }}.pub" + +- name: Set variable for public key path + set_fact: + rackspace_keypair_pub_path: "{{ output_dir|expanduser }}/{{ resource_prefix }}.pub" +# ============================================================ + + + +# ============================================================ +- name: Test rax_keypair with creds, region, name and public_key string + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + public_key: "{{ rackspace_keypair_pub }}" + register: rax_keypair + +- name: Validate rax_keypair creds, region, name and public_key string + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-1" + - rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}" + +- name: Delete integration 1 + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + public_key: "{{ rackspace_keypair_pub }}" + state: absent + register: rax_keypair + +- name: Validate delete integration 1 + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-1" +# ============================================================ + + + +# ============================================================ +- name: Test rax_keypair with creds, region, name and public_key path + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + public_key: "{{ rackspace_keypair_pub_path }}" + register: rax_keypair + +- name: Validate rax_keypair creds, region, name and public_key path + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-2" + - rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}" + +- name: Delete integration 2 + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + public_key: "{{ rackspace_keypair_pub }}" + state: absent + register: rax_keypair + +- name: Validate delete integration 2 + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-2" +# ============================================================ + + + +# ============================================================ +- name: Test rax_keypair with idempotency 1 + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + public_key: "{{ rackspace_keypair_pub }}" + register: rax_keypair + +- name: Validate rax_keypair with idempotency 1 + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-3" + - rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}" + +- name: Test rax_keypair with idempotency 2 + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + public_key: "{{ rackspace_keypair_pub }}" + register: rax_keypair + +- name: Validate rax_keypair with idempotency 1 + assert: + that: + - rax_keypair|success + - not rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-3" + - rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}" + +- name: Delete integration 3 + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + public_key: "{{ rackspace_keypair_pub }}" + state: absent + register: rax_keypair + +- name: Validate delete integration 3 + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-3" +# ============================================================ + + + +# ============================================================ +- name: Test rax_keypair with creds, region and name + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + register: rax_keypair + +- name: Validate rax_keypair creds, region and name + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-4" + - rax_keypair.keypair.private_key is defined + - rax_keypair.keypair.public_key is defined + +- name: Test rax_keypair with creds, region and name idempotency + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + register: rax_keypair + +- name: Validate rax_keypair creds, region and name + assert: + that: + - rax_keypair|success + - not rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-4" + - rax_keypair.keypair.private_key is not defined + - rax_keypair.keypair.public_key is defined + +- name: Delete integration 4 + rax_keypair: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + public_key: "{{ rackspace_keypair_pub }}" + state: absent + register: rax_keypair + +- name: Validate delete integration 4 + assert: + that: + - rax_keypair|success + - rax_keypair|changed + - rax_keypair.keypair.name == "{{ resource_prefix }}-4" +# ============================================================ From f01ae9f50951708cae41a153edf917ac3612fe9c Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 16 Jan 2015 15:25:32 -0600 Subject: [PATCH 10/17] Add test_rax_network role --- test/integration/cleanup_rax.py | 19 ++- test/integration/rackspace.yml | 3 + .../roles/test_rax_network/meta/main.yml | 3 + .../roles/test_rax_network/tasks/main.yml | 158 ++++++++++++++++++ 4 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 test/integration/roles/test_rax_network/meta/main.yml create mode 100644 test/integration/roles/test_rax_network/tasks/main.yml diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index 4d1c55b1e03..932f23e61aa 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -102,6 +102,18 @@ def delete_rax_keypair(args): args.assumeyes) +def delete_rax_network(args): + """Function for deleting Cloud Networks""" + print ("--- Cleaning Cloud Networks matching '%s'" % args.match_re) + for region in pyrax.identity.services.network.regions: + cnw = pyrax.connect_to_cloud_networks(region=region) + for network in cnw.list(): + if re.search(args.match_re, network.name): + prompt_and_delete(network, + 'Delete matching %s? [y/n]: ' % network, + args.assumeyes) + + def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') @@ -111,6 +123,11 @@ def main(): delete_rax(args) delete_rax_clb(args) delete_rax_keypair(args) + delete_rax_network(args) + if __name__ == '__main__': - main() + try: + main() + except KeyboardInterrupt: + print ('\nExiting...') diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index c37b3892f49..ba2f9f0714e 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -27,3 +27,6 @@ - role: test_rax_clb_nodes tags: test_rax_clb_nodes + + - role: test_rax_network + tags: test_rax_network diff --git a/test/integration/roles/test_rax_network/meta/main.yml b/test/integration/roles/test_rax_network/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_network/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_network/tasks/main.yml b/test/integration/roles/test_rax_network/tasks/main.yml new file mode 100644 index 00000000000..27eda8b273e --- /dev/null +++ b/test/integration/roles/test_rax_network/tasks/main.yml @@ -0,0 +1,158 @@ +# ============================================================ +- name: Test rax_network with no args + rax_network: + ignore_errors: true + register: rax_network + +- name: Validate results of rax_network with no args + assert: + that: + - rax_network|failed + - rax_network.msg == 'missing required arguments: label' +# ============================================================ + + + +# ============================================================ +- name: Test rax_network with label + rax_network: + label: fail + ignore_errors: true + register: rax_network + +- name: Validate results of rax_network with no args + assert: + that: + - rax_network|failed + - rax_network.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_network with creds + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + label: fail + ignore_errors: true + register: rax_network + +- name: Validate results of rax_network with creds + assert: + that: + - rax_network|failed + - rax_network.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_network with creds and region + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + label: fail + ignore_errors: true + register: rax_network + +- name: Validate results of rax_network with creds and region + assert: + that: + - rax_network|failed + - rax_network.msg == 'missing required arguments: cidr' +# ============================================================ + + + +# ============================================================ +- name: Test rax_network with creds, region and cidr + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + cidr: "172.17.141.0/24" + label: "{{ resource_prefix }}-1" + register: rax_network + +- name: Validate results of rax_network with creds, region and cidr + assert: + that: + - rax_network|success + - rax_network|changed + - rax_network.networks.0.cidr == "172.17.141.0/24" + - rax_network.networks.0.label == "{{ resource_prefix }}-1" + +- name: Delete Integration 1 + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + label: "{{ resource_prefix }}-1" + state: absent + register: rax_network + +- name: Validate delete integration 1 + assert: + that: + - rax_network|changed + - rax_network|success + - rax_network.networks.0.label == "{{ resource_prefix }}-1" + - rax_network.networks.0.cidr == "172.17.141.0/24" +# ============================================================ + + + +# ============================================================ +- name: Test rax_network idempotency 1 + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + cidr: "172.17.142.0/24" + label: "{{ resource_prefix }}-2" + register: rax_network + +- name: Validate rax_network idempotency 1 + assert: + that: + - rax_network|success + - rax_network|changed + - rax_network.networks.0.cidr == "172.17.142.0/24" + - rax_network.networks.0.label == "{{ resource_prefix }}-2" + +- name: Test rax_network idempotency 2 + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + cidr: "172.17.142.0/24" + label: "{{ resource_prefix }}-2" + register: rax_network + +- name: Validate rax_network idempotency 2 + assert: + that: + - rax_network|success + - not rax_network|changed + - rax_network.networks.0.cidr == "172.17.142.0/24" + - rax_network.networks.0.label == "{{ resource_prefix }}-2" + +- name: Delete Integration 2 + rax_network: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + label: "{{ resource_prefix }}-2" + state: absent + register: rax_network + +- name: Validate delete integration 2 + assert: + that: + - rax_network|changed + - rax_network|success + - rax_network.networks.0.label == "{{ resource_prefix }}-2" + - rax_network.networks.0.cidr == "172.17.142.0/24" +# ============================================================ From 3ae1014fd34753a0d7fc50e24271ca8003d4d63f Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 19 Jan 2015 11:04:53 -0600 Subject: [PATCH 11/17] Add tests for rax_cbs --- test/integration/cleanup_rax.py | 13 + test/integration/rackspace.yml | 8 +- .../roles/test_rax_cbs/meta/main.yml | 3 + .../roles/test_rax_cbs/tasks/main.yml | 346 ++++++++++++++++++ 4 files changed, 365 insertions(+), 5 deletions(-) create mode 100644 test/integration/roles/test_rax_cbs/meta/main.yml create mode 100644 test/integration/roles/test_rax_cbs/tasks/main.yml diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index 932f23e61aa..10e94334f89 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -114,6 +114,18 @@ def delete_rax_network(args): args.assumeyes) +def delete_rax_cbs(args): + """Function for deleting Cloud Networks""" + print ("--- Cleaning Cloud Block Storage matching '%s'" % args.match_re) + for region in pyrax.identity.services.network.regions: + cbs = pyrax.connect_to_cloud_blockstorage(region=region) + for volume in cbs.list(): + if re.search(args.match_re, volume.name): + prompt_and_delete(volume, + 'Delete matching %s? [y/n]: ' % volume, + args.assumeyes) + + def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') @@ -124,6 +136,7 @@ def main(): delete_rax_clb(args) delete_rax_keypair(args) delete_rax_network(args) + delete_rax_cbs(args) if __name__ == '__main__': diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index ba2f9f0714e..51f7620a7c0 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -5,11 +5,6 @@ tags: - rackspace roles: - - role: prepare_rax_tests - tags: - - prepare - - prepare_rax_tests - - role: test_rax tags: test_rax @@ -30,3 +25,6 @@ - role: test_rax_network tags: test_rax_network + + - role: test_rax_cbs + tags: test_rax_cbs diff --git a/test/integration/roles/test_rax_cbs/meta/main.yml b/test/integration/roles/test_rax_cbs/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_cbs/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_cbs/tasks/main.yml b/test/integration/roles/test_rax_cbs/tasks/main.yml new file mode 100644 index 00000000000..90395e4fe20 --- /dev/null +++ b/test/integration/roles/test_rax_cbs/tasks/main.yml @@ -0,0 +1,346 @@ +# ============================================================ +- name: Test rax_cbs with no args + rax_cbs: + ignore_errors: true + register: rax_cbs + +- name: Validate results of rax_cbs with no args + assert: + that: + - rax_cbs|failed + - rax_cbs.msg == 'missing required arguments: name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with name + rax_cbs: + name: fail + ignore_errors: true + register: rax_cbs + +- name: Validate results of rax_cbs with no args + assert: + that: + - rax_cbs|failed + - rax_cbs.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with name and credentials + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + name: fail + ignore_errors: true + register: rax_cbs + +- name: Validate results of rax_cbs with name and credentials + assert: + that: + - rax_cbs|failed + - rax_cbs.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and public_key string + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + wait: true + register: rax_cbs + +- name: Validate rax_cbs creds, region and name + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-1" + - rax_cbs.volume.attachments == [] + - rax_cbs.volume.size == 100 + - rax_cbs.volume.volume_type == 'SATA' + - rax_cbs.volume.status == 'available' + +- name: Delete integration 1 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + state: absent + register: rax_cbs + +- name: Validate delete integration 1 + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-1" +# ============================================================ + + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and invalid size + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: fail + size: 1 + ignore_errors: true + register: rax_cbs + +- name: Validate rax_cbs creds, region, name and invalid size + assert: + that: + - rax_cbs|failed + - rax_cbs.msg == '"size" must be greater than or equal to 100' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and valid size + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + size: 150 + wait: true + register: rax_cbs + +- name: Validate rax_cbs creds, region and valid size + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-2" + - rax_cbs.volume.attachments == [] + - rax_cbs.volume.size == 150 + - rax_cbs.volume.volume_type == 'SATA' + - rax_cbs.volume.status == 'available' + +- name: Delete integration 2 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + state: absent + register: rax_cbs + +- name: Validate delete integration 2 + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-2" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and invalid volume_type + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: fail + volume_type: fail + ignore_errors: true + register: rax_cbs + +- name: Validate rax_cbs creds, region, name and invalid volume_type + assert: + that: + - rax_cbs|failed + - "rax_cbs.msg == 'value of volume_type must be one of: SSD,SATA, got: fail'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and valid volume_size + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + volume_type: SSD + wait: true + register: rax_cbs + +- name: Validate rax_cbs creds, region and valid volume_size + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-3" + - rax_cbs.volume.attachments == [] + - rax_cbs.volume.size == 100 + - rax_cbs.volume.volume_type == 'SSD' + - rax_cbs.volume.status == 'available' + +- name: Delete integration 3 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + state: absent + register: rax_cbs + +- name: Validate delete integration 3 + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-3" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and description + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + description: "{{ resource_prefix }}-4 description" + wait: true + register: rax_cbs + +- name: Validate rax_cbs creds, region and description + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-4" + - rax_cbs.volume.description == '{{ resource_prefix }}-4 description' + - rax_cbs.volume.attachments == [] + - rax_cbs.volume.size == 100 + - rax_cbs.volume.volume_type == 'SATA' + - rax_cbs.volume.status == 'available' + +- name: Delete integration 4 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + state: absent + register: rax_cbs + +- name: Validate delete integration 4 + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-4" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with creds, region, name and meta + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-5" + meta: + foo: bar + wait: true + register: rax_cbs + +- name: Validate rax_cbs creds, region and meta + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-5" + - rax_cbs.volume.attachments == [] + - rax_cbs.volume.size == 100 + - rax_cbs.volume.volume_type == 'SATA' + - rax_cbs.volume.status == 'available' + - rax_cbs.volume.metadata.foo == 'bar' + +- name: Delete integration 5 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-5" + state: absent + register: rax_cbs + +- name: Validate delete integration 5 + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-5" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs with idempotency 1 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + wait: true + register: rax_cbs_1 + +- name: Validate rax_cbs with idempotency 1 + assert: + that: + - rax_cbs_1|success + - rax_cbs_1|changed + - rax_cbs_1.volume.display_name == "{{ resource_prefix }}-6" + +- name: Test rax_cbs with idempotency 2 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + register: rax_cbs_2 + +- name: Validate rax_cbs with idempotency 2 + assert: + that: + - rax_cbs_2|success + - not rax_cbs_2|changed + - rax_cbs_2.volume.display_name == "{{ resource_prefix }}-6" + - rax_cbs_2.volume.id == rax_cbs_1.volume.id + +- name: Delete integration 6 + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + state: absent + register: rax_cbs + +- name: Validate delete integration 6 + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.name == "{{ resource_prefix }}-6" +# ============================================================ From 5e00e72f7ada8fe70f5f3818411e5b152308b69a Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 19 Jan 2015 11:06:37 -0600 Subject: [PATCH 12/17] Remove unecessary prep tasks --- .../roles/prepare_rax_tests/tasks/main.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 test/integration/roles/prepare_rax_tests/tasks/main.yml diff --git a/test/integration/roles/prepare_rax_tests/tasks/main.yml b/test/integration/roles/prepare_rax_tests/tasks/main.yml deleted file mode 100644 index 60cc52830f6..00000000000 --- a/test/integration/roles/prepare_rax_tests/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- 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 - - rackspace_image_human_id is defined and rackspace_image_human_id - - rackspace_image_id is defined and rackspace_image_id - - rackspace_image_name is defined and rackspace_image_name From 74f4d186cc7816bde8b803d9c524be473ea00890 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 19 Jan 2015 12:45:52 -0600 Subject: [PATCH 13/17] Add tests for rax_cbs_attachments --- test/integration/rackspace.yml | 3 + .../test_rax_cbs_attachments/meta/main.yml | 3 + .../test_rax_cbs_attachments/tasks/main.yml | 253 ++++++++++++++++++ 3 files changed, 259 insertions(+) create mode 100644 test/integration/roles/test_rax_cbs_attachments/meta/main.yml create mode 100644 test/integration/roles/test_rax_cbs_attachments/tasks/main.yml diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index 51f7620a7c0..e00f14171d5 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -28,3 +28,6 @@ - role: test_rax_cbs tags: test_rax_cbs + + - role: test_rax_cbs_attachments + tags: test_rax_cbs_attachments diff --git a/test/integration/roles/test_rax_cbs_attachments/meta/main.yml b/test/integration/roles/test_rax_cbs_attachments/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_cbs_attachments/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_cbs_attachments/tasks/main.yml b/test/integration/roles/test_rax_cbs_attachments/tasks/main.yml new file mode 100644 index 00000000000..6750105c1e6 --- /dev/null +++ b/test/integration/roles/test_rax_cbs_attachments/tasks/main.yml @@ -0,0 +1,253 @@ +# ============================================================ +- name: Test rax_cbs_attachments with no args + rax_cbs_attachments: + ignore_errors: true + register: rax_cbs_attachments + +- name: Validate results of rax_cbs_attachments with no args + assert: + that: + - rax_cbs_attachments|failed + - rax_cbs_attachments.msg == 'missing required arguments: server,volume,device' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs_attachments with server, volume and device + rax_cbs_attachments: + server: '1234' + volume: '1234' + device: /dev/xvde + ignore_errors: true + register: rax_cbs_attachments + +- name: Validate results of rax_cbs_attachments with server, volume and device + assert: + that: + - rax_cbs_attachments|failed + - rax_cbs_attachments.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs_attachments with credentials, server, volume and device + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + server: '1234' + volume: '1234' + device: /dev/xvde + ignore_errors: true + register: rax_cbs_attachments + +- name: Validate results of rax_cbs_attachments with credentials, server, volume and device + assert: + that: + - rax_cbs_attachments|failed + - rax_cbs_attachments.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs_attachments with creds, region, invalid server, invalid volume and device + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + server: '1234' + volume: '1234' + device: /dev/xvde + ignore_errors: true + register: rax_cbs_attachments + +- name: Validate rax_cbs_attachments creds, region, invalid server, invalid volume and device + assert: + that: + - rax_cbs_attachments|failed + - rax_cbs_attachments.msg == 'No matching storage volumes were found' +# ============================================================ + + + +# ============================================================ +- name: Build Volume for rax_cbs_attachments test + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-rax_cbs_attachments" + wait: true + register: rax_cbs + +- name: Validate volume build + assert: + that: + - rax_cbs|success + - rax_cbs|changed + - rax_cbs.volume.display_name == "{{ resource_prefix }}-rax_cbs_attachments" +# ============================================================ + + + +# ============================================================ +- name: Build CloudServer for rax_cbs_attachments tests + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + image: "{{ rackspace_image_id }}" + flavor: "{{ rackspace_flavor }}" + name: "{{ resource_prefix }}-rax_cbs_attachments" + wait: true + register: rax + +- name: Validate CloudServer build + assert: + that: + - rax|success + - rax|changed + - rax.action == 'create' + - rax.instances|length == 1 + - rax.instances[0].name == "{{ resource_prefix }}-rax_cbs_attachments" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs_attachments with creds, region, invalid server, volume and device + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + server: '1234' + volume: "{{ rax_cbs.volume.id }}" + device: /dev/xvde + ignore_errors: true + register: rax_cbs_attachments + +- name: Validate rax_cbs_attachments creds, region, invalid server, volume and device + assert: + that: + - rax_cbs_attachments|failed + - rax_cbs_attachments.msg == 'No Server was matched by name, try using the Server ID instead' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cbs_attachments with creds, region, server, volume and device (valid) + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + server: "{{ rax.instances[0].id }}" + volume: "{{ rax_cbs.volume.id }}" + device: /dev/xvde + wait: true + register: rax_cbs_attachments + +- name: Validate rax_cbs_attachments creds, region, server, volume and device (valid) + assert: + that: + - rax_cbs_attachments|success + - rax_cbs_attachments|changed + - rax_cbs_attachments.volume.attachments.0.device == '/dev/xvde' + - rax_cbs_attachments.volume.attachments.0.server_id == "{{ rax.instances[0].id }}" + +- name: Idempotent present test + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + server: "{{ rax.instances[0].id }}" + volume: "{{ rax_cbs.volume.id }}" + device: /dev/xvde + wait: true + register: rax_cbs_attachments + +- name: Validate idempotent present test + assert: + that: + - rax_cbs_attachments|success + - not rax_cbs_attachments|changed + +- name: Unattach volume + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + server: "{{ rax.instances[0].id }}" + volume: "{{ rax_cbs.volume.id }}" + device: /dev/xvde + wait: true + state: absent + register: rax_cbs_attachments + +- name: Validate unattach volume + assert: + that: + - rax_cbs_attachments|success + - rax_cbs_attachments|changed + - rax_cbs_attachments.volume.attachments == [] + +- name: Idempotent absent test + rax_cbs_attachments: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + server: "{{ rax.instances[0].id }}" + volume: "{{ rax_cbs.volume.id }}" + device: /dev/xvde + wait: true + state: absent + register: rax_cbs_attachments + +- name: Validate idempotent absent test + assert: + that: + - rax_cbs_attachments|success + - not rax_cbs_attachments|changed +# ============================================================ + + + +# ============================================================ +- name: Delete test volume + rax_cbs: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ rax_cbs.volume.id }}" + state: absent + register: rax_cbs + +- name: Validate delete integration 6 + assert: + that: + - rax_cbs|success + - rax_cbs|changed +# ============================================================ + + + +# ============================================================ +- name: "Delete CloudServer" + rax: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + instance_ids: "{{ rax.instances[0].id }}" + state: absent + wait: true + register: rax + +- name: "Validate delete" + assert: + that: + - rax|changed + - rax|success + - rax.action == 'delete' +# ============================================================ From 29cd7e3fc132cc83e68ee47b19597c58a301ab0c Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 19 Jan 2015 13:06:35 -0600 Subject: [PATCH 14/17] Add tests for rax_identity --- test/integration/rackspace.yml | 3 ++ .../roles/test_rax_identity/meta/main.yml | 3 ++ .../roles/test_rax_identity/tasks/main.yml | 51 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 test/integration/roles/test_rax_identity/meta/main.yml create mode 100644 test/integration/roles/test_rax_identity/tasks/main.yml diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index e00f14171d5..cdf0da92e09 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -31,3 +31,6 @@ - role: test_rax_cbs_attachments tags: test_rax_cbs_attachments + + - role: test_rax_identity + tags: test_rax_identity diff --git a/test/integration/roles/test_rax_identity/meta/main.yml b/test/integration/roles/test_rax_identity/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_identity/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_identity/tasks/main.yml b/test/integration/roles/test_rax_identity/tasks/main.yml new file mode 100644 index 00000000000..d5b12eb3509 --- /dev/null +++ b/test/integration/roles/test_rax_identity/tasks/main.yml @@ -0,0 +1,51 @@ +# ============================================================ +- name: Test rax_identity with no args + rax_identity: + ignore_errors: true + register: rax_identity + +- name: Validate results of rax_identity with no args + assert: + that: + - rax_identity|failed + - rax_identity.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_identity with name and credentials + rax_identity: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + ignore_errors: true + register: rax_identity + +- name: Validate results of rax_identity with name and credentials + assert: + that: + - rax_identity|failed + - rax_identity.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_identity with name and credentials and region + rax_identity: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + register: rax_identity + +- name: Validate results of rax_identity with name and credentials + assert: + that: + - rax_identity|success + - not rax_identity|changed + - rax_identity.identity.region == "{{ rackspace_region }}" + - rax_identity.identity.username == "{{ rackspace_username }}" + - rax_identity.identity.authenticated + - rax_identity.identity.services + - rax_identity.identity.auth_token +# ============================================================ From 9485d82ecad09070e3675122b37861d3989593de Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 20 Jan 2015 11:41:41 -0600 Subject: [PATCH 15/17] Add tests for rax_cdb --- test/integration/cleanup_rax.py | 24 +- test/integration/rackspace.yml | 3 + .../roles/test_rax_cdb/meta/main.yml | 3 + .../roles/test_rax_cdb/tasks/main.yml | 270 ++++++++++++++++++ 4 files changed, 295 insertions(+), 5 deletions(-) create mode 100644 test/integration/roles/test_rax_cdb/meta/main.yml create mode 100644 test/integration/roles/test_rax_cdb/tasks/main.yml diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index 10e94334f89..f65a96ca682 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -126,17 +126,31 @@ def delete_rax_cbs(args): args.assumeyes) +def delete_rax_cdb(args): + """Function for deleting Cloud Databases""" + print ("--- Cleaning Cloud Databases matching '%s'" % args.match_re) + for region in pyrax.identity.services.database.regions: + cdb = pyrax.connect_to_cloud_databases(region=region) + for db in rax_list_iterator(cdb): + if re.search(args.match_re, db.name): + prompt_and_delete(db, + 'Delete matching %s? [y/n]: ' % db, + args.assumeyes) + + def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') args = parse_args() authenticate() - delete_rax(args) - delete_rax_clb(args) - delete_rax_keypair(args) - delete_rax_network(args) - delete_rax_cbs(args) + + for func in [delete_rax, delete_rax_clb, delete_rax_keypair, + delete_rax_network, delete_rax_cbs, delete_rax_cdb]: + try: + func(args) + except Exception as e: + print ("---- %s failed (%s)" % (func.__name__, e.message)) if __name__ == '__main__': diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index cdf0da92e09..e572f145e4b 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -34,3 +34,6 @@ - role: test_rax_identity tags: test_rax_identity + + - role: test_rax_cdb + tags: test_rax_cdb diff --git a/test/integration/roles/test_rax_cdb/meta/main.yml b/test/integration/roles/test_rax_cdb/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_cdb/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_cdb/tasks/main.yml b/test/integration/roles/test_rax_cdb/tasks/main.yml new file mode 100644 index 00000000000..fe4bdd9c0d9 --- /dev/null +++ b/test/integration/roles/test_rax_cdb/tasks/main.yml @@ -0,0 +1,270 @@ +# ============================================================ +- name: Test rax_cdb with no args + rax_cdb: + ignore_errors: true + register: rax_cdb + +- name: Validate results of rax_cdb with no args + assert: + that: + - rax_cdb|failed + - rax_cdb.msg == 'missing required arguments: name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb with name + rax_cdb: + name: fail + ignore_errors: true + register: rax_cdb + +- name: Validate results of rax_cdb with only creds + assert: + that: + - rax_cdb|failed + - rax_cdb.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb with name and credentials + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + name: fail + ignore_errors: true + register: rax_cdb + +- name: Validate results of rax_cdb with only creds + assert: + that: + - rax_cdb|failed + - rax_cdb.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb with creds and region + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + ignore_errors: true + register: rax_cdb + +- name: Validate rax_cdb creds and region + assert: + that: + - rax_cdb|failed + - rax_cdb.msg == 'missing required arguments: name' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb with creds, region and name + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + wait: true + register: rax_cdb + +- name: Validate rax_cdb with creds, region and name + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == '{{ resource_prefix }}-1' + - rax_cdb.cdb.hostname + - rax_cdb.cdb.status == 'ACTIVE' + +- name: "Delete integration 1" + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + state: absent + wait: true + register: rax_cdb + +- name: "Validate delete integration 1" + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-1" + +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb idempotent test 1 + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + wait: true + register: rax_cdb + +- name: Validate rax_cdb idempotent test 1 + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-2" + - rax_cdb.cdb.status == 'ACTIVE' + +- name: Test rax_cdb idempotent test 2 + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + wait: true + register: rax_cdb + +- name: Validate rax_cdb idempotent test 2 + assert: + that: + - rax_cdb|success + - not rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-2" + - rax_cdb.cdb.status == 'ACTIVE' + +- name: "Delete integration 2" + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + state: absent + wait: true + register: rax_cdb + +- name: "Validate delete integration 2" + assert: + that: + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-2" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb resize volume 1 + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + wait: true + register: rax_cdb + +- name: Validate rax_cdb resize volume 1 + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-3" + - rax_cdb.cdb.status == 'ACTIVE' + +- name: Test rax_cdb resize volume 2 + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + volume: 3 + wait: true + wait_timeout: 600 + register: rax_cdb + +- name: Validate rax_cdb resize volume 2 + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-3" + - rax_cdb.cdb.status == 'ACTIVE' + +- name: "Delete integration 3" + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + state: absent + wait: true + register: rax_cdb + +- name: "Validate delete integration 3" + assert: + that: + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-3" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb resize flavor 1 + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + wait: true + register: rax_cdb + +- name: Validate rax_cdb resize flavor 1 + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-4" + - rax_cdb.cdb.status == 'ACTIVE' + +- name: Test rax_cdb resize flavor 2 + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + flavor: 2 + wait: true + wait_timeout: 600 + register: rax_cdb + +- name: Validate rax_cdb resize flavor 2 + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-4" + - rax_cdb.cdb.status == 'ACTIVE' + +- name: "Delete integration 4" + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + state: absent + wait: true + register: rax_cdb + +- name: "Validate delete integration 4" + assert: + that: + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-4" +# ============================================================ From 952aa0c2d801931cea7fbc868744059eb63c3ced Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 20 Jan 2015 11:49:22 -0600 Subject: [PATCH 16/17] Don't hardcode list of delete functions to loop through --- test/integration/cleanup_rax.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index f65a96ca682..95f8ba2f0ae 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -145,8 +145,8 @@ def main(): args = parse_args() authenticate() - for func in [delete_rax, delete_rax_clb, delete_rax_keypair, - delete_rax_network, delete_rax_cbs, delete_rax_cdb]: + funcs = [f for n, f in globals().items() if n.startswith('delete_rax')] + for func in sorted(funcs, key=lambda f: f.__name__): try: func(args) except Exception as e: From be6e49dd1f6ed1297dc590ad29f51d5baa1f57e9 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 20 Jan 2015 14:05:45 -0600 Subject: [PATCH 17/17] Add tests for rax_cdb_database --- test/integration/rackspace.yml | 3 + .../roles/test_rax_cdb_database/meta/main.yml | 3 + .../test_rax_cdb_database/tasks/main.yml | 215 ++++++++++++++++++ 3 files changed, 221 insertions(+) create mode 100644 test/integration/roles/test_rax_cdb_database/meta/main.yml create mode 100644 test/integration/roles/test_rax_cdb_database/tasks/main.yml diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index e572f145e4b..37f9b097b9c 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -37,3 +37,6 @@ - role: test_rax_cdb tags: test_rax_cdb + + - role: test_rax_cdb_database + tags: test_rax_cdb_database diff --git a/test/integration/roles/test_rax_cdb_database/meta/main.yml b/test/integration/roles/test_rax_cdb_database/meta/main.yml new file mode 100644 index 00000000000..a3f85b642e3 --- /dev/null +++ b/test/integration/roles/test_rax_cdb_database/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - prepare_rax_tests diff --git a/test/integration/roles/test_rax_cdb_database/tasks/main.yml b/test/integration/roles/test_rax_cdb_database/tasks/main.yml new file mode 100644 index 00000000000..a8f5caa335d --- /dev/null +++ b/test/integration/roles/test_rax_cdb_database/tasks/main.yml @@ -0,0 +1,215 @@ +# ============================================================ +- name: Test rax_cdb_database with no args + rax_cdb_database: + ignore_errors: true + register: rax_cdb_database + +- name: Validate results of rax_cdb_database with no args + assert: + that: + - rax_cdb_database|failed + - rax_cdb_database.msg == 'missing required arguments: name,cdb_id' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb_database with name + rax_cdb_database: + name: fail + ignore_errors: true + register: rax_cdb_database + +- name: Validate results of rax_cdb_database with name + assert: + that: + - rax_cdb_database|failed + - rax_cdb_database.msg == 'missing required arguments: cdb_id' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb_database with name and cdb_id + rax_cdb_database: + name: fail + cdb_id: '1234' + ignore_errors: true + register: rax_cdb_database + +- name: Validate results of rax_cdb_database with name and cdb_id + assert: + that: + - rax_cdb_database|failed + - rax_cdb_database.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb_database with name, cdb_id and creds + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + name: fail + cdb_id: '1234' + ignore_errors: true + register: rax_cdb_database + +- name: Validate results of rax_cdb_database with name, cdb_id and creds + assert: + that: + - rax_cdb_database|failed + - rax_cdb_database.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb_database with name, invalid cdb_id, creds and region + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: fail + cdb_id: '1234' + ignore_errors: true + register: rax_cdb_database + +- name: Validate rax_cdb_database name, invalid cdb_id, creds and region + assert: + that: + - rax_cdb_database|failed +# ============================================================ + + + +# ============================================================ +- name: Build Cloud Database for testing + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-rax_cdb_database" + wait: true + register: rax_cdb + +- name: Validate build + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == '{{ resource_prefix }}-rax_cdb_database' + - rax_cdb.cdb.status == 'ACTIVE' +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb_database with name, cdb_id, creds and region + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + cdb_id: "{{ rax_cdb.cdb.id }}" + register: rax_cdb_database + +- name: Validate rax_cdb_database name, cdb_id, creds and region + assert: + that: + - rax_cdb_database|success + - rax_cdb_database|changed + - rax_cdb_database.database.name == "{{ resource_prefix }}-1" + +- name: Delete integration 1 + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + cdb_id: "{{ rax_cdb.cdb.id }}" + state: absent + register: rax_cdb_database + +- name: Validate delete integration 1 + assert: + that: + - rax_cdb_database|success + - rax_cdb_database|changed + - rax_cdb_database.database.name == "{{ resource_prefix }}-1" +# ============================================================ + + + +# ============================================================ +- name: Test rax_cdb_database idempotency 1 + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + cdb_id: "{{ rax_cdb.cdb.id }}" + register: rax_cdb_database + +- name: Validate rax_cdb_database idempotency 1 + assert: + that: + - rax_cdb_database|success + - rax_cdb_database|changed + - rax_cdb_database.database.name == "{{ resource_prefix }}-2" + +- name: Test rax_cdb_database idempotency 2 + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + cdb_id: "{{ rax_cdb.cdb.id }}" + register: rax_cdb_database + +- name: Validate rax_cdb_database idempotency 2 + assert: + that: + - rax_cdb_database|success + - not rax_cdb_database|changed + - rax_cdb_database.database.name == "{{ resource_prefix }}-2" + +- name: Delete integration 2 + rax_cdb_database: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + cdb_id: "{{ rax_cdb.cdb.id }}" + state: absent + register: rax_cdb_database + +- name: Validate delete integration 2 + assert: + that: + - rax_cdb_database|success + - rax_cdb_database|changed + - rax_cdb_database.database.name == "{{ resource_prefix }}-2" +# ============================================================ + + + +# ============================================================ +- name: Delete Cloud Database + rax_cdb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-rax_cdb_database" + state: absent + wait: true + register: rax_cdb + +- name: Validate Delete + assert: + that: + - rax_cdb|success + - rax_cdb|changed + - rax_cdb.cdb.name == "{{ resource_prefix }}-rax_cdb_database" +# ============================================================