summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2021-03-18 02:50:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-18 03:27:32 +0000
commit61df6d3c9a0a6658613d2ef9bcfb28bd14224acf (patch)
treeb314fbf8e4270a22016978b58f35254e3a3e6551
parent68cd2c39ff64864b533471af63450cd352c51709 (diff)
downloadmongo-61df6d3c9a0a6658613d2ef9bcfb28bd14224acf.tar.gz
Revert "SERVER-54069 Added $graphLookup test suite for timeseries"
This reverts commit 1640bbb7d487ef65722d98ac830090c82b7f7ee5.
-rw-r--r--jstests/core/timeseries/libs/timeseries.js29
-rw-r--r--jstests/core/timeseries/timeseries_graph_lookup.js156
2 files changed, 14 insertions, 171 deletions
diff --git a/jstests/core/timeseries/libs/timeseries.js b/jstests/core/timeseries/libs/timeseries.js
index df52c18749a..f1f4d3eb917 100644
--- a/jstests/core/timeseries/libs/timeseries.js
+++ b/jstests/core/timeseries/libs/timeseries.js
@@ -29,10 +29,6 @@ var TimeseriesTest = class {
return arr[Random.randInt(arr.length)];
}
- static getRandomUsage() {
- return Random.randInt(101);
- }
-
/**
* Generates time-series data based on the TSBS document-per-event format.
*
@@ -42,6 +38,10 @@ var TimeseriesTest = class {
static generateHosts(numHosts) {
const hosts = new Array(numHosts);
+ const getRandomUsage = function() {
+ return Random.randInt(101);
+ };
+
const regions = [
"ap-northeast-1",
"ap-southeast-1",
@@ -102,22 +102,21 @@ var TimeseriesTest = class {
const regionIndex = Random.randInt(regions.length);
hosts[i] = {
fields: {
- usage_guest: TimeseriesTest.getRandomUsage(),
- usage_guest_nice: TimeseriesTest.getRandomUsage(),
- usage_idle: TimeseriesTest.getRandomUsage(),
- usage_iowait: TimeseriesTest.getRandomUsage(),
- usage_irq: TimeseriesTest.getRandomUsage(),
- usage_nice: TimeseriesTest.getRandomUsage(),
- usage_softirq: TimeseriesTest.getRandomUsage(),
- usage_steal: TimeseriesTest.getRandomUsage(),
- usage_system: TimeseriesTest.getRandomUsage(),
- usage_user: TimeseriesTest.getRandomUsage(),
+ usage_guest: getRandomUsage(),
+ usage_guest_nice: getRandomUsage(),
+ usage_idle: getRandomUsage(),
+ usage_iowait: getRandomUsage(),
+ usage_irq: getRandomUsage(),
+ usage_nice: getRandomUsage(),
+ usage_softirq: getRandomUsage(),
+ usage_steal: getRandomUsage(),
+ usage_system: getRandomUsage(),
+ usage_user: getRandomUsage(),
},
tags: {
arch: TimeseriesTest.getRandomElem(["x64", "x86"]),
datacenter: TimeseriesTest.getRandomElem(dataCenters[regionIndex]),
hostname: "host_" + i,
- hostid: i,
os: TimeseriesTest.getRandomElem(
["Ubuntu15.10", "Ubuntu16.10", "Ubuntu16.04LTS"]),
rack: Random.randInt(100).toString(),
diff --git a/jstests/core/timeseries/timeseries_graph_lookup.js b/jstests/core/timeseries/timeseries_graph_lookup.js
deleted file mode 100644
index 26bc1f0b9a6..00000000000
--- a/jstests/core/timeseries/timeseries_graph_lookup.js
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Verifies that time-series bucket collections work as expected with $graphLookup.
- *
- *
- * @tags: [
- * assumes_unsharded_collection,
- * requires_timeseries,
- * requires_fcv_49,
- * sbe_incompatible,
- * ]
- */
-(function() {
-"use strict";
-
-load("jstests/core/timeseries/libs/timeseries.js");
-
-if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
- jsTestLog("Skipping test because the time-series collection feature flag is disabled");
- return;
-}
-
-const testDB = db.getSiblingDB(jsTestName());
-assert.commandWorked(testDB.dropDatabase());
-const timeFieldName = "time";
-const hostIdFieldName = "hostid";
-const nonTimeseriesCollOption = null;
-const timeseriesCollOption = {
- timeseries: {timeField: timeFieldName, metaField: hostIdFieldName}
-};
-const numHosts = 10;
-const numDocs = 200;
-
-Random.setRandomSeed();
-const hosts = TimeseriesTest.generateHosts(numHosts);
-
-let testFunc = function(collAOption, collBOption) {
- // Prepares two collections. Each collection can be either a time-series or a non time-series
- // collection, depending on collAOption/collBOption.
- const collA = testDB.getCollection("a");
- const collB = testDB.getCollection("b");
- collA.drop();
- collB.drop();
- assert.commandWorked(testDB.createCollection(collA.getName(), collAOption));
- assert.commandWorked(testDB.createCollection(collB.getName(), collBOption));
- let entryCountPerHost = new Array(numHosts).fill(0);
- let entryCountOver80AndExistsIdlePerHost = new Array(numHosts).fill(0);
-
- // Inserts into collA, one entry per host.
- for (let i = 0; i < numHosts; i++) {
- let host = hosts[i];
- assert.commandWorked(collA.insert({time: ISODate(), hostid: host.tags.hostid}));
- }
-
- // Inserts some random documents to collB. The 'idle' measurement is inserted only when usage is
- // odd.
- for (let i = 0; i < numDocs; i++) {
- let host = TimeseriesTest.getRandomElem(hosts);
- let usage = TimeseriesTest.getRandomUsage();
- if (usage % 2) {
- assert.commandWorked(collB.insert(
- {time: ISODate(), hostid: host.tags.hostid, cpu: usage, idle: 100 - usage}));
- } else {
- assert.commandWorked(
- collB.insert({time: ISODate(), hostid: host.tags.hostid, cpu: usage}));
- }
-
- // These counts are to test metaField match.
- entryCountPerHost[host.tags.hostid]++;
-
- // These counts are to test measurement fields match which are specified by $graphLookup's
- // restrictSearchWithMatch.
- if (usage > 80 && usage % 2) {
- entryCountOver80AndExistsIdlePerHost[host.tags.hostid]++;
- }
- }
-
- // Verifies that a meta field "hostid" works with $graphLookup.
- let results = collA.aggregate([
- {
- $graphLookup: {
- from: collB.getName(),
- startWith: "$hostid",
- connectFromField: "hostid",
- connectToField: "hostid",
- as: "matchedB",
- maxDepth: 0
- }
- }, {
- $project: {
- _id: 0,
- hostid: 1,
- matchedB: {
- $size: "$matchedB"
- }
- }
- },
- {$sort: {hostid: 1}}
- ]).toArray();
-
- assert.eq(numHosts, results.length, results);
-
- for (let i = 0; i < numHosts; i++) {
- assert.eq({hostid: i, matchedB: entryCountPerHost[i]}, results[i], results);
- }
-
- // Verifies that measurement fields "cpu" and "idle" work with $graphLookup as expected.
- results = collA.aggregate([
- {
- $graphLookup: {
- from: collB.getName(),
- startWith: "$hostid",
- connectFromField: "hostid",
- connectToField: "hostid",
- as: "matchedB",
- maxDepth: 0,
- restrictSearchWithMatch: {
- cpu: {$gt: 80}, // Tests measurement "cpu".
- idle: {$exists: true} // Tests the existence of measurement "idle".
- }
- }
- }, {
- $project: {
- _id: 0,
- hostid: 1,
- matchedB: {
- $size: "$matchedB"
- }
- }
- },
- {$sort: {hostid: 1}}
- ]).toArray();
-
- assert.eq(numHosts, results.length, results);
-
- for (let i = 0; i < numHosts; i++) {
- let expectedCount = entryCountOver80AndExistsIdlePerHost[i];
- assert.eq(
- {hostid: i, matchedB: expectedCount}, results[i], entryCountOver80AndExistsIdlePerHost);
- }
-};
-
-// Tests case #1: collA: non time-series, collB: time-series
-var collAOption = nonTimeseriesCollOption;
-var collBOption = timeseriesCollOption;
-testFunc(collAOption, collBOption);
-
-// Tests case #2: collA: time-series, collB: non time-series
-collAOption = timeseriesCollOption;
-collBOption = nonTimeseriesCollOption;
-testFunc(collAOption, collBOption);
-
-// Tests case #3: collA: time-series, collB: time-series
-collAOption = timeseriesCollOption;
-collBOption = timeseriesCollOption;
-testFunc(collAOption, collBOption);
-})();