Arbiter change and test additions (#59883)
This commit is contained in:
parent
b8a36e5950
commit
05e034f899
2 changed files with 45 additions and 1 deletions
|
@ -333,7 +333,7 @@ def main():
|
|||
if validate:
|
||||
if len(members) <= 2 or len(members) % 2 == 0:
|
||||
module.fail_json(msg="MongoDB Replicaset validation failed. Invalid number of replicaset members.")
|
||||
if arbiter_at_index is not None and len(members) - 1 > arbiter_at_index:
|
||||
if arbiter_at_index is not None and len(members) - 1 < arbiter_at_index:
|
||||
module.fail_json(msg="MongoDB Replicaset validation failed. Invalid arbiter index.")
|
||||
|
||||
result = dict(
|
||||
|
|
|
@ -493,4 +493,48 @@
|
|||
# - "'Name or service not known' in host_does_not_exist.module_stderr"
|
||||
|
||||
# Final clean up to prevent "directory not empty" error
|
||||
|
||||
# Test invalid arbiter handling
|
||||
# Test with arbiter_at_index
|
||||
- name: Test invalid arbiter handling 1
|
||||
mongodb_replicaset:
|
||||
login_user: admin
|
||||
login_password: secret
|
||||
login_host: "localhost"
|
||||
login_port: 3001
|
||||
login_database: "admin"
|
||||
arbiter_at_index: 0
|
||||
replica_set: "{{ mongodb_replicaset4 }}"
|
||||
members:
|
||||
- localhost:3001
|
||||
- localhost:3002
|
||||
- localhost:3003
|
||||
- localhost:3004
|
||||
ignore_errors: yes
|
||||
register: invalid_num
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'MongoDB Replicaset validation failed. Invalid number of replicaset members.' == invalid_num.msg"
|
||||
|
||||
- name: Test invalid arbiter handling 2
|
||||
mongodb_replicaset:
|
||||
login_user: admin
|
||||
login_password: secret
|
||||
login_host: "localhost"
|
||||
login_port: 3001
|
||||
login_database: "admin"
|
||||
arbiter_at_index: 4
|
||||
replica_set: "{{ mongodb_replicaset4 }}"
|
||||
members:
|
||||
- localhost:3001
|
||||
- localhost:3002
|
||||
- localhost:3003
|
||||
ignore_errors: yes
|
||||
register: invalid_num2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'MongoDB Replicaset validation failed. Invalid arbiter index.' == invalid_num2.msg"
|
||||
|
||||
- include_tasks: mongod_teardown.yml
|
||||
|
|
Loading…
Reference in a new issue