diff options
author | Spencer Jackson <spencer.jackson@mongodb.com> | 2020-05-29 18:38:02 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-16 16:13:36 +0000 |
commit | decb20798cf3a54e15a85d8345500023b60a7156 (patch) | |
tree | a6264098005793172e6143ef3af7c806b0491982 | |
parent | fb777a1aa5d7e9c238e3905e51bc13e924c234bb (diff) | |
download | mongo-decb20798cf3a54e15a85d8345500023b60a7156.tar.gz |
SERVER-48466 Suppress tcp_fastopen test on hosts with blackhole events
-rw-r--r-- | jstests/core/tcp_fastopen.js | 12 | ||||
-rw-r--r-- | jstests/libs/netstat.js | 45 |
2 files changed, 56 insertions, 1 deletions
diff --git a/jstests/core/tcp_fastopen.js b/jstests/core/tcp_fastopen.js index ac45d2faa2d..d63a86c5c5e 100644 --- a/jstests/core/tcp_fastopen.js +++ b/jstests/core/tcp_fastopen.js @@ -4,6 +4,8 @@ (function() { 'use strict'; +load("jstests/libs/netstat.js"); + // Does it make sense to expect TFO support? try { // Both client and server bits must be set to run this test. @@ -21,7 +23,15 @@ try { const initial = db.serverStatus().network.tcpFastOpen; printjson(initial); print("/proc/net/netstat:"); -print(cat("/proc/net/netstat")); +const initialObj = getNetStatObj(); +printjson(initialObj); + +// If TCPFastOpenBlackhole is 0 or not present, try to run the test. Otherwise, +// we've seen an event, and should skip the test. +if (initialObj.TcpExt.TCPFastOpenBlackhole) { + print("==Skipping test, host OS has observed a TCPFastOpenBlackhole event"); + return; +} if (!initial.serverSupported || !initial.clientSupported) { print("==Skipping test, one or both setsockopt() calls failed"); diff --git a/jstests/libs/netstat.js b/jstests/libs/netstat.js new file mode 100644 index 00000000000..0fe05922259 --- /dev/null +++ b/jstests/libs/netstat.js @@ -0,0 +1,45 @@ +'use strict'; + +/* Read the contents of /proc/net/netstat, and transform the output into a JS object. + * Netstat contains sections of key/value pairs, for different metrics tracked by the + * Linux kernel. Sections are encoded as two lines, prefixed by the field name. The first + * line contains an ordered list of all key names. The second line contains the ordered + * list of values. + * The schema of resulting Javascript object is: + * { + * "section1": { + * "key1": value1, + * "key2": value2, + * ... + * }, + * "section2": { + * "key1": value1, + * ... + * }, + * ... + * } + */ +function getNetStatObj() { + return cat("/proc/net/netstat") + .split("\n") + .filter((item) => item.length) + .map(line => line.split(" ")) + .reduce((acc, current) => { + const sectionName = current[0].slice(0, -1); + // If we're populating a subsection for the first time, + // just copy over the key names, resulting in: + // {..., "section": ["key1", "key2", ..., "keyN"] } + if (!acc[sectionName]) { + acc[sectionName] = current.slice(1); + } else { + // Merge the values into a subsection, resulting in: + // {..., "section": {"key1": value1, ..., "keyN", valueN} } + const populated = {}; + acc[sectionName].forEach((item, index) => { + populated[item] = current[index + 1]; + }); + acc[sectionName] = populated; + } + return acc; + }, {}); +} |