summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/proxysql/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/community/proxysql/tests')
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/defaults/main.yml5
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/config.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/install.yml28
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/main.yml9
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/vars/main.yml13
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/defaults/main.yml8
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/base_test.yml57
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/cleanup_test_servers.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/main.yml88
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/setup_test_server.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/defaults/main.yml8
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/base_test.yml54
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/cleanup_global_variables.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/main.yml53
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setup_global_variables.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setvars.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/tasks/main.yml36
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/defaults/main.yml8
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/base_test.yml59
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/cleanup_test_users.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/main.yml88
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/setup_test_user.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/defaults/main.yml16
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/base_test.yml127
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/cleanup_test_query_rules.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/main.yml98
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/setup_test_query_rule.yml17
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule.yml55
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_in_memory_only.yml52
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_with_delayed_persist.yml54
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_using_check_mode.yml53
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule.yml53
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_in_memory_only.yml54
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_with_delayed_persist.yml52
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_using_check_mode.yml53
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/defaults/main.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/107-update_destination_hostgroup.yml61
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/base_test.yml61
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/cleanup_test_query_rules_fast_routing.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/main.yml93
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/setup_test_query_rules_fast_routing.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_in_memory_only.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/defaults/main.yml9
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/base_test.yml58
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/cleanup_test_replication_hostgroups.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/main.yml220
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/setup_test_replication_hostgroups.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_in_memory_only.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/defaults/main.yml9
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/meta/main.yml3
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/base_test.yml58
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/cleanup_test_schedulers.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/main.yml88
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/setup_test_scheduler.yml12
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/teardown.yml6
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_in_memory_only.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_in_memory_only.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_with_delayed_persist.yml31
-rw-r--r--ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_using_check_mode.yml30
-rw-r--r--ansible_collections/community/proxysql/tests/sanity/ignore-2.10.txt2
-rw-r--r--ansible_collections/community/proxysql/tests/sanity/ignore-2.11.txt2
-rw-r--r--ansible_collections/community/proxysql/tests/sanity/ignore-2.9.txt2
-rw-r--r--ansible_collections/community/proxysql/tests/sanity/skip-2.12.txt2
114 files changed, 3471 insertions, 0 deletions
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/defaults/main.yml
new file mode 100644
index 000000000..d994a842b
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+proxysql_download_src: https://github.com/sysown/proxysql/releases/download
+proxysql_version: 2.0.10
+
+proxysql_mysql_client_version: 5.7
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/config.yml b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/config.yml
new file mode 100644
index 000000000..a66a01aec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/config.yml
@@ -0,0 +1,12 @@
+---
+- name: proxysql | config | enable and start proxysql
+ service:
+ name: proxysql
+ state: started
+ enabled: true
+
+- name: proxysql | config | wait for proxysql
+ wait_for:
+ port: 6032
+ state: started
+ timeout: 30
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/install.yml b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/install.yml
new file mode 100644
index 000000000..5ceb67ae9
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/install.yml
@@ -0,0 +1,28 @@
+---
+- name: proxysql | install | add apt signing key for percona
+ apt_key:
+ keyserver: keyserver.ubuntu.com
+ id: 4D1BB29D63D98E422B2113B19334A25F8507EFA5
+ state: present
+
+- name: proxysql | install | add percona repositories
+ apt_repository:
+ repo: "{{ item }}"
+ state: present
+ loop: "{{ proxysql_percona_mysql_repos }}"
+
+- name: proxysql | install | install proxysql release
+ apt:
+ deb: "{{ proxysql_release }}"
+ state: present
+
+- name: proxysql | install | install packages required by proxysql
+ apt:
+ name: "{{ proxysql_percona_mysql_packages }}"
+ state: present
+ environment:
+ DEBIAN_FRONTEND: noninteractive
+
+- name: proxysql | install | install python packages
+ pip:
+ name: "{{ proxysql_python_packages }}"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/main.yml
new file mode 100644
index 000000000..188d0d0bb
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+- name: install and configure proxysql only if not exists
+ block:
+ - import_tasks: install.yml
+ - import_tasks: config.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/vars/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/vars/main.yml
new file mode 100644
index 000000000..443d7891b
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/vars/main.yml
@@ -0,0 +1,13 @@
+---
+proxysql_release: "{{ proxysql_download_src }}/v{{ proxysql_version }}/proxysql_{{ proxysql_version }}-{{ ansible_lsb.id | lower }}{{ ansible_lsb.major_release }}_amd64.deb"
+
+proxysql_percona_mysql_repos:
+ - deb http://repo.percona.com/apt {{ ansible_lsb.codename }} main
+ - deb-src http://repo.percona.com/apt {{ ansible_lsb.codename }} main
+
+proxysql_percona_mysql_packages:
+ - percona-server-client-{{ proxysql_mysql_client_version }}
+ # - python-mysqldb
+
+proxysql_python_packages:
+ - pymysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/defaults/main.yml
new file mode 100644
index 000000000..f5a4be59f
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/defaults/main.yml
@@ -0,0 +1,8 @@
+---
+test_host: mysql01
+
+test_proxysql_backend_servers_check_mode: false
+test_proxysql_backend_servers_in_memory_only: false
+test_proxysql_backend_servers_with_delayed_persist: false
+test_proxysql_backend_servers_check_idempotence: false
+test_proxysql_backend_servers_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/base_test.yml
new file mode 100644
index 000000000..4cd1d0979
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/base_test.yml
@@ -0,0 +1,57 @@
+---
+### prepare
+- name: "{{ role_name }} | {{ current_test }} | are we performing a delete"
+ set_fact:
+ test_delete: "{{ current_test | regex_search('^test_delete') | ternary(true, false) }}"
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: "{{ test_delete|ternary('setup_test_server', 'cleanup_test_servers') }}.yml"
+ when: not test_proxysql_backend_servers_check_idempotence
+
+### when
+
+- name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test backend mysql server"
+ proxysql_backend_servers:
+ login_user: admin
+ login_password: admin
+ hostname: "{{ test_host }}"
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_backend_servers_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_backend_servers_in_memory_only }}"
+ check_mode: "{{ test_proxysql_backend_servers_check_mode }}"
+ register: status
+
+- name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the mysql servers config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL SERVERS
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the mysql servers config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL SERVERS
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_backend_servers_with_delayed_persist
+
+- name: "{{ role_name }} | {{ current_test }} | check if test backend mysql server exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT hostname FROM mysql_servers where hostname = '{{ test_host }}'"
+ register: memory_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test backend mysql server exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT hostname FROM disk.mysql_servers where hostname = '{{ test_host }}'"
+ register: disk_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test backend mysql server exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT hostname FROM runtime_mysql_servers where hostname = '{{ test_host }}'"
+ register: runtime_result
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/cleanup_test_servers.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/cleanup_test_servers.yml
new file mode 100644
index 000000000..070e15bb0
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/cleanup_test_servers.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no hosts are created"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"DELETE FROM mysql_servers"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no hosts are saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL SERVERS TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no hosts are loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL SERVERS TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/main.yml
new file mode 100644
index 000000000..7b63832f0
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/main.yml
@@ -0,0 +1,88 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+### tests
+
+- name: "{{ role_name }} | test_create_using_check_mode | test create backend server using check mode"
+ import_tasks: test_create_using_check_mode.yml
+ vars:
+ test_proxysql_backend_servers_check_mode: true
+
+- name: "{{ role_name }} | test_delete_using_check_mode | test delete backend server using check mode"
+ import_tasks: test_delete_using_check_mode.yml
+ vars:
+ test_proxysql_backend_servers_check_mode: true
+
+- name: "{{ role_name }} | test_create_backend_server | test create backend server"
+ import_tasks: test_create_backend_server.yml
+ vars:
+ test_proxysql_backend_servers_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_backend_server | test idempotence of create backend server"
+ import_tasks: test_create_backend_server.yml
+ vars:
+ test_proxysql_backend_servers_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_backend_server | test delete backend server"
+ import_tasks: test_delete_backend_server.yml
+ vars:
+ test_proxysql_backend_servers_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_backend_server | test idempotence of delete backend server"
+ import_tasks: test_delete_backend_server.yml
+ vars:
+ test_proxysql_backend_servers_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_backend_server_in_memory_only | test create backend server in memory"
+ import_tasks: test_create_backend_server_in_memory_only.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_backend_server_in_memory_only | test idempotence of create backend server in memory"
+ import_tasks: test_create_backend_server_in_memory_only.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_backend_server_in_memory_only | test delete backend server in memory"
+ import_tasks: test_delete_backend_server_in_memory_only.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_backend_server_in_memory_only | test idempotence of delete backend server in memory"
+ import_tasks: test_delete_backend_server_in_memory_only.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_backend_server_with_delayed_persist | test create backend server with delayed save to disk/load to runtime"
+ import_tasks: test_create_backend_server_with_delayed_persist.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_with_delayed_persist: true
+ test_proxysql_backend_servers_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_backend_server_with_delayed_persist | test idempotence of create backend server with delayed save to disk/load to runtime"
+ import_tasks: test_create_backend_server_with_delayed_persist.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_with_delayed_persist: true
+ test_proxysql_backend_servers_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_backend_server_with_delayed_persist | test delete backend server with delayed save to disk/load to runtime"
+ import_tasks: test_delete_backend_server_with_delayed_persist.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_with_delayed_persist: true
+ test_proxysql_backend_servers_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_backend_server_with_delayed_persist | test idempotence of delete backend server with delayed save to disk/load to runtime"
+ import_tasks: test_delete_backend_server_with_delayed_persist.yml
+ vars:
+ test_proxysql_backend_servers_in_memory_only: true
+ test_proxysql_backend_servers_with_delayed_persist: true
+ test_proxysql_backend_servers_check_idempotence: true
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/setup_test_server.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/setup_test_server.yml
new file mode 100644
index 000000000..64d9dacda
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/setup_test_server.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test backend mysql server is created when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test backend mysql server is created in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO mysql_servers (hostname) VALUES ('{{ test_host }}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test backend mysql server is created on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL SERVERS TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test backend mysql server is created in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL SERVERS TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server.yml
new file mode 100644
index 000000000..fc1999531
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_backend_server | set current test"
+ set_fact:
+ current_test: test_create_backend_server
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create server reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_backend_servers_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_host }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
+ when: test_proxysql_backend_servers_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_in_memory_only.yml
new file mode 100644
index 000000000..fe6148b78
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_backend_server_in_memory_only | set current test"
+ set_fact:
+ current_test: test_create_backend_server_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create server reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_backend_servers_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
+ when: test_proxysql_backend_servers_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_with_delayed_persist.yml
new file mode 100644
index 000000000..c4c8956f0
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_backend_server_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_backend_server_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_create_backend_server_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create server reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_backend_servers_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_host }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
+ when: test_proxysql_backend_servers_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_using_check_mode.yml
new file mode 100644
index 000000000..2c2dfa97a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_create_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_create_using_check_mode | set current test"
+ set_fact:
+ current_test: test_create_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create server in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create server in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server.yml
new file mode 100644
index 000000000..17305edf5
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_backend_server | set current test"
+ set_fact:
+ current_test: test_delete_backend_server
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete server reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_backend_servers_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
+ when: test_proxysql_backend_servers_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_in_memory_only.yml
new file mode 100644
index 000000000..b7882fb65
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_backend_server_in_memory_only | set current test"
+ set_fact:
+ current_test: test_delete_backend_server_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete server reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_backend_servers_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_host }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
+ when: test_proxysql_backend_servers_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_with_delayed_persist.yml
new file mode 100644
index 000000000..516a0a475
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_backend_server_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_backend_server_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_delete_backend_server_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete server reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_backend_servers_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
+ when: test_proxysql_backend_servers_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_using_check_mode.yml
new file mode 100644
index 000000000..17aac721d
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_backend_servers/tasks/test_delete_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_using_check_mode | set current test"
+ set_fact:
+ current_test: test_delete_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete server in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_host }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete server in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_host }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_servers.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/defaults/main.yml
new file mode 100644
index 000000000..d65393845
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/defaults/main.yml
@@ -0,0 +1,8 @@
+---
+test_variable: mysql-max_connections
+
+test_proxysql_global_variables_check_mode: false
+test_proxysql_global_variables_in_memory_only: false
+test_proxysql_global_variables_with_delayed_persist: false
+test_proxysql_global_variables_check_idempotence: false
+test_proxysql_global_variables_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/base_test.yml
new file mode 100644
index 000000000..7676ddf9b
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/base_test.yml
@@ -0,0 +1,54 @@
+---
+### prepare
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: setup_global_variables.yml
+ when: not test_proxysql_global_variables_check_idempotence
+
+### when
+
+- name: "{{ role_name }} | {{ current_test }} | update global variable"
+ proxysql_global_variables:
+ login_user: admin
+ login_password: admin
+ variable: "{{ test_variable }}"
+ value: "{{ updated_variable_value }}"
+ save_to_disk: "{{ not test_proxysql_global_variables_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_global_variables_in_memory_only }}"
+ check_mode: "{{ test_proxysql_global_variables_check_mode }}"
+ register: status
+
+- name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save global variables from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL VARIABLES
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load global variables from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL VARIABLES
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_global_variables_with_delayed_persist
+
+- name: "{{ role_name }} | {{ current_test }} | check if updated global variable value exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT variable_value FROM global_variables where variable_name='{{ test_variable }}'"
+ register: memory_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if updated global variable value exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT variable_value FROM disk.global_variables where variable_name='{{ test_variable }}'"
+ register: disk_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if updated global variable value exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT variable_value FROM runtime_global_variables where variable_name='{{ test_variable }}'"
+ register: runtime_result
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/cleanup_global_variables.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/cleanup_global_variables.yml
new file mode 100644
index 000000000..68241ac77
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/cleanup_global_variables.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure variable value set to original value"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"UPDATE global_variables SET variable_value={{ original_variable_value }} WHERE variable_name='{{ test_variable }}'"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure original variable value is saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL VARIABLES TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure original variable value is loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL VARIABLES TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/main.yml
new file mode 100644
index 000000000..81977c04a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/main.yml
@@ -0,0 +1,53 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: "{{ role_name }} | setvars | populate base variables for tests"
+ import_tasks: setvars.yml
+
+### tests
+
+- name: "{{ role_name }} | test_update_variable_value_using_check_mode | test updating global variable using check mode"
+ import_tasks: test_update_variable_value_using_check_mode.yml
+ vars:
+ test_proxysql_global_variables_check_mode: true
+
+- name: "{{ role_name }} | test_update_variable_value | test updating global variable value"
+ import_tasks: test_update_variable_value.yml
+ vars:
+ test_proxysql_global_variables_cleanup_after_test: false
+- name: "{{ role_name }} | test_update_variable_value | test idempotence of updating global variable value"
+ import_tasks: test_update_variable_value.yml
+ vars:
+ test_proxysql_global_variables_check_idempotence: true
+
+- name: "{{ role_name }} | test_update_variable_value_in_memory_only | test updating global variable value in memory"
+ import_tasks: test_update_variable_value_in_memory_only.yml
+ vars:
+ test_proxysql_global_variables_in_memory_only: true
+ test_proxysql_global_variables_cleanup_after_test: false
+- name: "{{ role_name }} | test_update_variable_value_in_memory_only | test idempotence of updating global variable value in memory"
+ import_tasks: test_update_variable_value_in_memory_only.yml
+ vars:
+ test_proxysql_global_variables_in_memory_only: true
+ test_proxysql_global_variables_check_idempotence: true
+
+- name: "{{ role_name }} | test_update_variable_value_with_delayed_persist | test updating global variable value with delayed save to disk/load to runtime"
+ import_tasks: test_update_variable_value_with_delayed_persist.yml
+ vars:
+ test_proxysql_global_variables_in_memory_only: true
+ test_proxysql_global_variables_with_delayed_persist: true
+ test_proxysql_global_variables_cleanup_after_test: false
+- name: "{{ role_name }} | test_update_variable_value_with_delayed_persist | test idempotence of updating global variable value with delayed save to disk/load to runtime"
+ import_tasks: test_update_variable_value_with_delayed_persist.yml
+ vars:
+ test_proxysql_global_variables_in_memory_only: true
+ test_proxysql_global_variables_with_delayed_persist: true
+ test_proxysql_global_variables_check_idempotence: true
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setup_global_variables.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setup_global_variables.yml
new file mode 100644
index 000000000..a5b0a8c47
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setup_global_variables.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test variable value is updated when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test variable value is updated in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"UPDATE global_variables SET variable_value={{ original_variable_value }} WHERE variable_name='{{ test_variable }}'"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test variable value is updated on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL VARIABLES TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test variable value is updated in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL VARIABLES TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setvars.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setvars.yml
new file mode 100644
index 000000000..6499f12f0
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/setvars.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | setvars | get original variable value"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT variable_value FROM global_variables where variable_name='{{ test_variable }}'"
+ register: result
+
+- name: "{{ role_name }} | setvars | populate original_variable_value variable"
+ set_fact:
+ original_variable_value: "{{ result.stdout }}"
+
+- name: "{{ role_name }} | setvars | populate updated_variable_value variable"
+ set_fact:
+ updated_variable_value: "{{ result.stdout|int * 2 }}"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value.yml
new file mode 100644
index 000000000..ff5bc8196
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_update_variable_value | set current test"
+ set_fact:
+ current_test: test_update_variable_value
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if updating variable value reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_global_variables_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change in memory"
+ assert:
+ that: "memory_result.stdout == '{{ updated_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change on disk"
+ assert:
+ that: "disk_result.stdout == '{{ updated_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change to runtime"
+ assert:
+ that: "runtime_result.stdout == '{{ updated_variable_value }}'"
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_global_variables.yml
+ when: test_proxysql_global_variables_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_in_memory_only.yml
new file mode 100644
index 000000000..11297ec5c
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_update_variable_value_in_memory_only | set current test"
+ set_fact:
+ current_test: test_update_variable_value_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if updating variable value reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_global_variables_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change in memory"
+ assert:
+ that: "memory_result.stdout == '{{ updated_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value didn't make a change on disk"
+ assert:
+ that: "disk_result.stdout == '{{ original_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value didn't make a change to runtime"
+ assert:
+ that: "runtime_result.stdout == '{{ original_variable_value }}'"
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_global_variables.yml
+ when: test_proxysql_global_variables_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_using_check_mode.yml
new file mode 100644
index 000000000..b98c2d208
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_update_variable_value_using_check_mode | set current test"
+ set_fact:
+ current_test: test_update_variable_value_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if updating variable value reported a change in check mode"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create updating variable value didn't make a change in memory in check mode"
+ assert:
+ that: "memory_result.stdout == '{{ original_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create updating variable value didn't make a change on disk in check mode"
+ assert:
+ that: "disk_result.stdout == '{{ original_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create updating variable value didn't make a change to runtime in check mode"
+ assert:
+ that: "runtime_result.stdout == '{{ original_variable_value }}'"
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_global_variables.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_with_delayed_persist.yml
new file mode 100644
index 000000000..d6bb4246d
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_global_variables/tasks/test_update_variable_value_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_updated_variable_value_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_updated_variable_value_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if updating variable value reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_global_variables_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change in memory"
+ assert:
+ that: "memory_result.stdout == '{{ updated_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change on disk"
+ assert:
+ that: "disk_result.stdout == '{{ updated_variable_value }}'"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm updating variable value did make a change to runtime"
+ assert:
+ that: "runtime_result.stdout == '{{ updated_variable_value }}'"
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_global_variables.yml
+ when: test_proxysql_global_variables_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/tasks/main.yml
new file mode 100644
index 000000000..5c5e6a4cd
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_info/tasks/main.yml
@@ -0,0 +1,36 @@
+---
+- name: "{{ role_name }} | proxysql_info | test in check_mode"
+ check_mode: true
+ community.proxysql.proxysql_info:
+ login_user: admin
+ login_password: admin
+ register: proxysql_information
+
+- debug:
+ var: proxysql_information.version
+
+- name: verify some return values
+ assert:
+ that:
+ - "'global_variables' in proxysql_information.tables"
+ - "'mysql_servers' in proxysql_information.tables"
+ - "'runtime_mysql_servers' in proxysql_information.tables"
+ - proxysql_information.version.major == 2
+ - "proxysql_information.global_variables['mysql-connect_timeout_server'] == '3000'"
+ - "proxysql_information.global_variables['admin-web_enabled'] == 'false'"
+
+- name: "{{ role_name }} | proxysql_info | test not in check_mode"
+ community.proxysql.proxysql_info:
+ login_user: admin
+ login_password: admin
+ register: proxysql_information
+
+- name: verify some return values
+ assert:
+ that:
+ - "'global_variables' in proxysql_information.tables"
+ - "'mysql_servers' in proxysql_information.tables"
+ - "'runtime_mysql_servers' in proxysql_information.tables"
+ - proxysql_information.version.major == 2
+ - "proxysql_information.global_variables['mysql-connect_timeout_server'] == '3000'"
+ - "proxysql_information.global_variables['admin-web_enabled'] == 'false'"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/defaults/main.yml
new file mode 100644
index 000000000..bd4f78739
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/defaults/main.yml
@@ -0,0 +1,8 @@
+---
+test_user: productiondba
+
+test_proxysql_mysql_users_check_mode: false
+test_proxysql_mysql_users_in_memory_only: false
+test_proxysql_mysql_users_with_delayed_persist: false
+test_proxysql_mysql_users_check_idempotence: false
+test_proxysql_mysql_users_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/base_test.yml
new file mode 100644
index 000000000..2fdd3640f
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/base_test.yml
@@ -0,0 +1,59 @@
+---
+### prepare
+- name: "{{ role_name }} | {{ current_test }} | are we performing a delete"
+ set_fact:
+ test_delete: "{{ current_test | regex_search('^test_delete') | ternary(true, false) }}"
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: "{{ test_delete|ternary('setup_test_user', 'cleanup_test_users') }}.yml"
+ when: not test_proxysql_mysql_users_check_idempotence
+
+### when
+
+- name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test mysql user"
+ proxysql_mysql_users:
+ login_user: admin
+ login_password: admin
+ username: productiondba
+ password: productiondbapassword
+ encrypt_password: true
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_mysql_users_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_mysql_users_in_memory_only }}"
+ check_mode: "{{ test_proxysql_mysql_users_check_mode }}"
+ register: status
+
+- name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the mysql users config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL USERS
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the mysql users config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL USERS
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_mysql_users_with_delayed_persist
+
+- name: "{{ role_name }} | {{ current_test }} | check if test mysql user exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username FROM mysql_users where username = '{{ test_user }}'"
+ register: memory_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test mysql user exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username FROM disk.mysql_users where username = '{{ test_user }}'"
+ register: disk_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test mysql user exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username FROM runtime_mysql_users where username = '{{ test_user }}'"
+ register: runtime_result
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/cleanup_test_users.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/cleanup_test_users.yml
new file mode 100644
index 000000000..865f5ef71
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/cleanup_test_users.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no users are created"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"DELETE FROM mysql_users"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no users are saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL USERS TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no users are loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL USERS TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/main.yml
new file mode 100644
index 000000000..fc3ecbf75
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/main.yml
@@ -0,0 +1,88 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+### tests
+
+- name: "{{ role_name }} | test_create_using_check_mode | test create mysql user using check mode"
+ import_tasks: test_create_using_check_mode.yml
+ vars:
+ test_proxysql_mysql_users_check_mode: true
+
+- name: "{{ role_name }} | test_delete_using_check_mode | test delete mysql user using check mode"
+ import_tasks: test_delete_using_check_mode.yml
+ vars:
+ test_proxysql_mysql_users_check_mode: true
+
+- name: "{{ role_name }} | test_create_mysql_user | test create mysql user"
+ import_tasks: test_create_mysql_user.yml
+ vars:
+ test_proxysql_mysql_users_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_mysql_user | test idempotence of create mysql user"
+ import_tasks: test_create_mysql_user.yml
+ vars:
+ test_proxysql_mysql_users_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_mysql_user | test delete mysql user"
+ import_tasks: test_delete_mysql_user.yml
+ vars:
+ test_proxysql_mysql_users_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_mysql_user | test idempotence of delete mysql user"
+ import_tasks: test_delete_mysql_user.yml
+ vars:
+ test_proxysql_mysql_users_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_mysql_user_in_memory_only | test create mysql user in memory"
+ import_tasks: test_create_mysql_user_in_memory_only.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_mysql_user_in_memory_only | test idempotence of create mysql user in memory"
+ import_tasks: test_create_mysql_user_in_memory_only.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_mysql_user_in_memory_only | test delete mysql user in memory"
+ import_tasks: test_delete_mysql_user_in_memory_only.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_mysql_user_in_memory_only | test idempotence of delete mysql user in memory"
+ import_tasks: test_delete_mysql_user_in_memory_only.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_mysql_user_with_delayed_persist | test create mysql user with delayed save to disk/load to runtime"
+ import_tasks: test_create_mysql_user_with_delayed_persist.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_with_delayed_persist: true
+ test_proxysql_mysql_users_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_mysql_user_with_delayed_persist | test idempotence of create mysql user with delayed save to disk/load to runtime"
+ import_tasks: test_create_mysql_user_with_delayed_persist.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_with_delayed_persist: true
+ test_proxysql_mysql_users_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_mysql_user_with_delayed_persist | test delete mysql user with delayed save to disk/load to runtime"
+ import_tasks: test_delete_mysql_user_with_delayed_persist.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_with_delayed_persist: true
+ test_proxysql_mysql_users_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_mysql_user_with_delayed_persist | test idempotence of delete mysql user with delayed save to disk/load to runtime"
+ import_tasks: test_delete_mysql_user_with_delayed_persist.yml
+ vars:
+ test_proxysql_mysql_users_in_memory_only: true
+ test_proxysql_mysql_users_with_delayed_persist: true
+ test_proxysql_mysql_users_check_idempotence: true
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/setup_test_user.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/setup_test_user.yml
new file mode 100644
index 000000000..9ad43c988
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/setup_test_user.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test mysql user is created when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test mysql user is created in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO mysql_users (username) VALUES ('{{ test_user }}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test mysql user is created on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL USERS TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test mysql user is created in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL USERS TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user.yml
new file mode 100644
index 000000000..81616b482
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_mysql_user | set current test"
+ set_fact:
+ current_test: test_create_mysql_user
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create user reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_mysql_users_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }}\n{{ test_user }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
+ when: test_proxysql_mysql_users_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_in_memory_only.yml
new file mode 100644
index 000000000..6abd5553d
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_mysql_user_in_memory_only | set current test"
+ set_fact:
+ current_test: test_create_mysql_user_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create user reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_mysql_users_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
+ when: test_proxysql_mysql_users_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_with_delayed_persist.yml
new file mode 100644
index 000000000..5a2028221
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_mysql_user_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_mysql_user_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_create_mysql_user_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create user reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_mysql_users_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }}\n{{ test_user }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
+ when: test_proxysql_mysql_users_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_using_check_mode.yml
new file mode 100644
index 000000000..314d63076
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_create_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_create_using_check_mode | set current test"
+ set_fact:
+ current_test: test_create_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create user in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create user in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user.yml
new file mode 100644
index 000000000..48827968e
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_mysql_user | set current test"
+ set_fact:
+ current_test: test_delete_mysql_user
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete user reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_mysql_users_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
+ when: test_proxysql_mysql_users_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_in_memory_only.yml
new file mode 100644
index 000000000..7967bf010
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_mysql_user_in_memory_only | set current test"
+ set_fact:
+ current_test: test_delete_mysql_user_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete user reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_mysql_users_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }}\n{{ test_user }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
+ when: test_proxysql_mysql_users_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_with_delayed_persist.yml
new file mode 100644
index 000000000..4239b6b4b
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_mysql_user_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_mysql_user_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_delete_mysql_user_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete user reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_mysql_users_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
+ when: test_proxysql_mysql_users_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_using_check_mode.yml
new file mode 100644
index 000000000..a2001540c
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_mysql_users/tasks/test_delete_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_using_check_mode | set current test"
+ set_fact:
+ current_test: test_delete_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete user in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete user in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }}\n{{ test_user }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_users.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/defaults/main.yml
new file mode 100644
index 000000000..15335cbb2
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/defaults/main.yml
@@ -0,0 +1,16 @@
+---
+test_user: 'guest_ro'
+test_match_pattern: "^SELECT.*"
+test_destination_hostgroup: 1
+test_active: 1
+test_retries: 3
+test_cache_ttl: 20000
+test_cache_empty_result: 0
+test_multiplex: 0
+test_next_query_flagin: 0
+
+test_proxysql_query_rules_check_mode: false
+test_proxysql_query_rules_in_memory_only: false
+test_proxysql_query_rules_with_delayed_persist: false
+test_proxysql_query_rules_check_idempotence: false
+test_proxysql_query_rules_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/base_test.yml
new file mode 100644
index 000000000..1b2c6342e
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/base_test.yml
@@ -0,0 +1,127 @@
+---
+### prepare
+- name: "{{ role_name }} | {{ current_test }} | are we performing a delete"
+ set_fact:
+ test_delete: "{{ current_test | regex_search('^test_delete') | ternary(true, false) }}"
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: "{{ test_delete|ternary('setup_test_query_rule', 'cleanup_test_query_rules') }}.yml"
+ when: not test_proxysql_query_rules_check_idempotence
+
+### when proxysql >= 2
+
+- name: test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test query rule"
+ proxysql_query_rules:
+ login_user: admin
+ login_password: admin
+ username: '{{ test_user }}'
+ match_pattern: '{{ test_match_pattern }}'
+ destination_hostgroup: '{{ test_destination_hostgroup }}'
+ active: '{{ test_active }}'
+ retries: '{{ test_retries }}'
+ cache_ttl: '{{ test_cache_ttl }}'
+ cache_empty_result: '{{ test_cache_empty_result }}'
+ multiplex: '{{ test_multiplex }}'
+ next_query_flagIN: '{{ test_next_query_flagin }}'
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_query_rules_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_query_rules_in_memory_only }}"
+ check_mode: "{{ test_proxysql_query_rules_check_mode }}"
+ register: status
+
+ - name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the query rules config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL QUERY RULES
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the query rules config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL QUERY RULES
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_query_rules_with_delayed_persist
+
+ - name: "{{ role_name }} | {{ current_test }} | check if test query rule exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || match_pattern || ',' || destination_hostgroup || ',' || active || ',' || retries || ',' || cache_ttl || ',' || cache_empty_result || ',' || multiplex || ',' || next_query_flagIN FROM mysql_query_rules where username = '{{ test_user }}' and match_pattern = '{{ test_match_pattern }}' and destination_hostgroup and '{{ test_destination_hostgroup }}' and active = '{{ test_active }}' and retries = '{{ test_retries }}' and cache_ttl = '{{ test_cache_ttl }}' and cache_empty_result = '{{ test_cache_empty_result }}' and multiplex = '{{ test_multiplex }}' and next_query_flagIN = '{{ test_next_query_flagin }}'"
+ register: memory_result
+
+ - name: "{{ role_name }} | {{ current_test }} | check if test query rule exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || match_pattern || ',' || destination_hostgroup || ',' || active || ',' || retries || ',' || cache_ttl || ',' || cache_empty_result || ',' || multiplex || ',' || next_query_flagIN FROM disk.mysql_query_rules where username = '{{ test_user }}' and match_pattern = '{{ test_match_pattern }}' and destination_hostgroup and '{{ test_destination_hostgroup }}' and active = '{{ test_active }}' and retries = '{{ test_retries }}' and cache_ttl = '{{ test_cache_ttl }}' and cache_empty_result = '{{ test_cache_empty_result }}' and multiplex = '{{ test_multiplex }}' and next_query_flagIN = '{{ test_next_query_flagin }}'"
+ register: disk_result
+
+ - name: "{{ role_name }} | {{ current_test }} | check if test query rule exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || match_pattern || ',' || destination_hostgroup || ',' || active || ',' || retries || ',' || cache_ttl || ',' || cache_empty_result || ',' || multiplex || ',' || next_query_flagIN FROM runtime_mysql_query_rules where username = '{{ test_user }}' and match_pattern = '{{ test_match_pattern }}' and destination_hostgroup and '{{ test_destination_hostgroup }}' and active = '{{ test_active }}' and retries = '{{ test_retries }}' and cache_ttl = '{{ test_cache_ttl }}' and cache_empty_result = '{{ test_cache_empty_result }}' and multiplex = '{{ test_multiplex }}' and next_query_flagIN = '{{ test_next_query_flagin }}'"
+ register: runtime_result
+
+
+### when proxysql < 2
+
+- name: test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test query rule"
+ proxysql_query_rules:
+ login_user: admin
+ login_password: admin
+ username: '{{ test_user }}'
+ match_pattern: '{{ test_match_pattern }}'
+ destination_hostgroup: '{{ test_destination_hostgroup }}'
+ active: '{{ test_active }}'
+ retries: '{{ test_retries }}'
+ cache_ttl: '{{ test_cache_ttl }}'
+ multiplex: '{{ test_multiplex }}'
+ next_query_flagIN: '{{ test_next_query_flagin }}'
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_query_rules_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_query_rules_in_memory_only }}"
+ check_mode: "{{ test_proxysql_query_rules_check_mode }}"
+ register: status1
+
+ - name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the query rules config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL QUERY RULES
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the query rules config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL QUERY RULES
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_query_rules_with_delayed_persist
+
+ - name: "{{ role_name }} | {{ current_test }} | check if test query rule exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || match_pattern || ',' || destination_hostgroup || ',' || active || ',' || retries || ',' || cache_ttl || ',' || multiplex || ',' || next_query_flagIN FROM mysql_query_rules where username = '{{ test_user }}' and match_pattern = '{{ test_match_pattern }}' and destination_hostgroup and '{{ test_destination_hostgroup }}' and active = '{{ test_active }}' and retries = '{{ test_retries }}' and cache_ttl = '{{ test_cache_ttl }}' and multiplex = '{{ test_multiplex }}' and next_query_flagIN = '{{ test_next_query_flagin }}'"
+ register: memory_result1
+
+ - name: "{{ role_name }} | {{ current_test }} | check if test query rule exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || match_pattern || ',' || destination_hostgroup || ',' || active || ',' || retries || ',' || cache_ttl || ',' || multiplex || ',' || next_query_flagIN FROM disk.mysql_query_rules where username = '{{ test_user }}' and match_pattern = '{{ test_match_pattern }}' and destination_hostgroup and '{{ test_destination_hostgroup }}' and active = '{{ test_active }}' and retries = '{{ test_retries }}' and cache_ttl = '{{ test_cache_ttl }}' and multiplex = '{{ test_multiplex }}' and next_query_flagIN = '{{ test_next_query_flagin }}'"
+ register: disk_result1
+
+ - name: "{{ role_name }} | {{ current_test }} | check if test query rule exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || match_pattern || ',' || destination_hostgroup || ',' || active || ',' || retries || ',' || cache_ttl || ',' || multiplex || ',' || next_query_flagIN FROM runtime_mysql_query_rules where username = '{{ test_user }}' and match_pattern = '{{ test_match_pattern }}' and destination_hostgroup and '{{ test_destination_hostgroup }}' and active = '{{ test_active }}' and retries = '{{ test_retries }}' and cache_ttl = '{{ test_cache_ttl }}' and multiplex = '{{ test_multiplex }}' and next_query_flagIN = '{{ test_next_query_flagin }}'"
+ register: runtime_result1
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/cleanup_test_query_rules.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/cleanup_test_query_rules.yml
new file mode 100644
index 000000000..3f233b7f5
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/cleanup_test_query_rules.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no query rules are created"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"DELETE FROM mysql_query_rules"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no query rules are saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL QUERY RULES TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no query rules are loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL QUERY RULES TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/main.yml
new file mode 100644
index 000000000..6b5bcab68
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/main.yml
@@ -0,0 +1,98 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+### tests
+- name: "{{ role_name }} | proxysql_info"
+ check_mode: true
+ community.proxysql.proxysql_info:
+ login_user: admin
+ login_password: admin
+ register: proxysql_information
+
+- name: set proxysql version fact
+ set_fact:
+ PROXYSQL2: "{{ proxysql_information.version.major >= 2 }}"
+
+- name: "{{ role_name }} | test_create_using_check_mode | test create query rule using check mode"
+ import_tasks: test_create_using_check_mode.yml
+ vars:
+ test_proxysql_query_rules_check_mode: true
+
+- name: "{{ role_name }} | test_delete_using_check_mode | test delete query rule using check mode"
+ import_tasks: test_delete_using_check_mode.yml
+ vars:
+ test_proxysql_query_rules_check_mode: true
+
+- name: "{{ role_name }} | test_create_query_rule | test create query rule"
+ import_tasks: test_create_query_rule.yml
+ vars:
+ test_proxysql_query_rules_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_query_rule | test idempotence of create query rule"
+ import_tasks: test_create_query_rule.yml
+ vars:
+ test_proxysql_query_rules_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_query_rule | test delete query rule"
+ import_tasks: test_delete_query_rule.yml
+ vars:
+ test_proxysql_query_rules_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_query_rule | test idempotence of delete query rule"
+ import_tasks: test_delete_query_rule.yml
+ vars:
+ test_proxysql_query_rules_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_query_rule_in_memory_only | test create query rule in memory"
+ import_tasks: test_create_query_rule_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_query_rule_in_memory_only | test idempotence of create query rule in memory"
+ import_tasks: test_create_query_rule_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_query_rule_in_memory_only | test delete query rule in memory"
+ import_tasks: test_delete_query_rule_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_query_rule_in_memory_only | test idempotence of delete query rule in memory"
+ import_tasks: test_delete_query_rule_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_query_rule_with_delayed_persist | test create query rule with delayed save to disk/load to runtime"
+ import_tasks: test_create_query_rule_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_with_delayed_persist: true
+ test_proxysql_query_rules_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_query_rule_with_delayed_persist | test idempotence of create query rule with delayed save to disk/load to runtime"
+ import_tasks: test_create_query_rule_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_with_delayed_persist: true
+ test_proxysql_query_rules_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_query_rule_with_delayed_persist | test delete query rule with delayed save to disk/load to runtime"
+ import_tasks: test_delete_query_rule_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_with_delayed_persist: true
+ test_proxysql_query_rules_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_query_rule_with_delayed_persist | test idempotence of delete query rule with delayed save to disk/load to runtime"
+ import_tasks: test_delete_query_rule_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_in_memory_only: true
+ test_proxysql_query_rules_with_delayed_persist: true
+ test_proxysql_query_rules_check_idempotence: true
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/setup_test_query_rule.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/setup_test_query_rule.yml
new file mode 100644
index 000000000..7638b914b
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/setup_test_query_rule.yml
@@ -0,0 +1,17 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test query rule is created when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule is created in memory proxysql >= 2"
+ when: PROXYSQL2
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO mysql_query_rules (username, match_pattern, destination_hostgroup, active, retries, cache_ttl, cache_empty_result, multiplex, next_query_flagIN) VALUES ('{{ test_user }}', '{{ test_match_pattern}}', '{{ test_destination_hostgroup }}', '{{ test_active }}', '{{ test_retries }}', '{{ test_cache_ttl }}', '{{ test_cache_empty_result }}', '{{ test_multiplex }}', '{{ test_next_query_flagin }}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule is created in memory proxysql < 2"
+ when: not PROXYSQL2
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO mysql_query_rules (username, match_pattern, destination_hostgroup, active, retries, cache_ttl, multiplex, next_query_flagIN) VALUES ('{{ test_user }}', '{{ test_match_pattern}}', '{{ test_destination_hostgroup }}', '{{ test_active }}', '{{ test_retries }}', '{{ test_cache_ttl }}', '{{ test_multiplex }}', '{{ test_next_query_flagin }}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule is created on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL QUERY RULES TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule is created in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL QUERY RULES TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule.yml
new file mode 100644
index 000000000..f1c9bfc15
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule.yml
@@ -0,0 +1,55 @@
+---
+- name: "{{ role_name }} | test_create_query_rule | set current test"
+ set_fact:
+ current_test: test_create_query_rule
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule reported a change"
+ assert:
+ that:
+ - "status1 is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change in memory"
+ assert:
+ that: memory_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change on disk"
+ assert:
+ that: disk_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change to runtime"
+ assert:
+ that: runtime_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
+ when: test_proxysql_query_rules_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_in_memory_only.yml
new file mode 100644
index 000000000..a09603508
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_in_memory_only.yml
@@ -0,0 +1,52 @@
+---
+- name: "{{ role_name }} | test_create_query_rule_in_memory_only | set current test"
+ set_fact:
+ current_test: test_create_query_rule_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule reported a change"
+ assert:
+ that:
+ - "status1 is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change in memory"
+ assert:
+ that: memory_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule didn't make a change on disk"
+ assert:
+ that: disk_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule didn't make a change to runtime"
+ assert:
+ that: runtime_result1.stdout|length == 0
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
+ when: test_proxysql_query_rules_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_with_delayed_persist.yml
new file mode 100644
index 000000000..2c5c7f940
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_query_rule_with_delayed_persist.yml
@@ -0,0 +1,54 @@
+---
+- name: "{{ role_name }} | test_create_query_rule_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_create_query_rule_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule reported a change"
+ assert:
+ that:
+ - "status1 is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change in memory"
+ assert:
+ that: memory_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change on disk"
+ assert:
+ that: disk_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule did make a change to runtime"
+ assert:
+ that: runtime_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
+ when: test_proxysql_query_rules_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_using_check_mode.yml
new file mode 100644
index 000000000..4cc47fd0c
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_create_using_check_mode.yml
@@ -0,0 +1,53 @@
+---
+- name: "{{ role_name }} | test_create_using_check_mode | set current test"
+ set_fact:
+ current_test: test_create_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+- name: test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if create query rule in check mode reported a change"
+ assert:
+ that:
+ - status1 is changed
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule in check mode didn't make a change in memory"
+ assert:
+ that: memory_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule in check mode didn't make a change on disk"
+ assert:
+ that: disk_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm create query rule in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result1.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule.yml
new file mode 100644
index 000000000..c563c867c
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule.yml
@@ -0,0 +1,53 @@
+---
+- name: "{{ role_name }} | test_delete_query_rule | set current test"
+ set_fact:
+ current_test: test_delete_query_rule
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule reported a change"
+ assert:
+ that:
+ - "status1 is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change in memory"
+ assert:
+ that: memory_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change on disk"
+ assert:
+ that: disk_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change to runtime"
+ assert:
+ that: runtime_result1.stdout|length == 0
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
+ when: test_proxysql_query_rules_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_in_memory_only.yml
new file mode 100644
index 000000000..a5f32dbe6
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_in_memory_only.yml
@@ -0,0 +1,54 @@
+---
+- name: "{{ role_name }} | test_delete_query_rule_in_memory_only | set current test"
+ set_fact:
+ current_test: test_delete_query_rule_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule reported a change"
+ assert:
+ that:
+ - "status1 is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule didn't make a change in memory"
+ assert:
+ that: memory_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change on disk"
+ assert:
+ that: disk_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change to runtime"
+ assert:
+ that: runtime_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
+ when: test_proxysql_query_rules_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_with_delayed_persist.yml
new file mode 100644
index 000000000..397d76d21
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_query_rule_with_delayed_persist.yml
@@ -0,0 +1,52 @@
+---
+- name: "{{ role_name }} | test_delete_query_rule_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_delete_query_rule_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule reported a change"
+ assert:
+ that:
+ - "status1 is {{ test_proxysql_query_rules_check_idempotence|ternary('not changed', 'changed') }}"
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change in memory"
+ assert:
+ that: memory_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change on disk"
+ assert:
+ that: disk_result1.stdout|length == 0
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule did make a change to runtime"
+ assert:
+ that: runtime_result1.stdout|length == 0
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
+ when: test_proxysql_query_rules_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_using_check_mode.yml
new file mode 100644
index 000000000..17b8f2cb7
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules/tasks/test_delete_using_check_mode.yml
@@ -0,0 +1,53 @@
+---
+- name: "{{ role_name }} | test_delete_using_check_mode | set current test"
+ set_fact:
+ current_test: test_delete_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: verify test against proxysql >= 2
+ when: PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_cache_empty_result }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+- name: verify test against proxysql < 2
+ when: not PROXYSQL2
+ block:
+ - name: "{{ role_name }} | {{ current_test }} | check if delete query rule in check mode reported a change"
+ assert:
+ that:
+ - status1 is changed
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule in check mode didn't make a change in memory"
+ assert:
+ that: memory_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule in check mode didn't make a change on disk"
+ assert:
+ that: disk_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+ - name: "{{ role_name }} | {{ current_test }} | confirm delete query rule in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result1.stdout == '{{ test_user }},{{ test_match_pattern }},{{ test_destination_hostgroup }},{{ test_active }},{{ test_retries }},{{ test_cache_ttl }},{{ test_multiplex }},{{ test_next_query_flagin }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/defaults/main.yml
new file mode 100644
index 000000000..f1eca2892
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/defaults/main.yml
@@ -0,0 +1,12 @@
+---
+test_user: 'user_ro'
+test_schema: 'default'
+test_flagin: 0
+test_destination_hostgroup: 1
+test_comment: 'testing fast route'
+
+test_proxysql_query_rules_fast_routing_check_mode: false
+test_proxysql_query_rules_fast_routing_in_memory_only: false
+test_proxysql_query_rules_fast_routing_with_delayed_persist: false
+test_proxysql_query_rules_fast_routing_check_idempotence: false
+test_proxysql_query_rules_fast_routing_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/107-update_destination_hostgroup.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/107-update_destination_hostgroup.yml
new file mode 100644
index 000000000..775e83d0a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/107-update_destination_hostgroup.yml
@@ -0,0 +1,61 @@
+- name: Create fast routing rules
+ community.proxysql.proxysql_query_rules_fast_routing:
+ # rule args
+ username: user
+ schemaname: test_database
+ destination_hostgroup: 1
+ # auth args
+ login_user: admin
+ login_password: admin
+ state: present
+ register: out
+
+- debug:
+ var: out
+
+- name: verify create
+ assert:
+ that:
+ - out is changed
+ - out.rules[0].destination_hostgroup == "1"
+
+- name: Update destination hostgroup of previous fast routing rule
+ community.proxysql.proxysql_query_rules_fast_routing:
+ # rule args
+ username: user
+ schemaname: test_database
+ destination_hostgroup: 2
+ # auth args
+ login_user: admin
+ login_password: admin
+ state: present
+ register: out
+
+- debug:
+ var: out
+
+- name: verify change
+ assert:
+ that:
+ - out is changed
+ - out.rules[0].destination_hostgroup == "2"
+
+- name: Update destination hostgroup of previous fast routing rule (idempotent)
+ community.proxysql.proxysql_query_rules_fast_routing:
+ # rule args
+ username: user
+ schemaname: test_database
+ destination_hostgroup: 2
+ # auth args
+ login_user: admin
+ login_password: admin
+ state: present
+ register: out
+
+- debug:
+ var: out
+
+- name: verify no change
+ assert:
+ that:
+ - out is not changed \ No newline at end of file
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/base_test.yml
new file mode 100644
index 000000000..b63cd3fdf
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/base_test.yml
@@ -0,0 +1,61 @@
+---
+### prepare
+- name: "{{ role_name }} | {{ current_test }} | are we performing a delete"
+ set_fact:
+ test_delete: "{{ current_test | regex_search('^test_delete') | ternary(true, false) }}"
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: "{{ test_delete|ternary('setup_test_query_rules_fast_routing', 'cleanup_test_query_rules_fast_routing') }}.yml"
+ when: not test_proxysql_query_rules_fast_routing_check_idempotence
+
+### when
+
+- name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test query rules fast routing"
+ community.proxysql.proxysql_query_rules_fast_routing:
+ login_user: admin
+ login_password: admin
+ username: '{{ test_user }}'
+ destination_hostgroup: '{{ test_destination_hostgroup }}'
+ schemaname: '{{ test_schema }}'
+ flagIN: '{{ test_flagin }}'
+ comment: '{{ test_comment }}'
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_query_rules_fast_routing_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_query_rules_fast_routing_in_memory_only }}"
+ check_mode: "{{ test_proxysql_query_rules_fast_routing_check_mode }}"
+ register: status
+
+- name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the query rules fast routing config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL QUERY RULES
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the query rules fast routing config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL QUERY RULES
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_query_rules_fast_routing_with_delayed_persist
+
+- name: "{{ role_name }} | {{ current_test }} | check if test query rule fast routing exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || schemaname || ',' || destination_hostgroup || ',' || flagIN || ',' || comment FROM mysql_query_rules_fast_routing where username = '{{ test_user }}' and schemaname = '{{ test_schema }}' and destination_hostgroup = '{{ test_destination_hostgroup }}' and flagIN = '{{ test_flagin }}' and comment = '{{ test_comment }}'"
+ register: memory_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test query rule fast routing exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || schemaname || ',' || destination_hostgroup || ',' || flagIN || ',' || comment FROM disk.mysql_query_rules_fast_routing where username = '{{ test_user }}' and schemaname = '{{ test_schema }}' and destination_hostgroup = '{{ test_destination_hostgroup }}' and flagIN = '{{ test_flagin }}' and comment = '{{ test_comment }}'"
+ register: disk_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test query rule fast routing exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT username || ',' || schemaname || ',' || destination_hostgroup || ',' || flagIN || ',' || comment FROM runtime_mysql_query_rules_fast_routing where username = '{{ test_user }}' and schemaname = '{{ test_schema }}' and destination_hostgroup = '{{ test_destination_hostgroup }}' and flagIN = '{{ test_flagin }}' and comment = '{{ test_comment }}'"
+ register: runtime_result
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/cleanup_test_query_rules_fast_routing.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/cleanup_test_query_rules_fast_routing.yml
new file mode 100644
index 000000000..aeb5d9415
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/cleanup_test_query_rules_fast_routing.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no query rules fast routing are created"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"DELETE FROM mysql_query_rules_fast_routing"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no query rules fast routing are saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL QUERY RULES TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no query rules fast routing are loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL QUERY RULES TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/main.yml
new file mode 100644
index 000000000..bdd7a754e
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/main.yml
@@ -0,0 +1,93 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+### tests
+
+- name: "{{ role_name }} | test_create_using_check_mode | test create query rule fast routing using check mode"
+ import_tasks: test_create_using_check_mode.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_check_mode: true
+
+- name: "{{ role_name }} | test_delete_using_check_mode | test delete query rule fast routing using check mode"
+ import_tasks: test_delete_using_check_mode.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_check_mode: true
+
+- name: "{{ role_name }} | test_create_query_rule_fast_routing | test create query rule fast routing"
+ import_tasks: test_create_query_rule_fast_routing.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_query_rule_fast_routing | test idempotence of create query rule fast routing"
+ import_tasks: test_create_query_rule_fast_routing.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing | test delete query rule fast routing"
+ import_tasks: test_delete_query_rule_fast_routing.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing | test idempotence of delete query rule fast routing"
+ import_tasks: test_delete_query_rule_fast_routing.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_query_rule_fast_routing_in_memory_only | test create query rule fast routing in memory"
+ import_tasks: test_create_query_rule_fast_routing_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_query_rule_fast_routing_in_memory_only | test idempotence of create query rule fast routing in memory"
+ import_tasks: test_create_query_rule_fast_routing_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing_in_memory_only | test delete query rule fast routing in memory"
+ import_tasks: test_delete_query_rule_fast_routing_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing_in_memory_only | test idempotence of delete query rule fast routing in memory"
+ import_tasks: test_delete_query_rule_fast_routing_in_memory_only.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_query_rule_fast_routing_with_delayed_persist | test create query rule fast routing with delayed save to disk/load to runtime"
+ import_tasks: test_create_query_rule_fast_routing_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_with_delayed_persist: true
+ test_proxysql_query_rules_fast_routing_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_query_rule_fast_routing__with_delayed_persist | test idempotence of create query rule fast routing with delayed save to disk/load to runtime"
+ import_tasks: test_create_query_rule_fast_routing_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_with_delayed_persist: true
+ test_proxysql_query_rules_fast_routing_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing__with_delayed_persist | test delete query rule fast routing with delayed save to disk/load to runtime"
+ import_tasks: test_delete_query_rule_fast_routing_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_with_delayed_persist: true
+ test_proxysql_query_rules_fast_routing_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing_with_delayed_persist | test idempotence of delete query rule fast routing with delayed save to disk/load to runtime"
+ import_tasks: test_delete_query_rule_fast_routing_with_delayed_persist.yml
+ vars:
+ test_proxysql_query_rules_fast_routing_in_memory_only: true
+ test_proxysql_query_rules_fast_routing_with_delayed_persist: true
+ test_proxysql_query_rules_fast_routing_check_idempotence: true
+
+
+### other checks
+- name: test change destination hostgroup
+ include_tasks: 107-update_destination_hostgroup.yml
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/setup_test_query_rules_fast_routing.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/setup_test_query_rules_fast_routing.yml
new file mode 100644
index 000000000..ae8267e46
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/setup_test_query_rules_fast_routing.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test query rule fast routing is created when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule fast routing is created in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO mysql_query_rules_fast_routing (username, schemaname, destination_hostgroup, flagIN, comment) VALUES ('{{ test_user }}', '{{ test_schema }}', '{{ test_destination_hostgroup }}', '{{ test_flagin }}', '{{ test_comment }}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule fast routing is created on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL QUERY RULES TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test query rule fast routing is created in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL QUERY RULES TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing.yml
new file mode 100644
index 000000000..8f941b48f
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_query_rule_fast_routing | set current test"
+ set_fact:
+ current_test: test_create_query_rule_fast_routing
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create query rule fast routing reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_fast_routing_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
+ when: test_proxysql_query_rules_fast_routing_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_in_memory_only.yml
new file mode 100644
index 000000000..25ebfa3c1
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_query_rule_fast_routing_in_memory_only | set current test"
+ set_fact:
+ current_test: test_create_query_rule_fast_routing_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create query rule fast routing reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_fast_routing_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
+ when: test_proxysql_query_rules_fast_routing_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_with_delayed_persist.yml
new file mode 100644
index 000000000..ba11ceb5e
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_query_rule_fast_routing_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_query_rule_fast_routing_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_create_query_rule_fast_routing_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create query rule fast routing reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_fast_routing_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
+ when: test_proxysql_query_rules_fast_routing_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_using_check_mode.yml
new file mode 100644
index 000000000..e4f8c42e5
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_create_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_create_using_check_mode | set current test"
+ set_fact:
+ current_test: test_create_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create query rule fast routing in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create query rule fast routing in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing.yml
new file mode 100644
index 000000000..515fbe629
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing | set current test"
+ set_fact:
+ current_test: test_delete_query_rule_fast_routing
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete query rule fast routing reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_fast_routing_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
+ when: test_proxysql_query_rules_fast_routing_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_in_memory_only.yml
new file mode 100644
index 000000000..028bbac71
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_in_memory_only.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing_in_memory_only | set current test"
+ set_fact:
+ current_test: test_delete_query_rule_fast_routing_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete query rule fast routing reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_fast_routing_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing fast routing did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
+ when: test_proxysql_query_rules_fast_routing_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_with_delayed_persist.yml
new file mode 100644
index 000000000..a3ff67661
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_query_rule_fast_routing_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_query_rule_fast_routing_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_delete_query_rule_fast_routing_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete query rule fast routing reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_query_rules_fast_routing_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
+ when: test_proxysql_query_rules_fast_routing_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_using_check_mode.yml
new file mode 100644
index 000000000..58c576b5e
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_query_rules_fast_routing/tasks/test_delete_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_using_check_mode | set current test"
+ set_fact:
+ current_test: test_delete_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete query rule fast routing in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete query rule fast routing in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_user }},{{ test_schema }},{{ test_destination_hostgroup }},{{ test_flagin }},{{ test_comment }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_query_rules_fast_routing.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/defaults/main.yml
new file mode 100644
index 000000000..4e381d458
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/defaults/main.yml
@@ -0,0 +1,9 @@
+---
+test_writer_hostgroup: 1
+test_reader_hostgroup: 2
+
+test_proxysql_replication_hostgroups_check_mode: false
+test_proxysql_replication_hostgroups_in_memory_only: false
+test_proxysql_replication_hostgroups_with_delayed_persist: false
+test_proxysql_replication_hostgroups_check_idempotence: false
+test_proxysql_replication_hostgroups_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/base_test.yml
new file mode 100644
index 000000000..466a7c6b4
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/base_test.yml
@@ -0,0 +1,58 @@
+---
+### prepare
+- name: "{{ role_name }} | {{ current_test }} | are we performing a delete"
+ set_fact:
+ test_delete: "{{ current_test | regex_search('^test_delete') | ternary(true, false) }}"
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: "{{ test_delete|ternary('setup_test_replication_hostgroups', 'cleanup_test_replication_hostgroups') }}.yml"
+ when: not test_proxysql_replication_hostgroups_check_idempotence
+
+### when
+
+- name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test mysql replication hostgroup"
+ proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: '{{ test_writer_hostgroup }}'
+ reader_hostgroup: '{{ test_reader_hostgroup }}'
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_replication_hostgroups_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_replication_hostgroups_in_memory_only }}"
+ check_mode: "{{ test_proxysql_replication_hostgroups_check_mode }}"
+ register: status
+
+- name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the replication hostgroups config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: MYSQL SERVERS
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the replication hostgroups config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: MYSQL SERVERS
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_replication_hostgroups_with_delayed_persist
+
+- name: "{{ role_name }} | {{ current_test }} | check if test replication hostgroups exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT writer_hostgroup || ',' || reader_hostgroup FROM mysql_replication_hostgroups where writer_hostgroup = '{{ test_writer_hostgroup }}' and reader_hostgroup = '{{ test_reader_hostgroup }}'"
+ register: memory_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test replication hostgroups exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT writer_hostgroup || ',' || reader_hostgroup FROM disk.mysql_replication_hostgroups where writer_hostgroup = '{{ test_writer_hostgroup }}' and reader_hostgroup = '{{ test_reader_hostgroup }}'"
+ register: disk_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test replication hostgroups exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT writer_hostgroup || ',' || reader_hostgroup FROM runtime_mysql_replication_hostgroups where writer_hostgroup = '{{ test_writer_hostgroup }}' and reader_hostgroup = '{{ test_reader_hostgroup }}'"
+ register: runtime_result
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/cleanup_test_replication_hostgroups.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/cleanup_test_replication_hostgroups.yml
new file mode 100644
index 000000000..d32262a3a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/cleanup_test_replication_hostgroups.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no replication hostgroups are created"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"DELETE FROM mysql_replication_hostgroups"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no replication hostgroups are saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL SERVERS TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no replication hostgroups are loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL SERVERS TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/main.yml
new file mode 100644
index 000000000..b7510e2e7
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/main.yml
@@ -0,0 +1,220 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+### tests
+
+- name: "{{ role_name }} | test_create_using_check_mode | test create replication hostgroups using check mode"
+ import_tasks: test_create_using_check_mode.yml
+ vars:
+ test_proxysql_replication_hostgroups_check_mode: true
+
+- name: "{{ role_name }} | test_delete_using_check_mode | test delete replication hostgroups using check mode"
+ import_tasks: test_delete_using_check_mode.yml
+ vars:
+ test_proxysql_replication_hostgroups_check_mode: true
+
+- name: "{{ role_name }} | test_create_replication_hostgroups | test create replication hostgroups"
+ import_tasks: test_create_replication_hostgroups.yml
+ vars:
+ test_proxysql_replication_hostgroups_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_replication_hostgroups | test idempotence of create replication hostgroups"
+ import_tasks: test_create_replication_hostgroups.yml
+ vars:
+ test_proxysql_replication_hostgroups_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_replication_hostgroups | test delete replication hostgroups"
+ import_tasks: test_delete_replication_hostgroups.yml
+ vars:
+ test_proxysql_replication_hostgroups_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_replication_hostgroups | test idempotence of delete replication hostgroups"
+ import_tasks: test_delete_replication_hostgroups.yml
+ vars:
+ test_proxysql_replication_hostgroups_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_replication_hostgroups_in_memory_only | test create replication hostgroups in memory"
+ import_tasks: test_create_replication_hostgroups_in_memory_only.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_replication_hostgroups_in_memory_only | test idempotence of create replication hostgroups in memory"
+ import_tasks: test_create_replication_hostgroups_in_memory_only.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_replication_hostgroups_in_memory_only | test delete replication hostgroups in memory"
+ import_tasks: test_delete_replication_hostgroups_in_memory_only.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_replication_hostgroups_in_memory_only | test idempotence of delete replication hostgroups in memory"
+ import_tasks: test_delete_replication_hostgroups_in_memory_only.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_replication_hostgroups_with_delayed_persist | test create replication hostgroups with delayed save to disk/load to runtime"
+ import_tasks: test_create_replication_hostgroups_with_delayed_persist.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_with_delayed_persist: true
+ test_proxysql_replication_hostgroups_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_replication_hostgroups_with_delayed_persist | test idempotence of create replication hostgroups with delayed save to disk/load to runtime"
+ import_tasks: test_create_replication_hostgroups_with_delayed_persist.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_with_delayed_persist: true
+ test_proxysql_replication_hostgroups_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_replication_hostgroups_with_delayed_persist | test delete replication hostgroups with delayed save to disk/load to runtime"
+ import_tasks: test_delete_replication_hostgroups_with_delayed_persist.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_with_delayed_persist: true
+ test_proxysql_replication_hostgroups_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_replication_hostgroups_with_delayed_persist | test idempotence of delete replication hostgroups with delayed save to disk/load to runtime"
+ import_tasks: test_delete_replication_hostgroups_with_delayed_persist.yml
+ vars:
+ test_proxysql_replication_hostgroups_in_memory_only: true
+ test_proxysql_replication_hostgroups_with_delayed_persist: true
+ test_proxysql_replication_hostgroups_check_idempotence: true
+
+- name: "gather proxysql informations"
+ community.proxysql.proxysql_info:
+ login_user: admin
+ login_password: admin
+ register: proxysql_information
+
+- name: create replication hostgroup
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 200
+ register: special_condition
+
+- name: verify change
+ assert:
+ that:
+ - special_condition is changed
+
+- name: >
+ test conditions that are failing in the past
+ block:
+ - name: change reader hostgroup
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 300
+ register: special_condition
+
+ - name: verify change
+ assert:
+ that:
+ - special_condition is changed
+
+ - name: update check_type (check_mode)
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 300
+ check_type: innodb_read_only
+ register: special_condition
+ check_mode: true
+
+ - name: verify check_mode - change for proxysql > 2
+ when: proxysql_information.version.major >= 2
+ assert:
+ that:
+ - special_condition is changed
+
+ - name: verify check_mode - no change for proxysql < 2
+ when: proxysql_information.version.major < 2
+ assert:
+ that:
+ - special_condition is not changed
+
+ - name: update check_type
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 300
+ check_type: innodb_read_only
+ register: special_condition
+
+ - name: verify - change for proxysql >= 2
+ when: proxysql_information.version.major >= 2
+ assert:
+ that:
+ - special_condition is changed
+
+ - name: verify - no change for proxysql < 2
+ when: proxysql_information.version.major < 2
+ assert:
+ that:
+ - special_condition is not changed
+
+ - name: update check_type (idempotent)
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 300
+ check_type: innodb_read_only
+ register: special_condition
+
+ - name: verify idempotent - change for proxysql >= 2
+ when: proxysql_information.version.major >= 2
+ assert:
+ that:
+ - special_condition is not changed
+
+ - name: verify idempotent - no change for proxysql < 2
+ when: proxysql_information.version.major < 2
+ assert:
+ that:
+ - special_condition is not changed
+
+- name: >
+ test reader hostgroup become 0
+ when testing against proxysql >= 2.0.0
+ when: proxysql_information.version.major >= 2
+ block:
+ - name: set reader hostgroup to 0
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 0
+ check_type: innodb_read_only
+ register: special_condition
+
+ - name: verify change
+ assert:
+ that:
+ - special_condition is changed
+
+ - name: set reader hostgroup to 0 (immutable)
+ community.proxysql.proxysql_replication_hostgroups:
+ login_user: admin
+ login_password: admin
+ writer_hostgroup: 100
+ reader_hostgroup: 0
+ check_type: innodb_read_only
+ register: special_condition
+
+ - name: verify change
+ assert:
+ that:
+ - special_condition is not changed
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/setup_test_replication_hostgroups.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/setup_test_replication_hostgroups.yml
new file mode 100644
index 000000000..03f759dcc
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/setup_test_replication_hostgroups.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test replication hostgroups is created when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test replication hostgroups is created in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO mysql_replication_hostgroups (writer_hostgroup, reader_hostgroup) VALUES ('{{ test_writer_hostgroup }}', '{{ test_reader_hostgroup}}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test replication hostgroups is created on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE MYSQL SERVERS TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test replication hostgroups is created in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD MYSQL SERVERS TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups.yml
new file mode 100644
index 000000000..43bfb9d7a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_replication_hostgroups | set current test"
+ set_fact:
+ current_test: test_create_replication_hostgroups
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create replication hostgroups reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_replication_hostgroups_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
+ when: test_proxysql_replication_hostgroups_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_in_memory_only.yml
new file mode 100644
index 000000000..66d26c32a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_replication_hostgroups_in_memory_only | set current test"
+ set_fact:
+ current_test: test_create_replication_hostgroups_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create replication hostgroups reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_replication_hostgroups_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
+ when: test_proxysql_replication_hostgroups_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_with_delayed_persist.yml
new file mode 100644
index 000000000..cd649a519
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_replication_hostgroups_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_replication_hostgroups_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_create_replication_hostgroups_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create replication hostgroups reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_replication_hostgroups_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
+ when: test_proxysql_replication_hostgroups_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_using_check_mode.yml
new file mode 100644
index 000000000..b9a2fb2fb
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_create_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_create_using_check_mode | set current test"
+ set_fact:
+ current_test: test_create_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create replication hostgroups in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create replication hostgroups in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups.yml
new file mode 100644
index 000000000..ad3a189f6
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_replication_hostgroups | set current test"
+ set_fact:
+ current_test: test_delete_replication_hostgroups
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete replication hostgroups reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_replication_hostgroups_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
+ when: test_proxysql_replication_hostgroups_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_in_memory_only.yml
new file mode 100644
index 000000000..edd089ac4
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_in_memory_only.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_replication_hostgroups_in_memory_only | set current test"
+ set_fact:
+ current_test: test_delete_replication_hostgroups_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete replication hostgroups reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_replication_hostgroups_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
+ when: test_proxysql_replication_hostgroups_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_with_delayed_persist.yml
new file mode 100644
index 000000000..03a198892
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_replication_hostgroups_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_replication_hostgroups_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_delete_replication_hostgroups_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete replication hostgroups reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_replication_hostgroups_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
+ when: test_proxysql_replication_hostgroups_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_using_check_mode.yml
new file mode 100644
index 000000000..1fb587925
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_replication_hostgroups/tasks/test_delete_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_using_check_mode | set current test"
+ set_fact:
+ current_test: test_delete_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete replication hostgroups in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete replication hostgroups in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_writer_hostgroup }},{{ test_reader_hostgroup }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_replication_hostgroups.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/defaults/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/defaults/main.yml
new file mode 100644
index 000000000..d7c007433
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/defaults/main.yml
@@ -0,0 +1,9 @@
+---
+test_interval_ms: 1000
+test_filename: '/opt/maintenance.py'
+
+test_proxysql_scheduler_check_mode: false
+test_proxysql_scheduler_in_memory_only: false
+test_proxysql_scheduler_with_delayed_persist: false
+test_proxysql_scheduler_check_idempotence: false
+test_proxysql_scheduler_cleanup_after_test: true
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/meta/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/meta/main.yml
new file mode 100644
index 000000000..2023b8da8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_proxysql
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/base_test.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/base_test.yml
new file mode 100644
index 000000000..e1abf853f
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/base_test.yml
@@ -0,0 +1,58 @@
+---
+### prepare
+- name: "{{ role_name }} | {{ current_test }} | are we performing a delete"
+ set_fact:
+ test_delete: "{{ current_test | regex_search('^test_delete') | ternary(true, false) }}"
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start"
+ include_tasks: "{{ test_delete|ternary('setup_test_scheduler', 'cleanup_test_schedulers') }}.yml"
+ when: not test_proxysql_scheduler_check_idempotence
+
+### when
+
+- name: "{{ role_name }} | {{ current_test }} | {{ test_delete|ternary('delete','create') }} test scheduler"
+ proxysql_scheduler:
+ login_user: admin
+ login_password: admin
+ interval_ms: '{{ test_interval_ms }}'
+ filename: '{{ test_filename }}'
+ state: "{{ test_delete|ternary('absent', 'present') }}"
+ save_to_disk: "{{ not test_proxysql_scheduler_in_memory_only }}"
+ load_to_runtime: "{{ not test_proxysql_scheduler_in_memory_only }}"
+ check_mode: "{{ test_proxysql_scheduler_check_mode }}"
+ register: status
+
+- name: "{{ role_name }} | {{ current_test }} | persist the changes to disk, and load to runtime"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | save the scheduler config from memory to disk"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: SAVE
+ config_settings: SCHEDULER
+ direction: TO
+ config_layer: DISK
+
+ - name: "{{ role_name }} | {{ current_test }} | load the scheduler config from memory to runtime"
+ proxysql_manage_config:
+ login_user: admin
+ login_password: admin
+ action: LOAD
+ config_settings: SCHEDULER
+ direction: TO
+ config_layer: RUNTIME
+
+ when: test_proxysql_scheduler_with_delayed_persist
+
+- name: "{{ role_name }} | {{ current_test }} | check if test scheduler exists in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT interval_ms || ',' || filename FROM scheduler where interval_ms = '{{ test_interval_ms }}' and filename = '{{ test_filename }}'"
+ register: memory_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test scheduler exists on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT interval_ms || ',' || filename FROM disk.scheduler where interval_ms = '{{ test_interval_ms }}' and filename = '{{ test_filename }}'"
+ register: disk_result
+
+- name: "{{ role_name }} | {{ current_test }} | check if test scheduler exists in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SELECT interval_ms || ',' || filename FROM runtime_scheduler where interval_ms = '{{ test_interval_ms }}' and filename = '{{ test_filename }}'"
+ register: runtime_result
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/cleanup_test_schedulers.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/cleanup_test_schedulers.yml
new file mode 100644
index 000000000..396ab8366
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/cleanup_test_schedulers.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we start/finish"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no schedulers are created"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"DELETE FROM scheduler"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no schedulers are saved on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE SCHEDULER TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure no schedulers are loaded to runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD SCHEDULER TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/main.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/main.yml
new file mode 100644
index 000000000..d135e1edd
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/main.yml
@@ -0,0 +1,88 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+### tests
+
+- name: "{{ role_name }} | test_create_using_check_mode | test create scheduler using check mode"
+ import_tasks: test_create_using_check_mode.yml
+ vars:
+ test_proxysql_scheduler_check_mode: true
+
+- name: "{{ role_name }} | test_delete_using_check_mode | test delete scheduler using check mode"
+ import_tasks: test_delete_using_check_mode.yml
+ vars:
+ test_proxysql_scheduler_check_mode: true
+
+- name: "{{ role_name }} | test_create_scheduler | test create scheduler"
+ import_tasks: test_create_scheduler.yml
+ vars:
+ test_proxysql_scheduler_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_scheduler | test idempotence of create scheduler"
+ import_tasks: test_create_scheduler.yml
+ vars:
+ test_proxysql_scheduler_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_scheduler | test delete scheduler"
+ import_tasks: test_delete_scheduler.yml
+ vars:
+ test_proxysql_scheduler_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_scheduler | test idempotence of delete scheduler"
+ import_tasks: test_delete_scheduler.yml
+ vars:
+ test_proxysql_scheduler_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_scheduler_in_memory_only | test create scheduler in memory"
+ import_tasks: test_create_scheduler_in_memory_only.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_scheduler_in_memory_only | test idempotence of create scheduler in memory"
+ import_tasks: test_create_scheduler_in_memory_only.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_scheduler_in_memory_only | test delete scheduler in memory"
+ import_tasks: test_delete_scheduler_in_memory_only.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_scheduler_in_memory_only | test idempotence of delete scheduler in memory"
+ import_tasks: test_delete_scheduler_in_memory_only.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_check_idempotence: true
+
+- name: "{{ role_name }} | test_create_scheduler_with_delayed_persist | test create scheduler with delayed save to disk/load to runtime"
+ import_tasks: test_create_scheduler_with_delayed_persist.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_with_delayed_persist: true
+ test_proxysql_scheduler_cleanup_after_test: false
+- name: "{{ role_name }} | test_create_scheduler_with_delayed_persist | test idempotence of create scheduler with delayed save to disk/load to runtime"
+ import_tasks: test_create_scheduler_with_delayed_persist.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_with_delayed_persist: true
+ test_proxysql_scheduler_check_idempotence: true
+
+- name: "{{ role_name }} | test_delete_scheduler_with_delayed_persist | test delete scheduler with delayed save to disk/load to runtime"
+ import_tasks: test_delete_scheduler_with_delayed_persist.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_with_delayed_persist: true
+ test_proxysql_scheduler_cleanup_after_test: false
+- name: "{{ role_name }} | test_delete_scheduler_with_delayed_persist | test idempotence of delete scheduler with delayed save to disk/load to runtime"
+ import_tasks: test_delete_scheduler_with_delayed_persist.yml
+ vars:
+ test_proxysql_scheduler_in_memory_only: true
+ test_proxysql_scheduler_with_delayed_persist: true
+ test_proxysql_scheduler_check_idempotence: true
+
+### teardown
+
+- name: "{{ role_name }} | teardown | perform teardown"
+ import_tasks: teardown.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/setup_test_scheduler.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/setup_test_scheduler.yml
new file mode 100644
index 000000000..da12b2555
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/setup_test_scheduler.yml
@@ -0,0 +1,12 @@
+---
+- name: "{{ role_name }} | {{ current_test }} | ensure test scheduler is created when we start"
+ block:
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test scheduler is created in memory"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"INSERT OR REPLACE INTO scheduler (interval_ms, filename) VALUES ('{{ test_interval_ms }}', '{{ test_filename}}')"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test scheduler is created on disk"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"SAVE SCHEDULER TO DISK"
+
+ - name: "{{ role_name }} | {{ current_test }} | ensure test scheduler is created in runtime"
+ shell: mysql -uadmin -padmin -h127.0.0.1 -P6032 -BNe"LOAD SCHEDULER TO RUNTIME"
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/teardown.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/teardown.yml
new file mode 100644
index 000000000..0cb5ae1ec
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- name: "{{ role_name }} | teardown | uninstall proxysql"
+ apt:
+ name: proxysql
+ purge: true
+ state: absent
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler.yml
new file mode 100644
index 000000000..e290d266c
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_scheduler | set current test"
+ set_fact:
+ current_test: test_create_scheduler
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create scheduler reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_scheduler_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
+ when: test_proxysql_scheduler_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_in_memory_only.yml
new file mode 100644
index 000000000..d03cb77f4
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_in_memory_only.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_scheduler_in_memory_only | set current test"
+ set_fact:
+ current_test: test_create_scheduler_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create scheduler reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_scheduler_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
+ when: test_proxysql_scheduler_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_with_delayed_persist.yml
new file mode 100644
index 000000000..ba7eec57a
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_scheduler_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_create_scheduler_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_create_scheduler_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create scheduler reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_scheduler_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
+ when: test_proxysql_scheduler_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_using_check_mode.yml
new file mode 100644
index 000000000..bbb5de4d5
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_create_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_create_using_check_mode | set current test"
+ set_fact:
+ current_test: test_create_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if create scheduler in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm create scheduler in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler.yml
new file mode 100644
index 000000000..b136fec01
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_scheduler | set current test"
+ set_fact:
+ current_test: test_delete_scheduler
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete scheduler reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_scheduler_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
+ when: test_proxysql_scheduler_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_in_memory_only.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_in_memory_only.yml
new file mode 100644
index 000000000..50c58e1aa
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_in_memory_only.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_scheduler_in_memory_only | set current test"
+ set_fact:
+ current_test: test_delete_scheduler_in_memory_only
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete scheduler reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_scheduler_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler didn't make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
+ when: test_proxysql_scheduler_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_with_delayed_persist.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_with_delayed_persist.yml
new file mode 100644
index 000000000..bdea20cdc
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_scheduler_with_delayed_persist.yml
@@ -0,0 +1,31 @@
+---
+- name: "{{ role_name }} | test_delete_scheduler_with_delayed_persist | set current test"
+ set_fact:
+ current_test: test_delete_scheduler_with_delayed_persist
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete scheduler reported a change"
+ assert:
+ that:
+ - "status is {{ test_proxysql_scheduler_check_idempotence|ternary('not changed', 'changed') }}"
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change in memory"
+ assert:
+ that: memory_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change on disk"
+ assert:
+ that: disk_result.stdout|length == 0
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler did make a change to runtime"
+ assert:
+ that: runtime_result.stdout|length == 0
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
+ when: test_proxysql_scheduler_cleanup_after_test
diff --git a/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_using_check_mode.yml b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_using_check_mode.yml
new file mode 100644
index 000000000..96e5133f8
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/integration/targets/test_proxysql_scheduler/tasks/test_delete_using_check_mode.yml
@@ -0,0 +1,30 @@
+---
+- name: "{{ role_name }} | test_delete_using_check_mode | set current test"
+ set_fact:
+ current_test: test_delete_using_check_mode
+
+- include_tasks: base_test.yml
+
+### then
+
+- name: "{{ role_name }} | {{ current_test }} | check if delete scheduler in check mode reported a change"
+ assert:
+ that:
+ - status is changed
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler in check mode didn't make a change in memory"
+ assert:
+ that: memory_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler in check mode didn't make a change on disk"
+ assert:
+ that: disk_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+- name: "{{ role_name }} | {{ current_test }} | confirm delete scheduler in check mode didn't make a change to runtime"
+ assert:
+ that: runtime_result.stdout == '{{ test_interval_ms }},{{ test_filename }}'
+
+### perform cleanup
+
+- name: "{{ role_name }} | {{ current_test }} | ensure we're in a clean state when we finish"
+ import_tasks: cleanup_test_schedulers.yml
diff --git a/ansible_collections/community/proxysql/tests/sanity/ignore-2.10.txt b/ansible_collections/community/proxysql/tests/sanity/ignore-2.10.txt
new file mode 100644
index 000000000..4b958cf06
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/sanity/ignore-2.10.txt
@@ -0,0 +1,2 @@
+roles/proxysql/molecule/default/tests/test_default.py future-import-boilerplate
+roles/proxysql/molecule/default/tests/test_default.py metaclass-boilerplate
diff --git a/ansible_collections/community/proxysql/tests/sanity/ignore-2.11.txt b/ansible_collections/community/proxysql/tests/sanity/ignore-2.11.txt
new file mode 100644
index 000000000..4b958cf06
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/sanity/ignore-2.11.txt
@@ -0,0 +1,2 @@
+roles/proxysql/molecule/default/tests/test_default.py future-import-boilerplate
+roles/proxysql/molecule/default/tests/test_default.py metaclass-boilerplate
diff --git a/ansible_collections/community/proxysql/tests/sanity/ignore-2.9.txt b/ansible_collections/community/proxysql/tests/sanity/ignore-2.9.txt
new file mode 100644
index 000000000..4b958cf06
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/sanity/ignore-2.9.txt
@@ -0,0 +1,2 @@
+roles/proxysql/molecule/default/tests/test_default.py future-import-boilerplate
+roles/proxysql/molecule/default/tests/test_default.py metaclass-boilerplate
diff --git a/ansible_collections/community/proxysql/tests/sanity/skip-2.12.txt b/ansible_collections/community/proxysql/tests/sanity/skip-2.12.txt
new file mode 100644
index 000000000..4b958cf06
--- /dev/null
+++ b/ansible_collections/community/proxysql/tests/sanity/skip-2.12.txt
@@ -0,0 +1,2 @@
+roles/proxysql/molecule/default/tests/test_default.py future-import-boilerplate
+roles/proxysql/molecule/default/tests/test_default.py metaclass-boilerplate