[SERVER-61069] socket_disconnect_kills.js doesn't check that operations fail with network error Created: 28/Oct/21  Updated: 29/Oct/23  Resolved: 04/Jan/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.3.0

Type: Bug Priority: Major - P3
Reporter: George Wangensteen Assignee: Reo Kimura (Inactive)
Resolution: Fixed Votes: 0
Labels: neweng, save-for-reo, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service Arch 2021-12-13, Service Arch 2022-1-10
Participants:
Story Points: 3

 Description   

Here: https://github.com/mongodb/mongo/blob/6e98a462d6e3f2222bc53bc948b60721e7879999/jstests/noPassthrough/socket_disconnect_kills.js#L41-L49 the test socket_disconnect_kills.js tries to run some operation over a Mongo connection and wants to check that it fails with a network error (here's the linked code in a snippet):

  // Make sure that whatever operation we ran had a network error
  assert.throws(function() {            
     try {                
         pre(conn);           
     } catch (e) {                
         throw e;            
     }
  }, [], "error doing query: failed: network error while attempting");

However, this block of code doesn't actually check that the operation fails with a network error – it just checks that it fails at all (i.e. that pre(conn) throws). The provided "message" third argument to assert.throws is just the message to print if the assertion fails (i.e. if the pre(conn) didn't throw). We need to actually inspect the Error object returned by assert.throws and ensure it's a network error to realize the intent of this test.   



 Comments   
Comment by Githook User [ 23/Dec/21 ]

Author:

{'name': 'Reo Kimura', 'email': 'reo.kimura@mongodb.com', 'username': 'rkimura21'}

Message: SERVER-61069 Check that operations fail with network error
Branch: master
https://github.com/mongodb/mongo/commit/9766c982d67c2a8584e329f024d702d8e2c8138e

Comment by Billy Donahue [ 15/Nov/21 ]

Just noting that the snippet:

     try {
         pre(conn);
     } catch (e) {
         throw e;
     }

is equivalent to just pre(conn);. The try/catch is kind of a no-op.

Generated at Thu Feb 08 05:51:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.