Skip to content

Commit 16d0b59

Browse files
authored
Fix arbiter test (#728)
1 parent 58dc45c commit 16d0b59

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

tests/pages/dashboardPage.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1366,12 +1366,17 @@ module.exports = {
13661366
},
13671367

13681368
graphsLocator(metricName) {
1369-
return locate('.panel-title-container h2').withText(metricName);
1369+
return locate('.panel-container').withDescendant(locate('.panel-title-container h2').withText(metricName));
1370+
},
1371+
1372+
graphLegendSeriesValue(metricName, value) {
1373+
return this.graphsLocator(metricName).find('.graph-legend-series').find('td').withText(value);
13701374
},
13711375

13721376
tabLocator(tabName) {
13731377
return `//a[contains(text(), '${tabName}')]`;
13741378
},
1379+
13751380
async waitForAllGraphsToHaveData(timeout = 60) {
13761381
await I.waitForInvisible(this.fields.notAvailableMetrics, timeout);
13771382
await I.waitForInvisible(this.fields.notAvailableDataPoints, timeout);

tests/qa-integration/pmm_psmdb_integration_test.js

+29-15
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,41 @@ Scenario.skip(
169169
},
170170
).retry(2);
171171

172-
Scenario.skip(
173-
'T2317 Verify Wrong Replication Lag by Set values if RS is PSA -( MongoDB Cluster Summary) @pmm-psmdb-arbiter-integration @not-ui-pipeline',
172+
Scenario(
173+
'T1775, T1888 Verify Wrong Replication Lag by Set values if RS is PSA -( MongoDB Cluster Summary) @pmm-psmdb-arbiter-integration @not-ui-pipeline',
174174
async ({
175175
I, dashboardPage,
176176
}) => {
177177
I.amOnPage(`${dashboardPage.mongodbReplicaSetSummaryDashboard.url}&var-replset=rs1`);
178178
dashboardPage.waitForDashboardOpened();
179179

180-
// Grab secs or year lag value from Replication Lag min field in UI
181-
const replLagLocator = '(//a[@data-testid=\'data-testid dashboard-row-title-Replication Lag\']/following::a[contains(text(),\'mongodb_rs2_1\')]/following::td[contains(text(),\' s\') or contains(text(),\' year\')])[1]';
180+
const username = 'dba';
181+
const password = 'test1234';
182+
183+
// Gather Secondary member Service Name from Mongo and PMM admin
184+
const secondaryLagPort = (await I.verifyCommand(`docker exec ${arbiter_container_name} ./psmdb_${version}/bin/mongo --eval rs\.printSecondaryReplicationInfo\\(\\) --username=${username} --password=${password} | awk -F ":" '/source/ {print $3}'`)).trim();
185+
const serviceName = (await I.verifyCommand(`docker exec ${arbiter_container_name} pmm-admin list | awk -v pat='${secondaryLagPort}' '$0~pat {print $2}'`)).trim();
186+
187+
// Check if logs has arbiter connection
188+
await I.asyncWaitFor(async () => {
189+
const checkLog = await I.verifyCommand(`docker exec ${arbiter_container_name} grep -q "level=warning.*some metrics might be unavailable on arbiter nodes" pmm-agent.log; echo $?`);
190+
191+
return checkLog;
192+
}, 60);
182193

183-
await I.waitForElement(replLagLocator, 500);
184-
// Get the text content of the element located
185-
const replLagText = await I.grabTextFrom(replLagLocator);
186-
// Grab only Lag value required from Text
187-
const actualLagValue = +replLagText.split('.', 1);
188-
// Grab actual Lag value required from database
189-
let expectedLagValue = (await I.verifyCommand(`docker exec -w /mongosh/bin/ ${arbiter_container_name} ./mongosh --eval rs\.printSecondaryReplicationInfo\\(\\) | awk '/replLag:/ {print $2}' | cut -c 2`)).trim();
194+
// Check if there are no errors but only warnings
195+
let errorCode = 0;
190196

191-
// Give some threshold increase for actual replication lag, for now 2 secs extra
192-
expectedLagValue = +expectedLagValue + 2;
193-
I.assertBelow(actualLagValue, expectedLagValue, 'ReplicaLag is more than expected lag vaule');
197+
errorCode = (await I.verifyCommand(`docker exec ${arbiter_container_name} grep -q "level=error.*some metrics might be unavailable on arbiter nodes" pmm-agent.log; echo $?`));
198+
I.assertTrue(errorCode.includes(1), `No errors for arbiter setup expected but got error code: ${errorCode}`);
199+
200+
const replLagServiceName = dashboardPage.graphLegendSeriesValue('Replication Lag', 'mongodb_rs2_1_1519');
201+
const replLagSeriesValue = `${replLagServiceName.toXPath()}/following::td[contains(text(),'year')]`;
202+
203+
// Check service name from Replication Lag field in UI
204+
await I.waitForElement(replLagServiceName, 180);
205+
206+
// Check lag value from Replication Lag field is not 'year' in UI
207+
await I.dontSeeElement(replLagSeriesValue, 180);
194208
},
195-
);
209+
).retry(1);

0 commit comments

Comments
 (0)