summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Russell <gabriel.russell@mongodb.com>2020-10-12 12:25:41 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-23 14:28:35 +0000
commitfbdda8cb4937b24f5afe6b3982e6df3940453453 (patch)
tree9c14e7167ccb8c3b9659be0b09843abdf89785d4
parentd2aa85049faf7b01370827357c039abf020c26d9 (diff)
downloadmongo-fbdda8cb4937b24f5afe6b3982e6df3940453453.tar.gz
SERVER-50123 jstest for hostInfo.extra.physicalCores
-rw-r--r--jstests/core/hostinfo.js50
1 files changed, 31 insertions, 19 deletions
diff --git a/jstests/core/hostinfo.js b/jstests/core/hostinfo.js
index a532c2865e6..c088e52b853 100644
--- a/jstests/core/hostinfo.js
+++ b/jstests/core/hostinfo.js
@@ -3,37 +3,48 @@
// incompatible_with_embedded,
// ]
// SERVER-4615: Ensure hostInfo() command returns expected results on each platform
+//
+(function() {
+'use strict';
+
+function commonOSAsserts(hostinfo) {
+ assert(hostinfo.os.hasOwnProperty('name'), "Missing " + hostinfo.os.type + " os name");
+ assert(hostinfo.os.hasOwnProperty('version'), "Missing " + hostinfo.os.type + " version");
+}
+
+function coresAsserts(hostinfo) {
+ assert.gt(hostinfo.extra.physicalCores, 0, "Missing " + hostinfo.os.type + " physical cores");
+ assert.gt(hostinfo.system.numCores, 0, "Missing " + hostinfo.os.type + " logical cores");
+ assert.lte(hostinfo.extra.physicalCores,
+ hostinfo.system.numCores,
+ hostinfo.os.type + " physical cores not larger then logical cores");
+}
assert.commandWorked(db.hostInfo());
var hostinfo = db.hostInfo();
// test for os-specific fields
if (hostinfo.os.type == "Windows") {
- assert.neq(hostinfo.os.name, "" || null, "Missing Windows os name");
- assert.neq(hostinfo.os.version, "" || null, "Missing Windows version");
-
+ commonOSAsserts(hostinfo);
+ coresAsserts(hostinfo);
} else if (hostinfo.os.type == "Linux") {
- assert.neq(hostinfo.os.name, "" || null, "Missing Linux os/distro name");
- assert.neq(hostinfo.os.version, "" || null, "Missing Lindows version");
-
+ commonOSAsserts(hostinfo);
+ coresAsserts(hostinfo);
} else if (hostinfo.os.type == "Darwin") {
- assert.neq(hostinfo.os.name, "" || null, "Missing Darwin os name");
- assert.neq(hostinfo.os.version, "" || null, "Missing Darwin version");
-
+ commonOSAsserts(hostinfo);
+ coresAsserts(hostinfo);
} else if (hostinfo.os.type == "BSD") {
- assert.neq(hostinfo.os.name, "" || null, "Missing FreeBSD os name");
- assert.neq(hostinfo.os.version, "" || null, "Missing FreeBSD version");
+ commonOSAsserts(hostinfo);
}
-// comment out this block for systems which have not implemented hostinfo.
if (hostinfo.os.type != "") {
- assert.neq(hostinfo.system.hostname, "" || null, "Missing Hostname");
- assert.neq(hostinfo.system.currentTime, "" || null, "Missing Current Time");
- assert.neq(hostinfo.system.cpuAddrSize, "" || null || 0, "Missing CPU Address Size");
- assert.neq(hostinfo.system.memSizeMB, "" || null, "Missing Memory Size");
- assert.neq(hostinfo.system.numCores, "" || null || 0, "Missing Number of Cores");
- assert.neq(hostinfo.system.cpuArch, "" || null, "Missing CPU Architecture");
- assert.neq(hostinfo.system.numaEnabled, "" || null, "Missing NUMA flag");
+ assert(hostinfo.system.hasOwnProperty('hostname'), "Missing Hostname");
+ assert(hostinfo.system.hasOwnProperty('currentTime'), "Missing Current Time");
+ assert(hostinfo.system.hasOwnProperty('cpuAddrSize'), "Missing CPU Address Size");
+ assert(hostinfo.system.hasOwnProperty('memSizeMB'), "Missing Memory Size");
+ assert(hostinfo.system.hasOwnProperty('numCores'), "Missing Number of Cores");
+ assert(hostinfo.system.hasOwnProperty('cpuArch'), "Missing CPU Architecture");
+ assert(hostinfo.system.hasOwnProperty('numaEnabled'), "Missing NUMA flag");
}
var buildInfo = assert.commandWorked(db.runCommand({buildInfo: 1}));
@@ -45,3 +56,4 @@ if (buildInfo.buildEnvironment && buildInfo.buildEnvironment.target_arch) {
assert.eq(hostinfo.system.cpuAddrSize, 64);
assert.eq(hostinfo.system.cpuAddrSize, buildInfo.bits);
}
+})();