[SERVER-26095] ShardingTest::awaitBalancerRound logs the error msg incorrectly with assert.soon Created: 13/Sep/16  Updated: 19/Nov/16  Resolved: 15/Sep/16

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

Type: Bug Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: Dianna Hohensee (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2016-09-19
Participants:
Linked BF Score: 0

 Description   

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);
     };
 
     /**



 Comments   
Comment by Githook User [ 15/Sep/16 ]

Author:

{u'username': u'DiannaHohensee', u'name': u'Dianna Hohensee', u'email': u'dianna.hohensee@10gen.com'}

Message: SERVER-26095 fix error message in ShardingTest::awaitBalancerRound
Branch: master
https://github.com/mongodb/mongo/commit/1a5a51ed5214c95d44538336e6bf30fc8c57248b

Generated at Thu Feb 08 04:11:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.