Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-70925

Asserting a commandWorked when it can fail on remove_shard_util.js

    • Fully Compatible
    • ALL
    • Sharding EMEA 2022-11-14
    • 35

      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.

            Assignee:
            pol.pinol@mongodb.com Pol Pinol
            Reporter:
            pol.pinol@mongodb.com Pol Pinol
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: