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

socket_disconnect_kills.js doesn't check that operations fail with network error

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • ALL
    • Service Arch 2021-12-13, Service Arch 2022-1-10
    • 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.   

      Attachments

        Activity

          People

            reo.kimura@mongodb.com Reo Kimura
            george.wangensteen@mongodb.com George Wangensteen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: