From ad784dcf07acb2c4439d3d2a7d34bcfeb5f3da2c Mon Sep 17 00:00:00 2001 From: Saikumar Date: Sat, 9 Nov 2024 22:58:01 +0530 Subject: [PATCH 1/7] Updates for mongo patch --- .../verifyMongoDBCollectionFlags_test.js | 41 ++++++++++--------- tests/pages/api/grafanaAPI.js | 25 ++++++++--- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/tests/metrics/verifyMongoDBCollectionFlags_test.js b/tests/metrics/verifyMongoDBCollectionFlags_test.js index 5f4a59dc0..94602855c 100644 --- a/tests/metrics/verifyMongoDBCollectionFlags_test.js +++ b/tests/metrics/verifyMongoDBCollectionFlags_test.js @@ -7,7 +7,7 @@ const { Feature('MongoDB Collectors Parameters and Flags tests'); const collectionNames = ['col1', 'col2', 'col3', 'col4', 'col5']; -const dbNames = ['db1', 'db2', 'db3', 'db4']; +const dbNames = ['db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 'db8', 'db9']; const mongodb_service_name = 'mongodb_test_collections_flag'; const containerName = 'rs101'; @@ -85,8 +85,8 @@ Scenario( // assert dbstats and topmetrics collectors are disabled // eslint-disable-next-line no-prototype-builtins assert.ok(!mongoDbOptions.enable_all_collectors, `Was expecting enable_all_collectors to be disabled for Mongo Exporter for service "${mongodb_service_name}"`); - I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); @@ -115,8 +115,8 @@ Scenario( assert.ok(disabledCollectors[0] === collectorsToDisable, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "disabled_collectors: [ 'topmetrics' ]" property`); assert.ok(disabledCollectors.length === 1, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "disabled_collectors: [ 'topmetrics' ]" property`); assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property with "true"`); - I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); @@ -135,8 +135,8 @@ Scenario( // assert dbstats and topmetrics collectors are enabled assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); - await I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + await I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); @@ -157,8 +157,8 @@ Scenario( // assert dbstats and topmetrics collectors are enabled // eslint-disable-next-line no-prototype-builtins assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); - I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); @@ -211,8 +211,8 @@ Scenario( // assert dbstats and topmetrics collectors are enabled // eslint-disable-next-line no-prototype-builtins assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); - I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); @@ -237,8 +237,8 @@ Scenario( // assert dbstats and topmetrics collectors are enabled // eslint-disable-next-line no-prototype-builtins assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); - I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricAbsent(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); @@ -263,8 +263,8 @@ Scenario( // assert dbstats and topmetrics collectors are enabled // eslint-disable-next-line no-prototype-builtins assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); - I.say('Wait 150 seconds for Metrics being collected for the new service'); - await I.wait(150); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); @@ -290,8 +290,8 @@ Scenario( // assert dbstats and topmetrics collectors are enabled // eslint-disable-next-line no-prototype-builtins assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); - I.say('Wait 120 seconds for Metrics being collected for the new service'); - await I.wait(120); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'collstats' }]); await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'dbstats' }]); await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'diagnostic_data' }]); @@ -303,7 +303,8 @@ Scenario( // Re-add Service with Disable Top metrics, check no smart metrics for Top await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors=topmetrics --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); - await I.wait(120); + I.say('Wait 180 seconds for Metrics being collected for the new service'); + await I.wait(180); await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: `${mongodb_service_name}` }, { type: 'collector', value: 'dbstats' }]); await grafanaAPI.checkMetricAbsent(smartMetricName, [{ type: 'service_name', value: `${mongodb_service_name}` }, { type: 'collector', value: 'top' }]); }, @@ -370,9 +371,9 @@ Scenario( await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --service-name=${service_name}`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, service_name); - await grafanaAPI.waitForMetric('mongodb_up', [{ type: 'service_name', value: service_name }], 90); + await grafanaAPI.waitForMetric('mongodb_up', { type: 'service_name', value: service_name }, 90); await I.verifyCommand(`docker exec ${containerName} pmm-admin inventory remove service ${service_id} --force`); - await grafanaAPI.waitForMetricAbsent('mongodb_up', [{ type: 'service_name', value: service_name }], 90); + await grafanaAPI.waitForMetricAbsent('mongodb_up', { type: 'service_name', value: service_name }, 90); // PMM-T1352 Verify that Node exporter cannot be added by pmm-admin inventory add agent node-exporter with --log-level=fatal await I.verifyCommand(`docker exec ${containerName} pmm-admin inventory add agent node-exporter --log-level=fatal ${pmm_agent_id}`, 'pmm-admin: error: --log-level must be one of "debug","info","warn","error" but got "fatal"', 'fail'); }, diff --git a/tests/pages/api/grafanaAPI.js b/tests/pages/api/grafanaAPI.js index 0e3fa0161..60148545d 100644 --- a/tests/pages/api/grafanaAPI.js +++ b/tests/pages/api/grafanaAPI.js @@ -440,7 +440,7 @@ module.exports = { // Main condition check: metric body is not empty const response = await this.getMetric(metricName, queryBy); - if (response.data.data.result.length === 0) { + if (response.data.results.A.frames[0].data.values.length === 0) { return response; } @@ -456,7 +456,13 @@ module.exports = { }, async checkMetricExist(metricName, refineBy) { - const response = await this.getMetric(metricName, refineBy); + let response; + + await I.asyncWaitFor(async () => { + response = await this.getMetric(metricName, refineBy); + + return response.data.results.A.frames[0].data.values.length !== 0; + }, 120); const result = JSON.stringify(response.data.results); @@ -469,13 +475,22 @@ module.exports = { }, async checkMetricAbsent(metricName, refineBy) { - const response = await this.getMetric(metricName, refineBy); - const result = JSON.stringify(response.data.data.result); + let response; + + await I.asyncWaitFor(async () => { + response = await this.getMetric(metricName, refineBy); + + return response.data.results.A.frames[0].data.values.length === 0; + }, 120); + + const result = JSON.stringify(response.data.results); I.assertEqual( - response.data.data.result.length, + response.data.results.A.frames[0].data.values.length, 0, `Metrics "${metricName}" with filters as ${JSON.stringify(refineBy)} should be empty but got available ${result}`, ); + + return response; }, }; From dc41c7f36e9748bfd1d0179d6c04d806f63fcd5b Mon Sep 17 00:00:00 2001 From: Saikumar Date: Sun, 10 Nov 2024 00:26:41 +0530 Subject: [PATCH 2/7] Updates to make random service name --- .../verifyMongoDBCollectionFlags_test.js | 29 +++++++++++++++++++ tests/pages/api/grafanaAPI.js | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/metrics/verifyMongoDBCollectionFlags_test.js b/tests/metrics/verifyMongoDBCollectionFlags_test.js index 94602855c..c0539e607 100644 --- a/tests/metrics/verifyMongoDBCollectionFlags_test.js +++ b/tests/metrics/verifyMongoDBCollectionFlags_test.js @@ -74,6 +74,9 @@ Scenario( Scenario( 'PMM-T1208 - Verify metrics of MongoDB added with default flags @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -99,6 +102,8 @@ Scenario( + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { const collectorsToDisable = 'topmetrics'; + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors=${collectorsToDisable} --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -127,6 +132,9 @@ Scenario( Scenario( 'PMM-T1210 - Verify metrics of MongoDB with "--enable-all-collectors" was specified @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -148,6 +156,9 @@ Scenario( 'PMM-T1211 - Verify metrics of MongoDB with --disable-collectors="" and --enable-all-collectors were specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors="" --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -170,6 +181,9 @@ Scenario( 'PMM-T1212 - Verify metrics of MongoDB with --disable-collectors="collstats,dbstats,topmetrics" specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + const collectorsToDisable = 'collstats,dbstats,topmetrics'; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors="${collectorsToDisable}" --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -202,6 +216,9 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -228,6 +245,9 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=5 specified when total collections across db1, db2 and the filters are 6' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=5 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -254,6 +274,9 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=400 specified to allow fetching metrics from all collectors' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -280,6 +303,9 @@ Scenario( 'PMM-9919 Verify smart metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=400 specified to allow fetching metrics from all collectors' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -361,6 +387,9 @@ Scenario( }) => { I.amOnPage(dashboardPage.mongoDbInstanceOverview.url); dashboardPage.waitForDashboardOpened(); + const randomNumber = Math.floor(Math.random() * 100) + 1; + const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; + const service_name = 'testing_force_flag'; // adding service which will be used to verify various inventory addition commands diff --git a/tests/pages/api/grafanaAPI.js b/tests/pages/api/grafanaAPI.js index 60148545d..5b1342ac1 100644 --- a/tests/pages/api/grafanaAPI.js +++ b/tests/pages/api/grafanaAPI.js @@ -462,7 +462,7 @@ module.exports = { response = await this.getMetric(metricName, refineBy); return response.data.results.A.frames[0].data.values.length !== 0; - }, 120); + }, 60); const result = JSON.stringify(response.data.results); @@ -481,7 +481,7 @@ module.exports = { response = await this.getMetric(metricName, refineBy); return response.data.results.A.frames[0].data.values.length === 0; - }, 120); + }, 60); const result = JSON.stringify(response.data.results); From 6c6c9690a07800e3067478b6a1c4f3e54a485b0a Mon Sep 17 00:00:00 2001 From: Saikumar Date: Sun, 10 Nov 2024 08:41:38 +0530 Subject: [PATCH 3/7] Updates to remove random name and fix ui test locators names --- .../verifyMongoDBCollectionFlags_test.js | 22 ------------------- tests/pages/dashboardPage.js | 5 +++-- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/tests/metrics/verifyMongoDBCollectionFlags_test.js b/tests/metrics/verifyMongoDBCollectionFlags_test.js index c0539e607..41fa8818e 100644 --- a/tests/metrics/verifyMongoDBCollectionFlags_test.js +++ b/tests/metrics/verifyMongoDBCollectionFlags_test.js @@ -74,9 +74,6 @@ Scenario( Scenario( 'PMM-T1208 - Verify metrics of MongoDB added with default flags @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -102,8 +99,6 @@ Scenario( + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { const collectorsToDisable = 'topmetrics'; - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors=${collectorsToDisable} --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -132,8 +127,6 @@ Scenario( Scenario( 'PMM-T1210 - Verify metrics of MongoDB with "--enable-all-collectors" was specified @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -156,8 +149,6 @@ Scenario( 'PMM-T1211 - Verify metrics of MongoDB with --disable-collectors="" and --enable-all-collectors were specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors="" --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -181,9 +172,6 @@ Scenario( 'PMM-T1212 - Verify metrics of MongoDB with --disable-collectors="collstats,dbstats,topmetrics" specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; - const collectorsToDisable = 'collstats,dbstats,topmetrics'; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors="${collectorsToDisable}" --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -216,8 +204,6 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -245,8 +231,6 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=5 specified when total collections across db1, db2 and the filters are 6' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=5 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -274,8 +258,6 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=400 specified to allow fetching metrics from all collectors' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -303,8 +285,6 @@ Scenario( 'PMM-9919 Verify smart metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=400 specified to allow fetching metrics from all collectors' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); @@ -387,8 +367,6 @@ Scenario( }) => { I.amOnPage(dashboardPage.mongoDbInstanceOverview.url); dashboardPage.waitForDashboardOpened(); - const randomNumber = Math.floor(Math.random() * 100) + 1; - const mongodb_service_name = `${randomNumber}_mongo_${randomNumber}`; const service_name = 'testing_force_flag'; diff --git a/tests/pages/dashboardPage.js b/tests/pages/dashboardPage.js index a0071bc7b..cb54223ff 100644 --- a/tests/pages/dashboardPage.js +++ b/tests/pages/dashboardPage.js @@ -1017,9 +1017,10 @@ module.exports = { 'Top 5 Hottest Collections by Write (Total)', 'Top 5 Hottest Collections by Read (Rate)', 'Top 5 Hottest Collections by Write (Rate)', - 'Collections statistics for admin (rate)', - 'Collections statistics for admin (summary)', + 'Collections statistics for All (rate)', + 'Collections statistics for All (summary)', 'Collections statistics admin', + 'Collections statistics config', ], }, From 5da1f7c51975452421571b32a1521404f7d69ea1 Mon Sep 17 00:00:00 2001 From: Saikumar Date: Tue, 12 Nov 2024 11:06:14 +0530 Subject: [PATCH 4/7] Updates for api call change --- tests/pages/api/grafanaAPI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pages/api/grafanaAPI.js b/tests/pages/api/grafanaAPI.js index 5b1342ac1..68689b670 100644 --- a/tests/pages/api/grafanaAPI.js +++ b/tests/pages/api/grafanaAPI.js @@ -377,7 +377,7 @@ module.exports = { }; return await I.sendPostRequest( - 'graph/api/ds/query?ds_type=prometheus&requestId=explore_vmt', + 'graph/api/ds/query?ds_type=prometheus&requestId=explore_sbu', body, headers, ); From eba2a186b6064514594c5c64dab31e7a858ce67f Mon Sep 17 00:00:00 2001 From: Saikumar Date: Fri, 15 Nov 2024 09:03:36 +0530 Subject: [PATCH 5/7] Updates to fix mongo exporter playload type --- .../verifyMongoDBCollectionFlags_test.js | 113 +++++++++--------- tests/pages/api/grafanaAPI.js | 59 ++++++++- 2 files changed, 112 insertions(+), 60 deletions(-) diff --git a/tests/metrics/verifyMongoDBCollectionFlags_test.js b/tests/metrics/verifyMongoDBCollectionFlags_test.js index 41fa8818e..21ea31e21 100644 --- a/tests/metrics/verifyMongoDBCollectionFlags_test.js +++ b/tests/metrics/verifyMongoDBCollectionFlags_test.js @@ -87,10 +87,10 @@ Scenario( assert.ok(!mongoDbOptions.enable_all_collectors, `Was expecting enable_all_collectors to be disabled for Mongo Exporter for service "${mongodb_service_name}"`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); + await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.indexstats, { type: 'service_id', value: service_id }); }, ); @@ -117,10 +117,10 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property with "true"`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); + await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_id', value: service_id }); }, ); @@ -138,10 +138,10 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); await I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); + await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_id', value: service_id }); }, ); @@ -161,10 +161,10 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); + await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_id', value: service_id }); }, ); @@ -193,10 +193,10 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property with "true"`); I.say('Wait 150 seconds for Metrics being collected for the new service'); await I.wait(150); - await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); + await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_id', value: service_id }); }, ); @@ -216,14 +216,14 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db1' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db3' }, { type: 'collection', value: 'col3' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col1' }]); - await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col2' }]); + await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db1' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db3' }, { type: 'collection', value: 'col3' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col1' }]); + await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col2' }]); }, ); @@ -231,7 +231,6 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=5 specified when total collections across db1, db2 and the filters are 6' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=5 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -243,14 +242,14 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db1' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db3' }, { type: 'collection', value: 'col3' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col1' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col2' }]); + await grafanaAPI.checkMetricAbsent(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.topmetrics, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db1' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db3' }, { type: 'collection', value: 'col3' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col1' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col2' }]); }, ); @@ -258,7 +257,6 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=400 specified to allow fetching metrics from all collectors' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -270,14 +268,14 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_name', value: mongodb_service_name }); - await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db1' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db3' }, { type: 'collection', value: 'col3' }]); - await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col1' }]); - await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_name', value: mongodb_service_name }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col2' }]); + await grafanaAPI.checkMetricExist(metrics.dbstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.indexstats, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.topmetrics, { type: 'service_id', value: service_id }); + await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db1' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db3' }, { type: 'collection', value: 'col3' }]); + await grafanaAPI.checkMetricAbsent(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col1' }]); + await grafanaAPI.checkMetricExist(metrics.collstats, [{ type: 'service_id', value: service_id }, { type: 'database', value: 'db2' }, { type: 'collection', value: 'col2' }]); }, ); @@ -285,7 +283,6 @@ Scenario( 'PMM-9919 Verify smart metrics of MongoDB with --stats-collections=db1,db2.col2 & --max-collections-limit=400 specified to allow fetching metrics from all collectors' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -298,21 +295,21 @@ Scenario( assert.ok(mongoDbOptions.enable_all_collectors, `Was expecting Mongo Exporter for service ${mongodb_service_name} to have "enable_all_collectors" property`); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'collstats' }]); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'dbstats' }]); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'diagnostic_data' }]); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'general' }]); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'indexstats' }]); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'replset_status' }]); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: mongodb_service_name }, { type: 'collector', value: 'top' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'collstats' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'dbstats' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'diagnostic_data' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'general' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'indexstats' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'replset_status' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: service_id }, { type: 'collector', value: 'top' }]); await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin remove mongodb ${mongodb_service_name}`)); // Re-add Service with Disable Top metrics, check no smart metrics for Top await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors=topmetrics --max-collections-limit=400 --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); I.say('Wait 180 seconds for Metrics being collected for the new service'); await I.wait(180); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_name', value: `${mongodb_service_name}` }, { type: 'collector', value: 'dbstats' }]); - await grafanaAPI.checkMetricAbsent(smartMetricName, [{ type: 'service_name', value: `${mongodb_service_name}` }, { type: 'collector', value: 'top' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: `${service_id}` }, { type: 'collector', value: 'dbstats' }]); + await grafanaAPI.checkMetricAbsent(smartMetricName, [{ type: 'service_id', value: `${service_id}` }, { type: 'collector', value: 'top' }]); }, ); @@ -378,9 +375,9 @@ Scenario( await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --service-name=${service_name}`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, service_name); - await grafanaAPI.waitForMetric('mongodb_up', { type: 'service_name', value: service_name }, 90); + await grafanaAPI.waitForMetric('mongodb_up', { type: 'service_id', value: service_id }, 90); await I.verifyCommand(`docker exec ${containerName} pmm-admin inventory remove service ${service_id} --force`); - await grafanaAPI.waitForMetricAbsent('mongodb_up', { type: 'service_name', value: service_name }, 90); + await grafanaAPI.waitForMetricAbsent('mongodb_up', { type: 'service_id', value: service_id }, 90); // PMM-T1352 Verify that Node exporter cannot be added by pmm-admin inventory add agent node-exporter with --log-level=fatal await I.verifyCommand(`docker exec ${containerName} pmm-admin inventory add agent node-exporter --log-level=fatal ${pmm_agent_id}`, 'pmm-admin: error: --log-level must be one of "debug","info","warn","error" but got "fatal"', 'fail'); }, diff --git a/tests/pages/api/grafanaAPI.js b/tests/pages/api/grafanaAPI.js index 68689b670..d7c24e0e7 100644 --- a/tests/pages/api/grafanaAPI.js +++ b/tests/pages/api/grafanaAPI.js @@ -360,16 +360,71 @@ module.exports = { // Should be refactored async getMetric(metricName, refineBy) { const uid = await this.getDataSourceUidByName(); + const currentTime = Date.now(); + + let refineByString = ''; + + if (Array.isArray(refineBy)) { + // Handle refineBy as an array of objects + refineByString = refineBy + // Check that type and value are defined + .filter(({ type, value }) => type && value) + .map(({ type, value }) => `${type}="${value}"`) + .join(','); + } else if (refineBy && refineBy.type && refineBy.value) { + // Handle refineBy as a single object with both type and value defined + refineByString = `${refineBy.type}="${refineBy.value}"`; + } + const body = { queries: [ { + refId: 'A', + expr: refineByString ? `${metricName}{${refineByString}}` : metricName, + range: true, + instant: false, + datasource: { + type: 'prometheus', + uid, + }, + editorMode: 'builder', + legendFormat: '__auto', + useBackend: false, + disableTextWrap: false, + fullMetaSearch: false, + includeNullMetadata: true, + requestId: '17102A', + utcOffsetSec: 19800, + interval: '', + datasourceId: 1, + intervalMs: 1000, + maxDataPoints: 757, + }, + { + refId: 'A-Instant', + expr: refineByString ? `${metricName}{${refineByString}}` : metricName, + range: false, + instant: true, datasource: { + type: 'prometheus', uid, }, - expr: refineBy ? `${metricName}{${refineBy.type}=\"${refineBy.value}\"}` : metricName, + editorMode: 'builder', + legendFormat: '__auto', + useBackend: false, + disableTextWrap: false, + fullMetaSearch: false, + includeNullMetadata: true, + requestId: '17102A', + utcOffsetSec: 19800, + interval: '', + datasourceId: 1, + intervalMs: 1000, + maxDataPoints: 757, }, ], - from: 'now-15m', + from: (currentTime - 5 * 60 * 1000).toString(), + to: currentTime.toString(), }; const headers = { From 8a215d5448eb9e402aee3cb36e872f59b9acf0c3 Mon Sep 17 00:00:00 2001 From: Saikumar Date: Fri, 15 Nov 2024 09:17:55 +0530 Subject: [PATCH 6/7] Updates cleanups --- tests/metrics/verifyMongoDBCollectionFlags_test.js | 3 --- tests/pages/api/grafanaAPI.js | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/metrics/verifyMongoDBCollectionFlags_test.js b/tests/metrics/verifyMongoDBCollectionFlags_test.js index 21ea31e21..f577fa3b9 100644 --- a/tests/metrics/verifyMongoDBCollectionFlags_test.js +++ b/tests/metrics/verifyMongoDBCollectionFlags_test.js @@ -127,7 +127,6 @@ Scenario( Scenario( 'PMM-T1210 - Verify metrics of MongoDB with "--enable-all-collectors" was specified @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -149,7 +148,6 @@ Scenario( 'PMM-T1211 - Verify metrics of MongoDB with --disable-collectors="" and --enable-all-collectors were specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --disable-collectors="" --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); @@ -204,7 +202,6 @@ Scenario( 'PMM-T1213 - Verify metrics of MongoDB with --stats-collections=db1,db2.col2 specified' + ' @mongodb-exporter', async ({ I, inventoryAPI, grafanaAPI }) => { - await I.say(await I.verifyCommand(`docker exec ${containerName} pmm-admin add mongodb --agent-password='testing' --password=${pmm_user_mongodb.password} --username=${pmm_user_mongodb.username} --enable-all-collectors --stats-collections=db1,db2.col2 --service-name=${mongodb_service_name} --replication-set=rs0s`)); const { service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); diff --git a/tests/pages/api/grafanaAPI.js b/tests/pages/api/grafanaAPI.js index 73e0e8ea3..4a217d6a9 100644 --- a/tests/pages/api/grafanaAPI.js +++ b/tests/pages/api/grafanaAPI.js @@ -400,8 +400,8 @@ module.exports = { { refId: 'A-Instant', expr: refineBy ? `${metricName}{${refineBy.type}="${refineBy.value}"}` : metricName, - range: true, - instant: false, + range: false, + instant: true, datasource: { type: 'prometheus', uid, From aabc08c34f958855570b8cd5f2b6c7fdc8cec0ff Mon Sep 17 00:00:00 2001 From: Saikumar Date: Fri, 15 Nov 2024 10:04:42 +0530 Subject: [PATCH 7/7] Updates for dashboard elements --- tests/metrics/verifyMongoDBExperimental_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/metrics/verifyMongoDBExperimental_test.js b/tests/metrics/verifyMongoDBExperimental_test.js index e382b4e04..a36d9ee14 100644 --- a/tests/metrics/verifyMongoDBExperimental_test.js +++ b/tests/metrics/verifyMongoDBExperimental_test.js @@ -55,6 +55,6 @@ Scenario( I.amOnPage(I.buildUrlWithParams(dashboardPage.mongoDbOplogDetails.clearUrl, { from: 'now-5m', service_name: mongodb_service_name_ac })); dashboardPage.waitForDashboardOpened(); await dashboardPage.verifyMetricsExistence(dashboardPage.mongoDbOplogDetails.metrics); - await dashboardPage.verifyThereAreNoGraphsWithoutData(1); + await dashboardPage.verifyThereAreNoGraphsWithoutData(2); }, );