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

ShardingTest::awaitBalancerRound logs the error msg incorrectly with assert.soon

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.14
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Sharding 2016-09-19
    • 0

      In ShardingTest::awaitBalancerRound fails, it outputs "Latest balancer statusundefined".

      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 2016-08-23T19:23:14.224+0000 E QUERY    [thread1] Error: assert.soon failed, msg:Latest balancer statusundefined :
      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 doassert@src/mongo/shell/assert.js:15:14
      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 assert.soon@src/mongo/shell/assert.js:176:13
      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 ShardingTest/this.awaitBalancerRound@src/mongo/shell/shardingtest.js:573:1
      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 @jstests/sharding/tag_auto_split_partial_key.js:22:5
      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 @jstests/sharding/tag_auto_split_partial_key.js:2:2
      [js_test:tag_auto_split_partial_key] 2016-08-23T19:23:14.225+0000 failed to load: jstests/sharding/tag_auto_split_partial_key.js
      

      In order to include the current balancer status in the assertion message, it is necessary to pass a function as the msg parameter to assert.soon().

      diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
      index 6c3a67a..ac96291 100644
      --- a/src/mongo/shell/shardingtest.js
      +++ b/src/mongo/shell/shardingtest.js
      @@ -570,10 +570,15 @@ var ShardingTest = function(params) {
       
               var initialStatus = getBalancerStatus();
               var currentStatus;
      -        assert.soon(function() {
      -            currentStatus = getBalancerStatus();
      -            return (currentStatus.numBalancerRounds - initialStatus.numBalancerRounds) != 0;
      -        }, 'Latest balancer status' + currentStatus, timeoutMs);
      +        assert.soon(
      +            function() {
      +                currentStatus = getBalancerStatus();
      +                return (currentStatus.numBalancerRounds - initialStatus.numBalancerRounds) != 0;
      +            },
      +            function() {
      +                return 'Latest balancer status: ' + tojson(currentStatus);
      +            },
      +            timeoutMs);
           };
       
           /**
      

            Assignee:
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Reporter:
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: