|
| 1 | +/** |
| 2 | + * PSMDB-1893: Verify server parameters that control 'disks' and 'mounts' subsections |
| 3 | + * under systemMetrics in FTDC data. |
| 4 | + * |
| 5 | + * - diagnosticDataCollectionEnableSystemMetricsDisks |
| 6 | + * - diagnosticDataCollectionEnableSystemMetricsMounts |
| 7 | + * |
| 8 | + * Both default to true. When set to false, the corresponding subsection is omitted |
| 9 | + * from getDiagnosticData().data.systemMetrics. |
| 10 | + */ |
| 11 | +load('jstests/libs/ftdc.js'); |
| 12 | + |
| 13 | +(function() { |
| 14 | +'use strict'; |
| 15 | + |
| 16 | +function assertSystemMetricsSubsection(adminDb, subsectionName, expectedPresent, msg) { |
| 17 | + assert.soon(() => { |
| 18 | + const result = adminDb.runCommand("getDiagnosticData"); |
| 19 | + assert.commandWorked(result); |
| 20 | + const systemMetrics = result.data.systemMetrics; |
| 21 | + if (!systemMetrics) { |
| 22 | + return false; |
| 23 | + } |
| 24 | + if (systemMetrics.hasOwnProperty(subsectionName) === expectedPresent) { |
| 25 | + const subsection = systemMetrics.hasOwnProperty(subsectionName) |
| 26 | + ? systemMetrics[subsectionName] |
| 27 | + : "(absent)"; |
| 28 | + jsTestLog("getDiagnosticData systemMetrics." + subsectionName + ": " + |
| 29 | + tojson(subsection)); |
| 30 | + return true; |
| 31 | + } |
| 32 | + return false; |
| 33 | + }, msg, 10000); |
| 34 | +} |
| 35 | + |
| 36 | +// ========== diagnosticDataCollectionEnableSystemMetricsDisks ========== |
| 37 | + |
| 38 | +// --- Startup: disks false --- |
| 39 | +let conn = MongoRunner.runMongod( |
| 40 | + {setParameter: {diagnosticDataCollectionEnableSystemMetricsDisks: false}}); |
| 41 | +let adminDb = conn.getDB('admin'); |
| 42 | + |
| 43 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsDisks"), false); |
| 44 | + |
| 45 | +assertSystemMetricsSubsection( |
| 46 | + adminDb, |
| 47 | + "disks", |
| 48 | + false, |
| 49 | + "FTDC systemMetrics should omit 'disks' when param is false at startup"); |
| 50 | + |
| 51 | +// Enable at runtime and verify subsection appears |
| 52 | +assert.commandWorked( |
| 53 | + adminDb.runCommand({setParameter: 1, diagnosticDataCollectionEnableSystemMetricsDisks: true})); |
| 54 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsDisks"), true); |
| 55 | + |
| 56 | +assertSystemMetricsSubsection( |
| 57 | + adminDb, |
| 58 | + "disks", |
| 59 | + true, |
| 60 | + "FTDC systemMetrics should include 'disks' when enabled at runtime after startup disabled"); |
| 61 | + |
| 62 | +MongoRunner.stopMongod(conn); |
| 63 | + |
| 64 | +// --- Runtime: disks false then true --- |
| 65 | +conn = MongoRunner.runMongod(); |
| 66 | +adminDb = conn.getDB('admin'); |
| 67 | + |
| 68 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsDisks"), true); |
| 69 | + |
| 70 | +assert.commandWorked( |
| 71 | + adminDb.runCommand({setParameter: 1, diagnosticDataCollectionEnableSystemMetricsDisks: false})); |
| 72 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsDisks"), false); |
| 73 | + |
| 74 | +assertSystemMetricsSubsection( |
| 75 | + adminDb, |
| 76 | + "disks", |
| 77 | + false, |
| 78 | + "FTDC systemMetrics should omit 'disks' when param is false at runtime"); |
| 79 | + |
| 80 | +assert.commandWorked( |
| 81 | + adminDb.runCommand({setParameter: 1, diagnosticDataCollectionEnableSystemMetricsDisks: true})); |
| 82 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsDisks"), true); |
| 83 | + |
| 84 | +MongoRunner.stopMongod(conn); |
| 85 | + |
| 86 | +// ========== diagnosticDataCollectionEnableSystemMetricsMounts ========== |
| 87 | + |
| 88 | +// --- Startup: mounts false --- |
| 89 | +conn = MongoRunner.runMongod( |
| 90 | + {setParameter: {diagnosticDataCollectionEnableSystemMetricsMounts: false}}); |
| 91 | +adminDb = conn.getDB('admin'); |
| 92 | + |
| 93 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsMounts"), false); |
| 94 | + |
| 95 | +assertSystemMetricsSubsection( |
| 96 | + adminDb, |
| 97 | + "mounts", |
| 98 | + false, |
| 99 | + "FTDC systemMetrics should omit 'mounts' when param is false at startup"); |
| 100 | + |
| 101 | +// Enable at runtime and verify subsection appears |
| 102 | +assert.commandWorked( |
| 103 | + adminDb.runCommand({setParameter: 1, diagnosticDataCollectionEnableSystemMetricsMounts: true})); |
| 104 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsMounts"), true); |
| 105 | + |
| 106 | +assertSystemMetricsSubsection( |
| 107 | + adminDb, |
| 108 | + "mounts", |
| 109 | + true, |
| 110 | + "FTDC systemMetrics should include 'mounts' when enabled at runtime after startup disabled"); |
| 111 | + |
| 112 | +MongoRunner.stopMongod(conn); |
| 113 | + |
| 114 | +// --- Runtime: mounts false then true --- |
| 115 | +conn = MongoRunner.runMongod(); |
| 116 | +adminDb = conn.getDB('admin'); |
| 117 | + |
| 118 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsMounts"), true); |
| 119 | + |
| 120 | +assert.commandWorked(adminDb.runCommand( |
| 121 | + {setParameter: 1, diagnosticDataCollectionEnableSystemMetricsMounts: false})); |
| 122 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsMounts"), false); |
| 123 | + |
| 124 | +assertSystemMetricsSubsection( |
| 125 | + adminDb, |
| 126 | + "mounts", |
| 127 | + false, |
| 128 | + "FTDC systemMetrics should omit 'mounts' when param is false at runtime"); |
| 129 | + |
| 130 | +assert.commandWorked( |
| 131 | + adminDb.runCommand({setParameter: 1, diagnosticDataCollectionEnableSystemMetricsMounts: true})); |
| 132 | +assert.eq(getParameter(adminDb, "diagnosticDataCollectionEnableSystemMetricsMounts"), true); |
| 133 | + |
| 134 | +assertSystemMetricsSubsection( |
| 135 | + adminDb, |
| 136 | + "mounts", |
| 137 | + true, |
| 138 | + "FTDC systemMetrics should include 'mounts' when param is true at runtime"); |
| 139 | + |
| 140 | +MongoRunner.stopMongod(conn); |
| 141 | +})(); |
0 commit comments