From bd6b09820f9320ee877537b69b876ac5ebf71a26 Mon Sep 17 00:00:00 2001 From: Saikumar Date: Wed, 20 Nov 2024 23:28:53 +0530 Subject: [PATCH] updates, fix flaky test user service_id and also fix prev merge issue. --- tests/metrics/verifyMongoDBCollectionFlags_test.js | 9 +++++---- tests/pages/api/grafanaAPI.js | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/metrics/verifyMongoDBCollectionFlags_test.js b/tests/metrics/verifyMongoDBCollectionFlags_test.js index 78c29635b..030eee6ea 100644 --- a/tests/metrics/verifyMongoDBCollectionFlags_test.js +++ b/tests/metrics/verifyMongoDBCollectionFlags_test.js @@ -302,13 +302,14 @@ Scenario( 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`)); + 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'); - const { new_service_id } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); + const { service_id: new_service_id } = await inventoryAPI + .apiGetNodeInfoByServiceName(SERVICE_TYPE.MONGODB, mongodb_service_name); await I.wait(180); - await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: `${new_service_id}` }, { type: 'collector', value: 'dbstats' }]); - await grafanaAPI.checkMetricAbsent(smartMetricName, [{ type: 'service_id', value: `${new_service_id}` }, { type: 'collector', value: 'top' }]); + await grafanaAPI.checkMetricExist(smartMetricName, [{ type: 'service_id', value: new_service_id }, { type: 'collector', value: 'dbstats' }]); + await grafanaAPI.checkMetricAbsent(smartMetricName, [{ type: 'service_id', value: new_service_id }, { type: 'collector', value: 'top' }]); }, ); diff --git a/tests/pages/api/grafanaAPI.js b/tests/pages/api/grafanaAPI.js index 4a217d6a9..92a44c023 100644 --- a/tests/pages/api/grafanaAPI.js +++ b/tests/pages/api/grafanaAPI.js @@ -373,6 +373,7 @@ module.exports = { // Handle refineBy as a single object with both type and value defined refineByString = `${refineBy.type}="${refineBy.value}"`; } + const body = { queries: [ { @@ -399,7 +400,7 @@ module.exports = { }, { refId: 'A-Instant', - expr: refineBy ? `${metricName}{${refineBy.type}="${refineBy.value}"}` : metricName, + expr: refineByString ? `${metricName}{${refineByString}}` : metricName, range: false, instant: true, datasource: {