Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1811

Refactor readconcern tests

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      The readConcern tests reuse quite a bit of boilerplate code. As matt.broadstone suggested, we should simplify these tests to use a format like

      [
        {
          description: 'should set majority readConcern option for aggregate command',
          operation: coll => coll.aggregate([{ $match: {} }], { readConcern: { level: 'majority' } })
      ].forEach(testCase => {
        it(testCase.description, () => { ... });
      });
      

      and provide a helper for command monitoring, like

      it('should do something with command monitoring', commandMonitoringTest(done => {
        ... other setup ...
        return collection
          .aggregate([{ $match: {} }], { readConcern: { level: 'majority' } })
          .toArray(function(err) {
            const aggEvents = this.started.filter(evt => evt.name === 'aggregate');
            const toCheck = aggEvents[0];
            ... the rest ...
          });
      }));
      

      The command monitoring helper would be responsible for instrumenting before the test, maintaining a list of started/failed/succeeded events for introspection, and uninstrumenting after the test.

            Assignee:
            sam.pal@mongodb.com Samiksha Pal (Inactive)
            Reporter:
            katherine.walker@mongodb.com Katherine Walker (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: