Skip to content

Commit

Permalink
fixing e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrdyn committed Nov 26, 2024
1 parent dd9816e commit 076cb6c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function generateDatasets(
[dataset]: {
count,
percentage: calculatePercentage({
totalDocs: totalDocsMap[dataset] ? totalDocsMap[dataset] + count : 0,
totalDocs: (totalDocsMap[dataset] ?? 0) + count,
count,
}),
},
Expand All @@ -86,7 +86,7 @@ export function generateDatasets(
[dataset]: {
count,
percentage: calculatePercentage({
totalDocs: totalDocsMap[dataset] + (failedMap[dataset]?.count ?? 0),
totalDocs: (totalDocsMap[dataset] ?? 0) + (failedMap[dataset]?.count ?? 0),
count,
}),
},
Expand All @@ -109,7 +109,7 @@ export function generateDatasets(
degradedDocStat: degradedMap[dataset] || DEFAULT_QUALITY_DOC_STATS,
failedDocStat: failedMap[dataset] || DEFAULT_QUALITY_DOC_STATS,
datasetIntegrationMap,
totalDocs: totalDocsMap[dataset] ?? 0,
totalDocs: (totalDocsMap[dataset] ?? 0) + (failedMap[dataset]?.count ?? 0),
})
);
}
Expand All @@ -129,7 +129,8 @@ export function generateDatasets(
integrationsMap[dataStream.integration ?? ''],
degradedDocs: degradedMap[dataset.rawName] || dataset.degradedDocs,
failedDocs: failedMap[dataset.rawName] || dataset.failedDocs,
docsInTimeRange: totalDocsMap[dataset.rawName] ?? 0,
docsInTimeRange:
(totalDocsMap[dataset.rawName] ?? 0) + (failedMap[dataset.rawName]?.count ?? 0),
quality: mapPercentageToQuality(qualityStats),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
const samlAuth = getService('samlAuth');
const roleScopedSupertest = getService('roleScopedSupertest');
const synthtrace = getService('synthtrace');
const retry = getService('retry');
const from = '2024-09-20T11:00:00.000Z';
const to = '2024-09-20T11:01:00.000Z';
const dataStreamType = 'logs';
Expand Down Expand Up @@ -108,9 +109,9 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
.create()
.message('This is a log message')
.timestamp(timestamp)
.dataset(dataset)
.dataset(syntheticsDataset)
.namespace(namespace)
.logLevel('0')
.logLevel('5')
.defaults({
'log.file.path': '/my-service.log',
'service.name': serviceName,
Expand All @@ -120,9 +121,9 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
.create()
.message('This is a log message')
.timestamp(timestamp)
.dataset(syntheticsDataset)
.dataset(dataset)
.namespace(namespace)
.logLevel('5')
.logLevel('0')
.defaults({
'log.file.path': '/my-service.log',
'service.name': serviceName,
Expand All @@ -138,17 +139,19 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
});

it('returns number of failed documents per DataStream', async () => {
const resp = await callApiAs({
roleScopedSupertestWithCookieCredentials: supertestAdminWithCookieCredentials,
apiParams: {
start: from,
end: to,
},
});
await retry.tryForTime(180 * 1000, async () => {
const resp = await callApiAs({
roleScopedSupertestWithCookieCredentials: supertestAdminWithCookieCredentials,
apiParams: {
start: from,
end: new Date().toISOString(),
},
});

expect(resp.body.failedDocs.length).to.be(1);
expect(resp.body.totalDocs[0].dataset).to.be(syntheticsDataStreamName);
expect(resp.body.totalDocs[0].count).to.be(1);
expect(resp.body.failedDocs.length).to.be(1);
expect(resp.body.failedDocs[0].dataset).to.be(syntheticsDataStreamName);
expect(resp.body.failedDocs[0].count).to.be(1);
});
});

it('returns empty when all documents are outside timeRange', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export const customLogLevelProcessor = [
},
];

export const datasetNames = ['synth.1', 'synth.2', 'synth.3'];
export const datasetNames = ['synth.1', 'synth.2', 'synth.3', 'synth.failed'];
export const defaultNamespace = 'default';
export const productionNamespace = 'production';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
defaultNamespace,
defaultNamespace,
defaultNamespace,
defaultNamespace,
productionNamespace,
]);

Expand All @@ -115,11 +116,13 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
const cols = await PageObjects.datasetQuality.parseDatasetTable();
const lastActivityCol = cols['Last activity'];
const activityCells = await lastActivityCol.getCellTexts();
const lastActivityCell = activityCells[activityCells.length - 1];
const restActivityCells = activityCells.slice(0, -1);
const lastActivityDegradedCell = activityCells[activityCells.length - 2];
const lastActivityFailedCell = activityCells[activityCells.length - 1];
const restActivityCells = activityCells.slice(0, -2);

// The first cell of lastActivity should have data
expect(lastActivityCell).to.not.eql(PageObjects.datasetQuality.texts.noActivityText);
expect(lastActivityDegradedCell).to.not.eql(PageObjects.datasetQuality.texts.noActivityText);
expect(lastActivityFailedCell).to.not.eql(PageObjects.datasetQuality.texts.noActivityText);
// The rest of the rows must show no activity
expect(restActivityCells).to.eql([
PageObjects.datasetQuality.texts.noActivityText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function createDegradedFieldsRecord({
});
}

export const datasetNames = ['synth.1', 'synth.2', 'synth.3'];
export const datasetNames = ['synth.1', 'synth.2', 'synth.3', 'synth.failed'];
export const defaultNamespace = 'default';
export const productionNamespace = 'production';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
defaultNamespace,
defaultNamespace,
defaultNamespace,
defaultNamespace,
productionNamespace,
]);

Expand All @@ -118,11 +119,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const cols = await PageObjects.datasetQuality.parseDatasetTable();
const lastActivityCol = cols['Last activity'];
const activityCells = await lastActivityCol.getCellTexts();
const lastActivityCell = activityCells[activityCells.length - 1];
const restActivityCells = activityCells.slice(0, -1);
const lastActivityDegradedCell = activityCells[activityCells.length - 2];
const lastActivityFailedCell = activityCells[activityCells.length - 1];
const restActivityCells = activityCells.slice(0, -2);

// The first cell of lastActivity should have data
expect(lastActivityCell).to.not.eql(PageObjects.datasetQuality.texts.noActivityText);
expect(lastActivityDegradedCell).to.not.eql(PageObjects.datasetQuality.texts.noActivityText);
expect(lastActivityFailedCell).to.not.eql(PageObjects.datasetQuality.texts.noActivityText);
// The rest of the rows must show no activity
expect(restActivityCells).to.eql([
PageObjects.datasetQuality.texts.noActivityText,
Expand All @@ -136,7 +139,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

const degradedDocsCol = cols['Degraded docs (%)'];
const degradedDocsColCellTexts = await degradedDocsCol.getCellTexts();
expect(degradedDocsColCellTexts).to.eql(['0%', '0%', '0%', '100%']);
expect(degradedDocsColCellTexts).to.eql(['0%', '0%', '0%', '100%', '0%']);
});

it('shows failed docs percentage', async () => {
Expand Down

0 comments on commit 076cb6c

Please sign in to comment.