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

Make NetworkInterfaceIntegrationFixture wait for in progress requests

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Service Arch 2021-07-12, Service Arch 2021-08-09, Service Arch 2021-08-23
    • Linked BF Score:
      135
    • Story Points:
      2

      Description

      The fixture creates a new instance of NetworkInterface for every test. The network interface is shutdown after every test using tearDown (see here).

      void NetworkInterfaceIntegrationFixture::startNet(
          std::unique_ptr<NetworkConnectionHook> connectHook) {
       
          createNet(std::move(connectHook));
          net().startup();
      }
       
      void NetworkInterfaceIntegrationFixture::tearDown() {
          // Network interface will only shutdown once because of an internal shutdown guard
          _net->shutdown();
      }
      

      Integration tests use this network interface to run remote commands by calling into runCommand:

      Future<RemoteCommandResponse> NetworkInterfaceIntegrationFixture::runCommand(
          const TaskExecutor::CallbackHandle& cbHandle, RemoteCommandRequest request) {
          RemoteCommandRequestOnAny rcroa{request};
       
          return net().startCommand(cbHandle, rcroa).then([](TaskExecutor::ResponseOnAnyStatus roa) {
              auto res = RemoteCommandResponse(roa);
              if (res.isOK()) {
                  LOGV2(4820500,
                        "Got command result: {response}",
                        "Got command result",
                        "response"_attr = res.toString());
              } else {
                  LOGV2(4820501, "Command failed: {error}", "Command failed", "error"_attr = res.status);
              }
              return res;
          });
      }
      

      The fixture, however, does not track scheduled commands and may return from tearDown before all in progress commands finish. This violates the contract that different tests run in isolation, as a command may start in one test and complete in another.

      To address this issue, NetworkInterfaceIntegrationFixture must ensure all in progress commands complete before returning from tearDown. We may use a similar approach to that used by ThreadPoolTaskExecutor to get notified once the execution of a command is complete (see here).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              alex.li Alex Li (Inactive)
              Reporter:
              amirsaman.memaripour Amirsaman Memaripour
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: