[SERVER-70925] Asserting a commandWorked when it can fail on remove_shard_util.js Created: 28/Oct/22  Updated: 29/Oct/23  Resolved: 03/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.0-rc4, 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Pol Pinol Assignee: Pol Pinol
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding EMEA 2022-11-14
Participants:
Linked BF Score: 35

 Description   

Inside the jstest remove_shard_util.js (line 7) we are asserting that a command will work (removing a shard) and then handle the output error situation of that call. So, when the removeShard fails, we will get a failure on the test.
 

 let res = assert.commandWorked(st.s.adminCommand({removeShard: shardName}));
 if (!res.ok && res.code === ErrorCodes.ShardNotFound) {
     // ...
    return true;
 }

 
We should get the result on the variable first and then handle the error before asserting that the command worked.



 Comments   
Comment by Githook User [ 02/Nov/22 ]

Author:

{'name': 'Pol Pinol Castuera', 'email': 'pol.pinol@mongodb.com', 'username': 'PolPinol'}

Message: SERVER-70925 Changed the logic inside 'removeShard' helper.
Branch: master
https://github.com/mongodb/mongo/commit/1c454cfbc7e9f289e38dccdb625dbb859a2b1b39

Generated at Thu Feb 08 06:17:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.