From ad55918eaf34ecf250b13047281ff370c8c00a4e Mon Sep 17 00:00:00 2001 From: Jorge-Rodriguez Date: Wed, 30 Sep 2020 13:31:14 +0300 Subject: [PATCH] Fix issue with mysqldb silently failing to update out of range variables --- .../tasks/mysql_variables.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/test_mysql_variables/tasks/mysql_variables.yml b/tests/integration/targets/test_mysql_variables/tasks/mysql_variables.yml index 2473327..b2b0cd3 100644 --- a/tests/integration/targets/test_mysql_variables/tasks/mysql_variables.yml +++ b/tests/integration/targets/test_mysql_variables/tasks/mysql_variables.yml @@ -141,7 +141,7 @@ - name: set mysql variable value to an expression mysql_variables: <<: *mysql_params - variable: max_tmp_tables + variable: max_connect_errors value: "1024*4" register: result ignore_errors: true @@ -151,15 +151,22 @@ # ============================================================ # Verify mysql_variable fails when setting an incorrect value (out of range) # + - shell: pip show pymysql | awk '/Version/ {print $2}' + register: pymysql_version + - name: set mysql variable value to a number out of range mysql_variables: <<: *mysql_params - variable: max_tmp_tables + variable: max_connect_errors value: -1 register: result ignore_errors: true + - include: assert_var.yml changed=true output={{ result }} var_name=max_connect_errors var_value=1 + when: pymysql_version.stdout == "" + - include: assert_fail_msg.yml output={{ result }} msg='Truncated incorrect' + when: pymysql_version.stdout != "" # ============================================================ # Verify mysql_variable fails when setting an incorrect value (incorrect type) @@ -167,12 +174,16 @@ - name: set mysql variable value to a non-valid value number mysql_variables: <<: *mysql_params - variable: max_tmp_tables + variable: max_connect_errors value: TEST register: result ignore_errors: true + - include: assert_var.yml changed=true output={{ result }} var_name=max_connect_errors var_value=1 + when: pymysql_version.stdout == "" + - include: assert_fail_msg.yml output={{ result }} msg='Incorrect argument type to variable' + when: pymysql_version.stdout != "" # ============================================================ # Verify mysql_variable fails when setting an unknown variable