| 1 |
##################################################################### |
| 2 |
# WARNING: These are designed specifically for Ansible tests # |
| 3 |
# and should not be used as examples of how to write Ansible quotas # |
| 4 |
##################################################################### |
| 5 |
|
| 6 |
# Basic creation in check mode |
| 7 |
- name: Create a test quota in check mode |
| 8 |
register: result |
| 9 |
check_mode: true |
| 10 |
community.clickhouse.clickhouse_quota: |
| 11 |
state: present |
| 12 |
name: test_quota |
| 13 |
|
| 14 |
- name: Check the return values |
| 15 |
ansible.builtin.assert: |
| 16 |
that: |
| 17 |
- result is changed |
| 18 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\''] |
| 19 |
|
| 20 |
- name: Check the quota was not created in check mode |
| 21 |
register: result |
| 22 |
community.clickhouse.clickhouse_client: |
| 23 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 24 |
|
| 25 |
- name: Verify that the quota is not present |
| 26 |
ansible.builtin.assert: |
| 27 |
that: |
| 28 |
- result.result == [] |
| 29 |
|
| 30 |
# Basic creation with limits in check mode |
| 31 |
- name: Create a test quota in check mode |
| 32 |
register: result |
| 33 |
check_mode: true |
| 34 |
community.clickhouse.clickhouse_quota: |
| 35 |
state: present |
| 36 |
name: test_quota |
| 37 |
limits: |
| 38 |
- interval: 5 minute |
| 39 |
max: |
| 40 |
queries: 10 |
| 41 |
|
| 42 |
- name: Check the return values |
| 43 |
ansible.builtin.assert: |
| 44 |
that: |
| 45 |
- result is changed |
| 46 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' FOR INTERVAL 5 minute MAX queries = 10'] |
| 47 |
|
| 48 |
- name: Check the quota was not created in check mode |
| 49 |
register: result |
| 50 |
community.clickhouse.clickhouse_client: |
| 51 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 52 |
|
| 53 |
- name: Verify that the quota is not present |
| 54 |
ansible.builtin.assert: |
| 55 |
that: |
| 56 |
- result.result == [] |
| 57 |
|
| 58 |
# Basic creation with limits and apply_to in check mode |
| 59 |
- name: Create a test quota with limits and apply_to in check mode |
| 60 |
register: result |
| 61 |
check_mode: true |
| 62 |
community.clickhouse.clickhouse_quota: |
| 63 |
state: present |
| 64 |
name: test_quota |
| 65 |
limits: |
| 66 |
- interval: 5 minute |
| 67 |
max: |
| 68 |
queries: 100 |
| 69 |
execution_time: 600 |
| 70 |
apply_to: |
| 71 |
- default |
| 72 |
|
| 73 |
- name: Check the return values |
| 74 |
ansible.builtin.assert: |
| 75 |
that: |
| 76 |
- result is changed |
| 77 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' FOR INTERVAL 5 minute MAX queries = 100, execution_time = 600.0 TO default'] |
| 78 |
|
| 79 |
- name: Check the quota was not created in check mode |
| 80 |
register: result |
| 81 |
community.clickhouse.clickhouse_client: |
| 82 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 83 |
|
| 84 |
- name: Verify that the quota is not present |
| 85 |
ansible.builtin.assert: |
| 86 |
that: |
| 87 |
- result.result == [] |
| 88 |
|
| 89 |
# Basic creation with limits and apply_to_mode = all in check mode |
| 90 |
- name: Create a test quota with limits and apply_to_mode = all in check mode |
| 91 |
register: result |
| 92 |
check_mode: true |
| 93 |
community.clickhouse.clickhouse_quota: |
| 94 |
state: present |
| 95 |
name: test_quota |
| 96 |
limits: |
| 97 |
- interval: 5 minute |
| 98 |
tracking_only: true |
| 99 |
apply_to_mode: all |
| 100 |
|
| 101 |
- name: Check the return values |
| 102 |
ansible.builtin.assert: |
| 103 |
that: |
| 104 |
- result is changed |
| 105 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' FOR INTERVAL 5 minute TRACKING ONLY TO ALL'] |
| 106 |
|
| 107 |
- name: Check the quota was not created in check mode |
| 108 |
register: result |
| 109 |
community.clickhouse.clickhouse_client: |
| 110 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 111 |
|
| 112 |
- name: Verify that the quota is not present |
| 113 |
ansible.builtin.assert: |
| 114 |
that: |
| 115 |
- result.result == [] |
| 116 |
|
| 117 |
# Basic creation with limits and apply_to_mode = all_except_listed in check mode |
| 118 |
- name: Create a test quota with limits and apply_to_mode = all_except_listed in check mode |
| 119 |
register: result |
| 120 |
check_mode: true |
| 121 |
community.clickhouse.clickhouse_quota: |
| 122 |
state: present |
| 123 |
name: test_quota |
| 124 |
limits: |
| 125 |
- interval: 5 minute |
| 126 |
no_limits: true |
| 127 |
apply_to_mode: all_except_listed |
| 128 |
|
| 129 |
- name: Check the return values |
| 130 |
ansible.builtin.assert: |
| 131 |
that: |
| 132 |
- result is changed |
| 133 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' FOR INTERVAL 5 minute NO LIMITS TO ALL'] |
| 134 |
|
| 135 |
- name: Check the quota was not created in check mode |
| 136 |
register: result |
| 137 |
community.clickhouse.clickhouse_client: |
| 138 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 139 |
|
| 140 |
- name: Verify that the quota is not present |
| 141 |
ansible.builtin.assert: |
| 142 |
that: |
| 143 |
- result.result == [] |
| 144 |
|
| 145 |
# Basic creation with limits and apply_to_mode = all_except_listed in check mode |
| 146 |
- name: Create a test quota with limits and apply_to_mode = all_except_listed in check mode |
| 147 |
register: result |
| 148 |
check_mode: true |
| 149 |
community.clickhouse.clickhouse_quota: |
| 150 |
state: present |
| 151 |
name: test_quota |
| 152 |
limits: |
| 153 |
- interval: 5 minute |
| 154 |
max: |
| 155 |
failed_sequential_authentications: 5 |
| 156 |
apply_to_mode: all_except_listed |
| 157 |
apply_to: |
| 158 |
- admin |
| 159 |
- CURRENT_USER |
| 160 |
|
| 161 |
- name: Check the return values |
| 162 |
ansible.builtin.assert: |
| 163 |
that: |
| 164 |
- result is changed |
| 165 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' FOR INTERVAL 5 minute MAX failed_sequential_authentications = 5 TO ALL EXCEPT admin, CURRENT_USER'] |
| 166 |
|
| 167 |
- name: Check the quota was not created in check mode |
| 168 |
register: result |
| 169 |
community.clickhouse.clickhouse_client: |
| 170 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 171 |
|
| 172 |
- name: Verify that the quota is not present |
| 173 |
ansible.builtin.assert: |
| 174 |
that: |
| 175 |
- result.result == [] |
| 176 |
|
| 177 |
# Basic creation with keyed_by, limits and apply_to_mode = all_except_listed in check mode |
| 178 |
- name: Create a test quota with keyed_by, limits and apply_to_mode = all_except_listed in check mode |
| 179 |
register: result |
| 180 |
check_mode: true |
| 181 |
community.clickhouse.clickhouse_quota: |
| 182 |
state: present |
| 183 |
name: test_quota |
| 184 |
keyed_by: user_name |
| 185 |
limits: |
| 186 |
- interval: 5 minute |
| 187 |
randomized_start: true |
| 188 |
max: |
| 189 |
queries: 100 |
| 190 |
execution_time: 300.5 |
| 191 |
apply_to_mode: all |
| 192 |
|
| 193 |
- name: Check the return values |
| 194 |
ansible.builtin.assert: |
| 195 |
that: |
| 196 |
- result is changed |
| 197 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' KEYED BY user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 300.5 TO ALL'] |
| 198 |
|
| 199 |
- name: Check the quota was not created in check mode |
| 200 |
register: result |
| 201 |
community.clickhouse.clickhouse_client: |
| 202 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 203 |
|
| 204 |
- name: Verify that the quota is not present |
| 205 |
ansible.builtin.assert: |
| 206 |
that: |
| 207 |
- result.result == [] |
| 208 |
|
| 209 |
# Basic creation with cluster, keyed_by and limits in check mode |
| 210 |
- name: Create a test quota with cluster, keyed_by, limits in check mode |
| 211 |
register: result |
| 212 |
check_mode: true |
| 213 |
community.clickhouse.clickhouse_quota: |
| 214 |
state: present |
| 215 |
name: test_quota |
| 216 |
cluster: test_cluster |
| 217 |
keyed_by: user_name |
| 218 |
limits: |
| 219 |
- interval: 5 minute |
| 220 |
randomized_start: true |
| 221 |
max: |
| 222 |
execution_time: 10.2 |
| 223 |
- interval: 1 day |
| 224 |
max: |
| 225 |
query_selects: 10 |
| 226 |
query_inserts: 10 |
| 227 |
apply_to: CURRENT_USER |
| 228 |
|
| 229 |
- name: Check the return values |
| 230 |
ansible.builtin.assert: |
| 231 |
that: |
| 232 |
- result is changed |
| 233 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' ON CLUSTER \'test_cluster\' KEYED BY user_name FOR RANDOMIZED INTERVAL 5 minute MAX execution_time = 10.2, FOR INTERVAL 1 day MAX query_selects = 10, query_inserts = 10 TO CURRENT_USER'] |
| 234 |
|
| 235 |
- name: Check the quota was not created in check mode |
| 236 |
register: result |
| 237 |
community.clickhouse.clickhouse_client: |
| 238 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 239 |
|
| 240 |
- name: Verify that the quota is not present |
| 241 |
ansible.builtin.assert: |
| 242 |
that: |
| 243 |
- result.result == [] |
| 244 |
|
| 245 |
# Negative test that you can't specify apply_to_mode == all and a list of users |
| 246 |
- name: Negative test that you can't specify apply_to_mode == all and a list of users |
| 247 |
register: result |
| 248 |
check_mode: true |
| 249 |
ignore_errors: true |
| 250 |
community.clickhouse.clickhouse_quota: |
| 251 |
state: present |
| 252 |
name: test_quota |
| 253 |
apply_to: CURRENT_USER |
| 254 |
apply_to_mode: all |
| 255 |
|
| 256 |
- name: Check the return values |
| 257 |
ansible.builtin.assert: |
| 258 |
that: |
| 259 |
- result is failed |
| 260 |
|
| 261 |
# Actual test with basic limits |
| 262 |
- name: Actual test with basic limits |
| 263 |
register: result |
| 264 |
community.clickhouse.clickhouse_quota: |
| 265 |
name: test_quota |
| 266 |
keyed_by: user_name |
| 267 |
limits: |
| 268 |
- interval: 5 minute |
| 269 |
randomized_start: true |
| 270 |
max: |
| 271 |
queries: 100 |
| 272 |
apply_to: default |
| 273 |
|
| 274 |
- name: Check the return values |
| 275 |
ansible.builtin.assert: |
| 276 |
that: |
| 277 |
- result is changed |
| 278 |
- result.executed_statements == ['CREATE QUOTA \'test_quota\' KEYED BY user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100 TO default'] |
| 279 |
|
| 280 |
- name: Check the quota was actually created with the correct parameters |
| 281 |
register: result |
| 282 |
community.clickhouse.clickhouse_client: |
| 283 |
execute: "SHOW CREATE QUOTA test_quota" |
| 284 |
|
| 285 |
- name: Verify that the quota was actually created with the correct parameters |
| 286 |
ansible.builtin.assert: |
| 287 |
that: |
| 288 |
- result.result == [['CREATE QUOTA test_quota KEYED BY user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100 TO default']] |
| 289 |
|
| 290 |
- name: Delete the quota in check mode |
| 291 |
register: result |
| 292 |
check_mode: true |
| 293 |
community.clickhouse.clickhouse_quota: |
| 294 |
name: test_quota |
| 295 |
state: absent |
| 296 |
|
| 297 |
- name: Check the return values |
| 298 |
ansible.builtin.assert: |
| 299 |
that: |
| 300 |
- result is changed |
| 301 |
- result.executed_statements == ["DROP QUOTA 'test_quota'"] |
| 302 |
|
| 303 |
- name: Check the quota was not actually deleted |
| 304 |
register: result |
| 305 |
community.clickhouse.clickhouse_client: |
| 306 |
execute: "SHOW CREATE QUOTA test_quota" |
| 307 |
|
| 308 |
- name: Verify that the quota was not actually deleted (and still has the correct parameters) |
| 309 |
ansible.builtin.assert: |
| 310 |
that: |
| 311 |
- result.result == [['CREATE QUOTA test_quota KEYED BY user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100 TO default']] |
| 312 |
|
| 313 |
- name: Actually delete the quota |
| 314 |
register: result |
| 315 |
community.clickhouse.clickhouse_quota: |
| 316 |
name: test_quota |
| 317 |
state: absent |
| 318 |
|
| 319 |
- name: Check the return values |
| 320 |
ansible.builtin.assert: |
| 321 |
that: |
| 322 |
- result is changed |
| 323 |
- result.executed_statements == ['DROP QUOTA \'test_quota\''] |
| 324 |
|
| 325 |
- name: Check the quota was actually deleted |
| 326 |
register: result |
| 327 |
community.clickhouse.clickhouse_client: |
| 328 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 329 |
|
| 330 |
- name: Verify that the quota is no longer present |
| 331 |
ansible.builtin.assert: |
| 332 |
that: |
| 333 |
- result.result == [] |
| 334 |
|
| 335 |
# Alter quota |
| 336 |
- name: Create quota |
| 337 |
register: result |
| 338 |
community.clickhouse.clickhouse_quota: |
| 339 |
name: tést quota |
| 340 |
keyed_by: client_key,user_name |
| 341 |
limits: |
| 342 |
- interval: 5 minute |
| 343 |
randomized_start: true |
| 344 |
max: |
| 345 |
queries: 100 |
| 346 |
execution_time: 1.1 |
| 347 |
apply_to: default |
| 348 |
|
| 349 |
- name: Check the return values |
| 350 |
ansible.builtin.assert: |
| 351 |
that: |
| 352 |
- result is changed |
| 353 |
- result.executed_statements == ['CREATE QUOTA \'tést quota\' KEYED BY client_key,user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 1.1 TO default'] |
| 354 |
|
| 355 |
- name: Check the quota was actually created with the correct parameters |
| 356 |
register: result |
| 357 |
community.clickhouse.clickhouse_client: |
| 358 |
execute: "SHOW CREATE QUOTA 'tést quota'" |
| 359 |
|
| 360 |
- name: Verify that the quota was actually created with the correct parameters |
| 361 |
ansible.builtin.assert: |
| 362 |
that: |
| 363 |
- result.result == [['CREATE QUOTA `tést quota` KEYED BY client_key, user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 1.1 TO default']] |
| 364 |
|
| 365 |
- name: Alter the quota in check mode |
| 366 |
check_mode: true |
| 367 |
register: result |
| 368 |
community.clickhouse.clickhouse_quota: |
| 369 |
name: tést quota |
| 370 |
keyed_by: client_key,user_name |
| 371 |
limits: |
| 372 |
- interval: 5 minute |
| 373 |
randomized_start: true |
| 374 |
max: |
| 375 |
queries: 100 |
| 376 |
execution_time: 1.1 |
| 377 |
- interval: 1 minute |
| 378 |
max: |
| 379 |
errors: 10 |
| 380 |
apply_to: default |
| 381 |
|
| 382 |
- name: Check the return values |
| 383 |
ansible.builtin.assert: |
| 384 |
that: |
| 385 |
- result is changed |
| 386 |
- result.executed_statements == ['ALTER QUOTA \'tést quota\' KEYED BY client_key,user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 1.1, FOR INTERVAL 1 minute MAX errors = 10 TO default'] |
| 387 |
|
| 388 |
- name: Check the quota was not actually altered |
| 389 |
register: result |
| 390 |
community.clickhouse.clickhouse_client: |
| 391 |
execute: "SHOW CREATE QUOTA 'tést quota'" |
| 392 |
|
| 393 |
- name: Verify that the quota was not actually altered |
| 394 |
ansible.builtin.assert: |
| 395 |
that: |
| 396 |
- result.result == [['CREATE QUOTA `tést quota` KEYED BY client_key, user_name FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 1.1 TO default']] |
| 397 |
|
| 398 |
- name: Actually alter the quota |
| 399 |
register: result |
| 400 |
community.clickhouse.clickhouse_quota: |
| 401 |
name: tést quota |
| 402 |
keyed_by: client_key,user_name |
| 403 |
limits: |
| 404 |
- interval: 5 minute |
| 405 |
randomized_start: true |
| 406 |
max: |
| 407 |
queries: 100 |
| 408 |
execution_time: 1.1 |
| 409 |
- interval: 1 minute |
| 410 |
max: |
| 411 |
errors: 10 |
| 412 |
apply_to: default |
| 413 |
|
| 414 |
- name: Check the quota was actually altered |
| 415 |
register: result |
| 416 |
community.clickhouse.clickhouse_client: |
| 417 |
execute: "SHOW CREATE QUOTA 'tést quota'" |
| 418 |
|
| 419 |
- name: Verify that the quota was actually altered |
| 420 |
ansible.builtin.assert: |
| 421 |
that: |
| 422 |
- result.result == [['CREATE QUOTA `tést quota` KEYED BY client_key, user_name FOR INTERVAL 1 minute MAX errors = 10, FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 1.1 TO default']] |
| 423 |
|
| 424 |
- name: Check idempotency |
| 425 |
register: result |
| 426 |
community.clickhouse.clickhouse_quota: |
| 427 |
name: tést quota |
| 428 |
keyed_by: client_key,user_name |
| 429 |
limits: |
| 430 |
- interval: 5 minute |
| 431 |
randomized_start: true |
| 432 |
max: |
| 433 |
queries: 100 |
| 434 |
execution_time: 1.1 |
| 435 |
- interval: 1 minute |
| 436 |
max: |
| 437 |
errors: 10 |
| 438 |
apply_to: default |
| 439 |
|
| 440 |
- name: Check the return values |
| 441 |
ansible.builtin.assert: |
| 442 |
that: |
| 443 |
- result is not changed |
| 444 |
- result.executed_statements == [] |
| 445 |
|
| 446 |
- name: Check the quota was not actually altered |
| 447 |
register: result |
| 448 |
community.clickhouse.clickhouse_client: |
| 449 |
execute: "SHOW CREATE QUOTA 'tést quota'" |
| 450 |
|
| 451 |
- name: Verify that the quota was not actually altered |
| 452 |
ansible.builtin.assert: |
| 453 |
that: |
| 454 |
- result.result == [['CREATE QUOTA `tést quota` KEYED BY client_key, user_name FOR INTERVAL 1 minute MAX errors = 10, FOR RANDOMIZED INTERVAL 5 minute MAX queries = 100, execution_time = 1.1 TO default']] |
| 455 |
|
| 456 |
- name: Actually delete the quota |
| 457 |
register: result |
| 458 |
community.clickhouse.clickhouse_quota: |
| 459 |
name: tést quota |
| 460 |
state: absent |
| 461 |
|
| 462 |
- name: Check the return values |
| 463 |
ansible.builtin.assert: |
| 464 |
that: |
| 465 |
- result is changed |
| 466 |
- result.executed_statements == ['DROP QUOTA \'tést quota\''] |
| 467 |
|
| 468 |
- name: Check the quota was actually deleted |
| 469 |
register: result |
| 470 |
community.clickhouse.clickhouse_client: |
| 471 |
execute: "SELECT name FROM system.quotas WHERE name = 'tést quota'" |
| 472 |
|
| 473 |
- name: Verify that the quota is no longer present |
| 474 |
ansible.builtin.assert: |
| 475 |
that: |
| 476 |
- result.result == [] |
| 477 |
|
| 478 |
- name: Create quota |
| 479 |
register: result |
| 480 |
community.clickhouse.clickhouse_quota: |
| 481 |
name: test_quota |
| 482 |
limits: |
| 483 |
- interval: 1 day |
| 484 |
max: |
| 485 |
errors: 1000 |
| 486 |
apply_to_mode: all_except_listed |
| 487 |
|
| 488 |
- name: Check the return values |
| 489 |
ansible.builtin.assert: |
| 490 |
that: |
| 491 |
- result is changed |
| 492 |
- result.executed_statements == ["CREATE QUOTA 'test_quota' FOR INTERVAL 1 day MAX errors = 1000 TO ALL"] |
| 493 |
|
| 494 |
- name: Check the quota was actually created with the correct parameters |
| 495 |
register: result |
| 496 |
community.clickhouse.clickhouse_client: |
| 497 |
execute: "SHOW CREATE QUOTA 'test_quota'" |
| 498 |
|
| 499 |
- name: Verify that the quota was actually created with the correct parameters |
| 500 |
ansible.builtin.assert: |
| 501 |
that: |
| 502 |
- result.result == [['CREATE QUOTA test_quota FOR INTERVAL 1 day MAX errors = 1000 TO ALL']] |
| 503 |
|
| 504 |
- name: Check for idempotency between apply_to_mode=all_except_listed and apply_to=[] and apply_to_mode=all (in check mode) |
| 505 |
check_mode: true |
| 506 |
register: result |
| 507 |
community.clickhouse.clickhouse_quota: |
| 508 |
name: test_quota |
| 509 |
limits: |
| 510 |
- interval: 1 day |
| 511 |
max: |
| 512 |
errors: 1000 |
| 513 |
apply_to_mode: all |
| 514 |
|
| 515 |
- name: Check the return values |
| 516 |
ansible.builtin.assert: |
| 517 |
that: |
| 518 |
- result is not changed |
| 519 |
- result.executed_statements == [] |
| 520 |
|
| 521 |
- name: Check the quota was not actually altered |
| 522 |
register: result |
| 523 |
community.clickhouse.clickhouse_client: |
| 524 |
execute: "SHOW CREATE QUOTA 'test_quota'" |
| 525 |
|
| 526 |
- name: Verify that the quota was not actually altered |
| 527 |
ansible.builtin.assert: |
| 528 |
that: |
| 529 |
- result.result == [['CREATE QUOTA test_quota FOR INTERVAL 1 day MAX errors = 1000 TO ALL']] |
| 530 |
|
| 531 |
- name: Check for idempotency between apply_to_mode=all_except_listed and apply_to=[] and apply_to_mode=all |
| 532 |
register: result |
| 533 |
community.clickhouse.clickhouse_quota: |
| 534 |
name: test_quota |
| 535 |
limits: |
| 536 |
- interval: 1 day |
| 537 |
max: |
| 538 |
errors: 1000 |
| 539 |
apply_to_mode: all |
| 540 |
|
| 541 |
- name: Check the return values |
| 542 |
ansible.builtin.assert: |
| 543 |
that: |
| 544 |
- result is not changed |
| 545 |
- result.executed_statements == [] |
| 546 |
|
| 547 |
- name: Check the quota was not actually altered |
| 548 |
register: result |
| 549 |
community.clickhouse.clickhouse_client: |
| 550 |
execute: "SHOW CREATE QUOTA 'test_quota'" |
| 551 |
|
| 552 |
- name: Verify that the quota was not actually altered |
| 553 |
ansible.builtin.assert: |
| 554 |
that: |
| 555 |
- result.result == [['CREATE QUOTA test_quota FOR INTERVAL 1 day MAX errors = 1000 TO ALL']] |
| 556 |
|
| 557 |
- name: Delete the quota in check mode |
| 558 |
register: result |
| 559 |
check_mode: true |
| 560 |
community.clickhouse.clickhouse_quota: |
| 561 |
name: test_quota |
| 562 |
state: absent |
| 563 |
|
| 564 |
- name: Check the return values |
| 565 |
ansible.builtin.assert: |
| 566 |
that: |
| 567 |
- result is changed |
| 568 |
- result.executed_statements == ["DROP QUOTA 'test_quota'"] |
| 569 |
|
| 570 |
- name: Check the quota was not actually deleted |
| 571 |
register: result |
| 572 |
community.clickhouse.clickhouse_client: |
| 573 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 574 |
|
| 575 |
- name: Verify that the quota is still present |
| 576 |
ansible.builtin.assert: |
| 577 |
that: |
| 578 |
- result.result == [["test_quota"]] |
| 579 |
|
| 580 |
- name: Actually delete the quota |
| 581 |
register: result |
| 582 |
community.clickhouse.clickhouse_quota: |
| 583 |
name: test_quota |
| 584 |
state: absent |
| 585 |
|
| 586 |
- name: Check the return values |
| 587 |
ansible.builtin.assert: |
| 588 |
that: |
| 589 |
- result is changed |
| 590 |
- result.executed_statements == ["DROP QUOTA 'test_quota'"] |
| 591 |
|
| 592 |
- name: Check the quota was actually deleted |
| 593 |
register: result |
| 594 |
community.clickhouse.clickhouse_client: |
| 595 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 596 |
|
| 597 |
- name: Verify that the quota is no longer present |
| 598 |
ansible.builtin.assert: |
| 599 |
that: |
| 600 |
- result.result == [] |
| 601 |
|
| 602 |
- name: Create tracking only quota |
| 603 |
register: result |
| 604 |
community.clickhouse.clickhouse_quota: |
| 605 |
name: test_quota |
| 606 |
limits: |
| 607 |
- interval: 15 minute |
| 608 |
tracking_only: true |
| 609 |
apply_to_mode: all |
| 610 |
|
| 611 |
- name: Check the return values |
| 612 |
ansible.builtin.assert: |
| 613 |
that: |
| 614 |
- result is changed |
| 615 |
- result.executed_statements == ["CREATE QUOTA 'test_quota' FOR INTERVAL 15 minute TRACKING ONLY TO ALL"] |
| 616 |
|
| 617 |
- name: Check the quota was actually created with the correct parameters |
| 618 |
register: result |
| 619 |
community.clickhouse.clickhouse_client: |
| 620 |
execute: "SHOW CREATE QUOTA 'test_quota'" |
| 621 |
|
| 622 |
- name: Verify that the quota was actually created with the correct parameters |
| 623 |
ansible.builtin.assert: |
| 624 |
that: |
| 625 |
- result.result == [['CREATE QUOTA test_quota FOR INTERVAL 15 minute TRACKING ONLY TO ALL']] |
| 626 |
|
| 627 |
- name: Check for idempotency (in check mode) |
| 628 |
check_mode: true |
| 629 |
register: result |
| 630 |
community.clickhouse.clickhouse_quota: |
| 631 |
name: test_quota |
| 632 |
limits: |
| 633 |
- interval: 15 minute |
| 634 |
tracking_only: true |
| 635 |
apply_to_mode: all |
| 636 |
|
| 637 |
- name: Check the return values |
| 638 |
ansible.builtin.assert: |
| 639 |
that: |
| 640 |
- result is not changed |
| 641 |
- result.executed_statements == [] |
| 642 |
|
| 643 |
- name: Check the quota was not actually altered |
| 644 |
register: result |
| 645 |
community.clickhouse.clickhouse_client: |
| 646 |
execute: "SHOW CREATE QUOTA 'test_quota'" |
| 647 |
|
| 648 |
- name: Verify that the quota was not actually altered |
| 649 |
ansible.builtin.assert: |
| 650 |
that: |
| 651 |
- result.result == [['CREATE QUOTA test_quota FOR INTERVAL 15 minute TRACKING ONLY TO ALL']] |
| 652 |
|
| 653 |
- name: Check for idempotency |
| 654 |
register: result |
| 655 |
community.clickhouse.clickhouse_quota: |
| 656 |
name: test_quota |
| 657 |
limits: |
| 658 |
- interval: 15 minute |
| 659 |
tracking_only: true |
| 660 |
apply_to_mode: all |
| 661 |
|
| 662 |
- name: Check the return values |
| 663 |
ansible.builtin.assert: |
| 664 |
that: |
| 665 |
- result is not changed |
| 666 |
- result.executed_statements == [] |
| 667 |
|
| 668 |
- name: Check the quota was not actually altered |
| 669 |
register: result |
| 670 |
community.clickhouse.clickhouse_client: |
| 671 |
execute: "SHOW CREATE QUOTA 'test_quota'" |
| 672 |
|
| 673 |
- name: Verify that the quota was not actually altered |
| 674 |
ansible.builtin.assert: |
| 675 |
that: |
| 676 |
- result.result == [['CREATE QUOTA test_quota FOR INTERVAL 15 minute TRACKING ONLY TO ALL']] |
| 677 |
|
| 678 |
- name: Delete the quota in check mode |
| 679 |
register: result |
| 680 |
check_mode: true |
| 681 |
community.clickhouse.clickhouse_quota: |
| 682 |
name: test_quota |
| 683 |
state: absent |
| 684 |
|
| 685 |
- name: Check the return values |
| 686 |
ansible.builtin.assert: |
| 687 |
that: |
| 688 |
- result is changed |
| 689 |
- result.executed_statements == ["DROP QUOTA 'test_quota'"] |
| 690 |
|
| 691 |
- name: Check the quota was not actually deleted |
| 692 |
register: result |
| 693 |
community.clickhouse.clickhouse_client: |
| 694 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 695 |
|
| 696 |
- name: Verify that the quota is still present |
| 697 |
ansible.builtin.assert: |
| 698 |
that: |
| 699 |
- result.result == [["test_quota"]] |
| 700 |
|
| 701 |
- name: Actually delete the quota |
| 702 |
register: result |
| 703 |
community.clickhouse.clickhouse_quota: |
| 704 |
name: test_quota |
| 705 |
state: absent |
| 706 |
|
| 707 |
- name: Check the return values |
| 708 |
ansible.builtin.assert: |
| 709 |
that: |
| 710 |
- result is changed |
| 711 |
- result.executed_statements == ["DROP QUOTA 'test_quota'"] |
| 712 |
|
| 713 |
- name: Check the quota was actually deleted |
| 714 |
register: result |
| 715 |
community.clickhouse.clickhouse_client: |
| 716 |
execute: "SELECT name FROM system.quotas WHERE name = 'test_quota'" |
| 717 |
|
| 718 |
- name: Verify that the quota is no longer present |
| 719 |
ansible.builtin.assert: |
| 720 |
that: |
| 721 |
- result.result == [] |