From d4aa7db3233646e98fc541913c9f5d1aaf05336c Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Tue, 4 Sep 2018 12:30:09 +0800 Subject: [PATCH] consolidate sql tests into one (#45064) --- .../targets/azure_rm_sqldatabase/aliases | 3 - .../azure_rm_sqldatabase/meta/main.yml | 2 - .../azure_rm_sqldatabase/tasks/main.yml | 94 -------- .../targets/azure_rm_sqlfirewallrule/aliases | 3 - .../azure_rm_sqlfirewallrule/meta/main.yml | 2 - .../azure_rm_sqlfirewallrule/tasks/main.yml | 95 -------- .../targets/azure_rm_sqlserver/aliases | 3 + .../targets/azure_rm_sqlserver/tasks/main.yml | 221 +++++++++++++++++- .../targets/azure_rm_sqlserver_facts/aliases | 3 - .../azure_rm_sqlserver_facts/meta/main.yml | 2 - .../azure_rm_sqlserver_facts/tasks/main.yml | 104 --------- 11 files changed, 217 insertions(+), 315 deletions(-) delete mode 100644 test/integration/targets/azure_rm_sqldatabase/aliases delete mode 100644 test/integration/targets/azure_rm_sqldatabase/meta/main.yml delete mode 100644 test/integration/targets/azure_rm_sqldatabase/tasks/main.yml delete mode 100644 test/integration/targets/azure_rm_sqlfirewallrule/aliases delete mode 100644 test/integration/targets/azure_rm_sqlfirewallrule/meta/main.yml delete mode 100644 test/integration/targets/azure_rm_sqlfirewallrule/tasks/main.yml delete mode 100644 test/integration/targets/azure_rm_sqlserver_facts/aliases delete mode 100644 test/integration/targets/azure_rm_sqlserver_facts/meta/main.yml delete mode 100644 test/integration/targets/azure_rm_sqlserver_facts/tasks/main.yml diff --git a/test/integration/targets/azure_rm_sqldatabase/aliases b/test/integration/targets/azure_rm_sqldatabase/aliases deleted file mode 100644 index e391de0dce5..00000000000 --- a/test/integration/targets/azure_rm_sqldatabase/aliases +++ /dev/null @@ -1,3 +0,0 @@ -cloud/azure -destructive -shippable/azure/group3 diff --git a/test/integration/targets/azure_rm_sqldatabase/meta/main.yml b/test/integration/targets/azure_rm_sqldatabase/meta/main.yml deleted file mode 100644 index 95e1952f989..00000000000 --- a/test/integration/targets/azure_rm_sqldatabase/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - setup_azure diff --git a/test/integration/targets/azure_rm_sqldatabase/tasks/main.yml b/test/integration/targets/azure_rm_sqldatabase/tasks/main.yml deleted file mode 100644 index 401836a1571..00000000000 --- a/test/integration/targets/azure_rm_sqldatabase/tasks/main.yml +++ /dev/null @@ -1,94 +0,0 @@ -- name: Prepare random number - set_fact: - rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" - run_once: yes - -- name: Create SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: sqlsrv{{ rpfx }} - location: eastus - admin_username: mylogin - admin_password: Testpasswordxyz12! - -- name: Create instance of SQL Database -- check mode - azure_rm_sqldatabase: - resource_group: "{{ resource_group }}" - server_name: sqlsrv{{ rpfx }} - name: database{{ rpfx }} - location: eastus - check_mode: yes - register: output -- name: Assert the resource instance is well created - assert: - that: - - output.changed - -- name: Create instance of SQL Database - azure_rm_sqldatabase: - resource_group: "{{ resource_group }}" - server_name: sqlsrv{{ rpfx }} - name: database{{ rpfx }} - location: eastus - register: output -- name: Assert the resource instance is well created - assert: - that: - - output.changed - - output.status == 'Online' - -- name: Create again instance of SQL Database - azure_rm_sqldatabase: - resource_group: "{{ resource_group }}" - server_name: sqlsrv{{ rpfx }} - name: database{{ rpfx }} - location: eastus - register: output -- name: Assert the state has not changed - assert: - that: - - output.changed == false - - output.status == 'Online' - -- name: Delete instance of SQL Database -- check mode - azure_rm_sqldatabase: - resource_group: "{{ resource_group }}" - server_name: sqlsrv{{ rpfx }} - name: database{{ rpfx }} - state: absent - check_mode: yes - register: output -- name: Assert the state has changed - assert: - that: - - output.changed - -- name: Delete instance of SQL Database - azure_rm_sqldatabase: - resource_group: "{{ resource_group }}" - server_name: sqlsrv{{ rpfx }} - name: database{{ rpfx }} - state: absent - register: output -- name: Assert the state has changed - assert: - that: - - output.changed - -- name: Delete unexisting instance of SQL Database - azure_rm_sqldatabase: - resource_group: "{{ resource_group }}" - server_name: sqlsrv{{ rpfx }} - name: database{{ rpfx }} - state: absent - register: output -- name: Assert the state has changed - assert: - that: - - output.changed == false - -- name: Delete instance of SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: sqlsrv{{ rpfx }} - state: absent diff --git a/test/integration/targets/azure_rm_sqlfirewallrule/aliases b/test/integration/targets/azure_rm_sqlfirewallrule/aliases deleted file mode 100644 index 49acfee76c9..00000000000 --- a/test/integration/targets/azure_rm_sqlfirewallrule/aliases +++ /dev/null @@ -1,3 +0,0 @@ -cloud/azure -destructive -shippable/azure/group2 diff --git a/test/integration/targets/azure_rm_sqlfirewallrule/meta/main.yml b/test/integration/targets/azure_rm_sqlfirewallrule/meta/main.yml deleted file mode 100644 index 95e1952f989..00000000000 --- a/test/integration/targets/azure_rm_sqlfirewallrule/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - setup_azure diff --git a/test/integration/targets/azure_rm_sqlfirewallrule/tasks/main.yml b/test/integration/targets/azure_rm_sqlfirewallrule/tasks/main.yml deleted file mode 100644 index 5408f4095eb..00000000000 --- a/test/integration/targets/azure_rm_sqlfirewallrule/tasks/main.yml +++ /dev/null @@ -1,95 +0,0 @@ -- name: Prepare random number - set_fact: - rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" - run_once: yes - -- name: Create SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: "sqlsrv{{ rpfx }}" - location: eastus - admin_username: mylogin - admin_password: Testpasswordxyz12! - -- name: Create instance of Firewall Rule -- check mode - azure_rm_sqlfirewallrule: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - name: firewallrule{{ rpfx }} - start_ip_address: 172.28.10.136 - end_ip_address: 172.28.10.138 - check_mode: yes - register: output -- name: Assert the resource instance is well created - assert: - that: - - output.changed - -- name: Create instance of Firewall Rule - azure_rm_sqlfirewallrule: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - name: firewallrule{{ rpfx }} - start_ip_address: 172.28.10.136 - end_ip_address: 172.28.10.138 - register: output -- name: Assert the resource instance is well created - assert: - that: - - output.changed - -- name: Create again instance of Firewall Rule - azure_rm_sqlfirewallrule: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - name: firewallrule{{ rpfx }} - start_ip_address: 172.28.10.136 - end_ip_address: 172.28.10.138 - register: output -- name: Assert the state has not changed - assert: - that: - - output.changed == false - -- name: Delete instance of Firewall Rule -- check mode - azure_rm_sqlfirewallrule: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - name: firewallrule{{ rpfx }} - state: absent - check_mode: yes - register: output -- name: Assert the state has changed - assert: - that: - - output.changed - -- name: Delete instance of Firewall Rule - azure_rm_sqlfirewallrule: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - name: firewallrule{{ rpfx }} - state: absent - register: output -- name: Assert the state has changed - assert: - that: - - output.changed - -- name: Delete unexisting instance of Firewall Rule - azure_rm_sqlfirewallrule: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - name: firewallrule{{ rpfx }} - state: absent - register: output -- name: Assert the state has changed - assert: - that: - - output.changed == false - -- name: Delete instance of SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: "sqlsrv{{ rpfx }}" - state: absent diff --git a/test/integration/targets/azure_rm_sqlserver/aliases b/test/integration/targets/azure_rm_sqlserver/aliases index 021f5cf05bc..75471dce67d 100644 --- a/test/integration/targets/azure_rm_sqlserver/aliases +++ b/test/integration/targets/azure_rm_sqlserver/aliases @@ -1,3 +1,6 @@ cloud/azure destructive shippable/azure/group4 +azure_rm_sqlserver_facts +azure_rm_sqldatabase +azure_rm_sqlfirewallrule diff --git a/test/integration/targets/azure_rm_sqlserver/tasks/main.yml b/test/integration/targets/azure_rm_sqlserver/tasks/main.yml index 1e574240100..938b8644a6e 100644 --- a/test/integration/targets/azure_rm_sqlserver/tasks/main.yml +++ b/test/integration/targets/azure_rm_sqlserver/tasks/main.yml @@ -1,12 +1,12 @@ - name: Prepare random number set_fact: - random_postfix: "{{ 1000 | random }}" + random_postfix: "{{ 1000 | random }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" run_once: yes - name: Create instance of SQL Server -- check mode azure_rm_sqlserver: resource_group: "{{ resource_group }}" - name: "sqlsrv{{ random_postfix }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" + name: "sqlsrv{{ random_postfix }}" location: eastus admin_username: mylogin admin_password: Testpasswordxyz12! @@ -20,7 +20,7 @@ - name: Create instance of SQL Server azure_rm_sqlserver: resource_group: "{{ resource_group }}" - name: "sqlsrv{{ random_postfix }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" + name: "sqlsrv{{ random_postfix }}" location: eastus admin_username: mylogin admin_password: Testpasswordxyz12! @@ -34,7 +34,7 @@ - name: Create again instance of SQL Server azure_rm_sqlserver: resource_group: "{{ resource_group }}" - name: "sqlsrv{{ random_postfix }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" + name: "sqlsrv{{ random_postfix }}" location: eastus admin_username: mylogin admin_password: Testpasswordxyz12! @@ -45,10 +45,217 @@ - output.changed == false - output.state == 'Ready' +# azure_rm_sqlserver_facts tests + +- name: Gather facts SQL Server + azure_rm_sqlserver_facts: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers.sqlsrv{{ random_postfix }}.id != None + - output.servers.sqlsrv{{ random_postfix }}.name == "sqlsrv{{ random_postfix }}" + - output.servers.sqlsrv{{ random_postfix }}.type != None + - output.servers.sqlsrv{{ random_postfix }}.location != None + - output.servers.sqlsrv{{ random_postfix }}.kind != None + - output.servers.sqlsrv{{ random_postfix }}.version != None + - output.servers.sqlsrv{{ random_postfix }}.state != None + - output.servers.sqlsrv{{ random_postfix }}.fully_qualified_domain_name != None + +- name: Gather facts SQL Server - unexisting + azure_rm_sqlserver_facts: + resource_group: "{{ resource_group }}" + server_name: "unexisting" + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers == {} + +- name: Gather facts SQL Server - list + azure_rm_sqlserver_facts: + resource_group: "{{ resource_group }}" + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers.sqlsrv{{ random_postfix }}.id != None + - output.servers.sqlsrv{{ random_postfix }}.name == "sqlsrv{{ random_postfix }}" + - output.servers.sqlsrv{{ random_postfix }}.type != None + - output.servers.sqlsrv{{ random_postfix }}.location != None + - output.servers.sqlsrv{{ random_postfix }}.kind != None + - output.servers.sqlsrv{{ random_postfix }}.version != None + - output.servers.sqlsrv{{ random_postfix }}.state != None + - output.servers.sqlsrv{{ random_postfix }}.fully_qualified_domain_name != None + +# azure_rm_sqldatabase tests + +- name: Create instance of SQL Database -- check mode + azure_rm_sqldatabase: + resource_group: "{{ resource_group }}" + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + location: eastus + check_mode: yes + register: output +- name: Assert the resource instance is well created + assert: + that: + - output.changed + +- name: Create instance of SQL Database + azure_rm_sqldatabase: + resource_group: "{{ resource_group }}" + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + location: eastus + register: output +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.status == 'Online' + +- name: Create again instance of SQL Database + azure_rm_sqldatabase: + resource_group: "{{ resource_group }}" + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + location: eastus + register: output +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.status == 'Online' + +- name: Delete instance of SQL Database -- check mode + azure_rm_sqldatabase: + resource_group: "{{ resource_group }}" + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + state: absent + check_mode: yes + register: output +- name: Assert the state has changed + assert: + that: + - output.changed + +- name: Delete instance of SQL Database + azure_rm_sqldatabase: + resource_group: "{{ resource_group }}" + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + state: absent + register: output +- name: Assert the state has changed + assert: + that: + - output.changed + +- name: Delete unexisting instance of SQL Database + azure_rm_sqldatabase: + resource_group: "{{ resource_group }}" + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + state: absent + register: output +- name: Assert the state has changed + assert: + that: + - output.changed == false + +# azure_rm_sqlfirewallrule tests + +- name: Create instance of Firewall Rule -- check mode + azure_rm_sqlfirewallrule: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + name: firewallrule{{ random_postfix }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 + check_mode: yes + register: output +- name: Assert the resource instance is well created + assert: + that: + - output.changed + +- name: Create instance of Firewall Rule + azure_rm_sqlfirewallrule: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + name: firewallrule{{ random_postfix }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 + register: output +- name: Assert the resource instance is well created + assert: + that: + - output.changed + +- name: Create again instance of Firewall Rule + azure_rm_sqlfirewallrule: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + name: firewallrule{{ random_postfix }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 + register: output +- name: Assert the state has not changed + assert: + that: + - output.changed == false + +- name: Delete instance of Firewall Rule -- check mode + azure_rm_sqlfirewallrule: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + name: firewallrule{{ random_postfix }} + state: absent + check_mode: yes + register: output +- name: Assert the state has changed + assert: + that: + - output.changed + +- name: Delete instance of Firewall Rule + azure_rm_sqlfirewallrule: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + name: firewallrule{{ random_postfix }} + state: absent + register: output +- name: Assert the state has changed + assert: + that: + - output.changed + +- name: Delete unexisting instance of Firewall Rule + azure_rm_sqlfirewallrule: + resource_group: "{{ resource_group }}" + server_name: "sqlsrv{{ random_postfix }}" + name: firewallrule{{ random_postfix }} + state: absent + register: output +- name: Assert the state has changed + assert: + that: + - output.changed == false + +# finalise & clean up azure_rm_sqlserver test + - name: Delete instance of SQL Server -- check mode azure_rm_sqlserver: resource_group: "{{ resource_group }}" - name: "sqlsrv{{ random_postfix }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" + name: "sqlsrv{{ random_postfix }}" state: absent check_mode: yes register: output @@ -60,7 +267,7 @@ - name: Delete instance of SQL Server azure_rm_sqlserver: resource_group: "{{ resource_group }}" - name: "sqlsrv{{ random_postfix }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" + name: "sqlsrv{{ random_postfix }}" state: absent register: output - name: Assert the state has changed @@ -71,7 +278,7 @@ - name: Delete unexisting instance of SQL Server azure_rm_sqlserver: resource_group: "{{ resource_group }}" - name: "sqlsrv{{ random_postfix }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" + name: "sqlsrv{{ random_postfix }}" state: absent register: output - name: Assert the state has changed diff --git a/test/integration/targets/azure_rm_sqlserver_facts/aliases b/test/integration/targets/azure_rm_sqlserver_facts/aliases deleted file mode 100644 index e391de0dce5..00000000000 --- a/test/integration/targets/azure_rm_sqlserver_facts/aliases +++ /dev/null @@ -1,3 +0,0 @@ -cloud/azure -destructive -shippable/azure/group3 diff --git a/test/integration/targets/azure_rm_sqlserver_facts/meta/main.yml b/test/integration/targets/azure_rm_sqlserver_facts/meta/main.yml deleted file mode 100644 index 95e1952f989..00000000000 --- a/test/integration/targets/azure_rm_sqlserver_facts/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - setup_azure diff --git a/test/integration/targets/azure_rm_sqlserver_facts/tasks/main.yml b/test/integration/targets/azure_rm_sqlserver_facts/tasks/main.yml deleted file mode 100644 index 4593a627ec5..00000000000 --- a/test/integration/targets/azure_rm_sqlserver_facts/tasks/main.yml +++ /dev/null @@ -1,104 +0,0 @@ -- name: Prepare random number - set_fact: - rpfx: "{{ 1000 | random }}{{ resource_group | hash('md5') | truncate(7, True, '') }}" - run_once: yes - -- name: Create SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: "sqlsrv{{ rpfx }}" - location: eastus - admin_username: mylogin - admin_password: Testpasswordxyz12! - -- name: Create SQL Server - 2 - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: "sqlsrv{{ rpfx }}x" - location: eastus - admin_username: mylogin - admin_password: Testpasswordxyz12! - -- name: Gather facts SQL Server - azure_rm_sqlserver_facts: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}" - register: output -- name: Assert that facts are returned - assert: - that: - - output.changed == False - - output.servers.sqlsrv{{ rpfx }}.id != None - - output.servers.sqlsrv{{ rpfx }}.name == "sqlsrv{{ rpfx }}" - - output.servers.sqlsrv{{ rpfx }}.type != None - - output.servers.sqlsrv{{ rpfx }}.location != None - - output.servers.sqlsrv{{ rpfx }}.kind != None - - output.servers.sqlsrv{{ rpfx }}.version != None - - output.servers.sqlsrv{{ rpfx }}.state != None - - output.servers.sqlsrv{{ rpfx }}.fully_qualified_domain_name != None - -- name: Gather facts SQL Server - second - azure_rm_sqlserver_facts: - resource_group: "{{ resource_group }}" - server_name: "sqlsrv{{ rpfx }}x" - register: output -- name: Assert that facts are returned - assert: - that: - - output.changed == False - - output.servers.sqlsrv{{ rpfx }}x.id != None - - output.servers.sqlsrv{{ rpfx }}x.name == "sqlsrv{{ rpfx }}x" - - output.servers.sqlsrv{{ rpfx }}x.type != None - - output.servers.sqlsrv{{ rpfx }}x.location != None - - output.servers.sqlsrv{{ rpfx }}x.kind != None - - output.servers.sqlsrv{{ rpfx }}x.version != None - - output.servers.sqlsrv{{ rpfx }}x.state != None - - output.servers.sqlsrv{{ rpfx }}x.fully_qualified_domain_name != None - -- name: Gather facts SQL Server - unexisting - azure_rm_sqlserver_facts: - resource_group: "{{ resource_group }}" - server_name: "unexisting" - register: output -- name: Assert that facts are returned - assert: - that: - - output.changed == False - - output.servers == {} - -- name: Gather facts SQL Server - list - azure_rm_sqlserver_facts: - resource_group: "{{ resource_group }}" - register: output -- name: Assert that facts are returned - assert: - that: - - output.changed == False - - output.servers.sqlsrv{{ rpfx }}.id != None - - output.servers.sqlsrv{{ rpfx }}.name == "sqlsrv{{ rpfx }}" - - output.servers.sqlsrv{{ rpfx }}.type != None - - output.servers.sqlsrv{{ rpfx }}.location != None - - output.servers.sqlsrv{{ rpfx }}.kind != None - - output.servers.sqlsrv{{ rpfx }}.version != None - - output.servers.sqlsrv{{ rpfx }}.state != None - - output.servers.sqlsrv{{ rpfx }}.fully_qualified_domain_name != None - - output.servers.sqlsrv{{ rpfx }}x.id != None - - output.servers.sqlsrv{{ rpfx }}x.name == "sqlsrv{{ rpfx }}x" - - output.servers.sqlsrv{{ rpfx }}x.type != None - - output.servers.sqlsrv{{ rpfx }}x.location != None - - output.servers.sqlsrv{{ rpfx }}x.kind != None - - output.servers.sqlsrv{{ rpfx }}x.version != None - - output.servers.sqlsrv{{ rpfx }}x.state != None - - output.servers.sqlsrv{{ rpfx }}x.fully_qualified_domain_name != None - -- name: Delete instance of SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: "sqlsrv{{ rpfx }}" - state: absent - -- name: Delete instance of SQL Server - azure_rm_sqlserver: - resource_group: "{{ resource_group }}" - name: "sqlsrv{{ rpfx }}x" - state: absent