fix(slo): handle eventual consistency of delete slo data (#181048)

This commit is contained in:
Kevin Delemme 2024-04-17 16:20:53 -04:00 committed by GitHub
parent 20b55e203b
commit 81e3faef2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 19 deletions

View file

@ -118,12 +118,20 @@ export default function ({ getService }: FtrProviderContext) {
.expect(404);
// expect summary and rollup documents to be deleted
await retry.tryForTime(60 * 1000, async () => {
await retry.waitForWithTimeout('SLO summary data is deleted', 60 * 1000, async () => {
const sloSummaryResponseAfterDeletion = await sloEsClient.getSLOSummaryDataById(id);
if (sloSummaryResponseAfterDeletion.hits.hits.length > 0) {
throw new Error('SLO summary data not deleted yet');
}
return true;
});
await retry.waitForWithTimeout('SLO rollup data is deleted', 60 * 1000, async () => {
const sloRollupResponseAfterDeletion = await sloEsClient.getSLORollupDataById(id);
expect(sloSummaryResponseAfterDeletion.hits.hits.length).eql(0);
// sometimes the ingest pipeline ingests one extra document after the transform is stopped
expect(sloRollupResponseAfterDeletion.hits.hits.length <= 1).eql(true);
if (sloRollupResponseAfterDeletion.hits.hits.length > 1) {
throw new Error('SLO rollup data not deleted yet');
}
return true;
});
});
});

View file

@ -80,8 +80,7 @@ export default function ({ getService }: FtrProviderContext) {
await cleanup({ esClient, logger });
});
// FLAKY: https://github.com/elastic/kibana/issues/180982
describe.skip('non partition by SLO', () => {
describe('non partition by SLO', () => {
it('deletes the SLO definition, transforms, ingest pipeline and data', async () => {
const createdSlo = await sloApi.create({
name: 'my custom name',
@ -114,18 +113,17 @@ export default function ({ getService }: FtrProviderContext) {
});
expect(savedObject.total).to.eql(1);
expect(savedObject.saved_objects[0].attributes.id).to.eql(sloId);
const sloRevision = savedObject.saved_objects[0].attributes.revision ?? 1;
// Transforms
const sloTransformId = getSLOTransformId(sloId, 1);
const sloSummaryTransformId = getSLOSummaryTransformId(sloId, 1);
const sloTransformId = getSLOTransformId(sloId, sloRevision);
const sloSummaryTransformId = getSLOSummaryTransformId(sloId, sloRevision);
await transform.api.waitForTransformToExist(sloTransformId);
await transform.api.waitForTransformToExist(sloSummaryTransformId);
// Ingest pipeline
const sloRevision = 1;
const pipelineResponse = await fetchSloSummaryPipeline(esClient, sloId, sloRevision);
const expectedPipeline = `.slo-observability.summary.pipeline-${sloId}-${sloRevision}`;
expect(pipelineResponse[expectedPipeline]).not.to.be(undefined);
expect(pipelineResponse[getSLOSummaryPipelineId(sloId, sloRevision)]).not.to.be(undefined);
// RollUp and Summary data
const sloRollupData = await sloApi.waitForSloData({
@ -154,19 +152,26 @@ export default function ({ getService }: FtrProviderContext) {
await transform.api.getTransform(sloTransformId, 404);
await transform.api.getTransform(sloSummaryTransformId, 404);
// Roll up and summary data
await retry.tryForTime(60 * 1000, async () => {
const sloRollupDataAfterDeletion = await sloApi.getSloData({
sloId,
indexName: SLO_DESTINATION_INDEX_PATTERN,
});
await retry.waitForWithTimeout('SLO summary data is deleted', 60 * 1000, async () => {
const sloSummaryDataAfterDeletion = await sloApi.getSloData({
sloId,
indexName: SLO_SUMMARY_DESTINATION_INDEX_PATTERN,
});
if (sloSummaryDataAfterDeletion.hits.hits.length > 0) {
throw new Error('SLO summary data not deleted yet');
}
return true;
});
expect(sloRollupDataAfterDeletion.hits.hits.length).to.be(0);
expect(sloSummaryDataAfterDeletion.hits.hits.length).to.be(0);
await retry.waitForWithTimeout('SLO rollup data is deleted', 60 * 1000, async () => {
const sloRollupDataAfterDeletion = await sloApi.getSloData({
sloId,
indexName: SLO_DESTINATION_INDEX_PATTERN,
});
if (sloRollupDataAfterDeletion.hits.hits.length > 0) {
throw new Error('SLO rollup data not deleted yet');
}
return true;
});
});
});