summaryrefslogtreecommitdiff
path: root/jstests
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-26 17:41:50 +0000
commitf3e1c75924038769b29c2c4f548f6011d97b47da (patch)
tree3c0c68799749f85c5460f76141c0ee58b03c2760 /jstests
parenta017afe7b73c13c111e63112c723edbf441e7eda (diff)
downloadmongo-f3e1c75924038769b29c2c4f548f6011d97b47da.tar.gz
SERVER-50123 jstest for hostInfo.extra.physicalCores
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/hostinfo.js85
1 files changed, 49 insertions, 36 deletions
diff --git a/jstests/core/hostinfo.js b/jstests/core/hostinfo.js
index a532c2865e6..725cf296276 100644
--- a/jstests/core/hostinfo.js
+++ b/jstests/core/hostinfo.js
@@ -3,45 +3,58 @@
// incompatible_with_embedded,
// ]
// SERVER-4615: Ensure hostInfo() command returns expected results on each platform
+//
+(function() {
+ 'use strict';
-assert.commandWorked(db.hostInfo());
-var hostinfo = db.hostInfo();
+ function commonOSAsserts(hostinfo) {
+ assert(hostinfo.os.hasOwnProperty('name'), "Missing " + hostinfo.os.type + " os name");
+ assert(hostinfo.os.hasOwnProperty('version'), "Missing " + hostinfo.os.type + " version");
+ }
-// 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");
+ 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");
+ }
-} 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");
+ assert.commandWorked(db.hostInfo());
+ var hostinfo = db.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");
+ // test for os-specific fields
+ if (hostinfo.os.type == "Windows") {
+ commonOSAsserts(hostinfo);
+ coresAsserts(hostinfo);
+ } else if (hostinfo.os.type == "Linux") {
+ commonOSAsserts(hostinfo);
+ coresAsserts(hostinfo);
+ } else if (hostinfo.os.type == "Darwin") {
+ commonOSAsserts(hostinfo);
+ coresAsserts(hostinfo);
+ } else if (hostinfo.os.type == "BSD") {
+ commonOSAsserts(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");
-}
+ if (hostinfo.os.type != "") {
+ 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");
+ }
-// 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");
-}
-
-var buildInfo = assert.commandWorked(db.runCommand({buildInfo: 1}));
-if (buildInfo.buildEnvironment && buildInfo.buildEnvironment.target_arch) {
- let targetArch = buildInfo.buildEnvironment.target_arch;
- if (targetArch == "i386")
- assert.eq(hostinfo.system.cpuAddrSize, 32);
- else
- assert.eq(hostinfo.system.cpuAddrSize, 64);
- assert.eq(hostinfo.system.cpuAddrSize, buildInfo.bits);
-}
+ var buildInfo = assert.commandWorked(db.runCommand({buildInfo: 1}));
+ if (buildInfo.buildEnvironment && buildInfo.buildEnvironment.target_arch) {
+ let targetArch = buildInfo.buildEnvironment.target_arch;
+ if (targetArch == "i386")
+ assert.eq(hostinfo.system.cpuAddrSize, 32);
+ else
+ assert.eq(hostinfo.system.cpuAddrSize, 64);
+ assert.eq(hostinfo.system.cpuAddrSize, buildInfo.bits);
+ }
+})();