mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[FTR analytics] Unskip flaky tests (#132925)
This commit is contained in:
parent
afb18895ca
commit
85638ebb88
8 changed files with 79 additions and 51 deletions
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { ReplaySubject, firstValueFrom, filter, take, toArray } from 'rxjs';
|
||||
import { ReplaySubject, firstValueFrom, filter, take, toArray, map } from 'rxjs';
|
||||
import type { Plugin, CoreSetup, Event } from '@kbn/core/public';
|
||||
import { CustomShipper } from './custom_shipper';
|
||||
import './types';
|
||||
|
@ -31,7 +31,13 @@ export class AnalyticsFTRHelpers implements Plugin {
|
|||
return true;
|
||||
}),
|
||||
take(takeNumberOfEvents),
|
||||
toArray()
|
||||
toArray(),
|
||||
// Sorting the events by timestamp... on CI it's happening an event may occur while the client is still forwarding the early ones...
|
||||
map((_events) =>
|
||||
_events.sort(
|
||||
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { firstValueFrom, ReplaySubject, filter, take, toArray } from 'rxjs';
|
||||
import { firstValueFrom, ReplaySubject, filter, take, toArray, map } from 'rxjs';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { Plugin, CoreSetup, Event } from '@kbn/core/server';
|
||||
import { CustomShipper } from './custom_shipper';
|
||||
|
@ -60,7 +60,13 @@ export class AnalyticsFTRHelpers implements Plugin {
|
|||
return true;
|
||||
}),
|
||||
take(takeNumberOfEvents),
|
||||
toArray()
|
||||
toArray(),
|
||||
// Sorting the events by timestamp... on CI it's happening an event may occur while the client is still forwarding the early ones...
|
||||
map((_events) =>
|
||||
_events.sort(
|
||||
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { BehaviorSubject, firstValueFrom, ReplaySubject } from 'rxjs';
|
||||
import { BehaviorSubject, filter, firstValueFrom, ReplaySubject } from 'rxjs';
|
||||
import { takeWhile, tap, toArray } from 'rxjs/operators';
|
||||
import type { Plugin, CoreSetup, CoreStart, TelemetryCounter, Event } from '@kbn/core/server';
|
||||
import type { Action } from './custom_shipper';
|
||||
|
@ -58,11 +58,15 @@ export class AnalyticsPluginA implements Plugin {
|
|||
firstValueFrom(
|
||||
this.actions$.pipe(
|
||||
takeWhile(() => !found),
|
||||
tap(({ action, meta }) => {
|
||||
found =
|
||||
action === 'reportEvents' &&
|
||||
meta.find((event: Event) => event.event_type === 'test-plugin-lifecycle');
|
||||
tap((action) => {
|
||||
found = isTestPluginLifecycleReportEventAction(action);
|
||||
}),
|
||||
// Filter only the actions that are relevant to this plugin
|
||||
filter(
|
||||
({ action, meta }) =>
|
||||
['optIn', 'extendContext'].includes(action) ||
|
||||
isTestPluginLifecycleReportEventAction({ action, meta })
|
||||
),
|
||||
toArray()
|
||||
)
|
||||
),
|
||||
|
@ -93,3 +97,10 @@ export class AnalyticsPluginA implements Plugin {
|
|||
}
|
||||
public stop() {}
|
||||
}
|
||||
|
||||
function isTestPluginLifecycleReportEventAction({ action, meta }: Action): boolean {
|
||||
return (
|
||||
action === 'reportEvents' &&
|
||||
meta.find((event: Event) => event.event_type === 'test-plugin-lifecycle')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { BehaviorSubject, firstValueFrom, ReplaySubject } from 'rxjs';
|
||||
import { BehaviorSubject, filter, firstValueFrom, ReplaySubject } from 'rxjs';
|
||||
import { takeWhile, tap, toArray } from 'rxjs/operators';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { Plugin, CoreSetup, CoreStart, TelemetryCounter, Event } from '@kbn/core/server';
|
||||
|
@ -90,11 +90,15 @@ export class AnalyticsPluginAPlugin implements Plugin {
|
|||
const actions = await firstValueFrom(
|
||||
actions$.pipe(
|
||||
takeWhile(() => !found),
|
||||
tap(({ action, meta }) => {
|
||||
found =
|
||||
action === 'reportEvents' &&
|
||||
meta.find((event: Event) => event.event_type === 'test-plugin-lifecycle');
|
||||
tap((action) => {
|
||||
found = isTestPluginLifecycleReportEventAction(action);
|
||||
}),
|
||||
// Filter only the actions that are relevant to this plugin
|
||||
filter(
|
||||
({ action, meta }) =>
|
||||
['optIn', 'extendContext'].includes(action) ||
|
||||
isTestPluginLifecycleReportEventAction({ action, meta })
|
||||
),
|
||||
toArray()
|
||||
)
|
||||
);
|
||||
|
@ -125,3 +129,10 @@ export class AnalyticsPluginAPlugin implements Plugin {
|
|||
|
||||
public stop() {}
|
||||
}
|
||||
|
||||
function isTestPluginLifecycleReportEventAction({ action, meta }: Action): boolean {
|
||||
return (
|
||||
action === 'reportEvents' &&
|
||||
meta.find((event: Event) => event.event_type === 'test-plugin-lifecycle')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -87,28 +87,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
|
||||
describe('after setting opt-in', () => {
|
||||
let actions: Action[];
|
||||
let context: Action['meta'];
|
||||
|
||||
before(async () => {
|
||||
actions = await getActions();
|
||||
context = actions[1].meta;
|
||||
});
|
||||
|
||||
it('it should extend the contexts with pid injected by "analytics_plugin_a"', () => {
|
||||
// Validating the remote user_agent because that's the only field that it's added by the FTR plugin.
|
||||
expect(context).to.have.property('user_agent');
|
||||
expect(context.user_agent).to.be.a('string');
|
||||
});
|
||||
|
||||
it('it calls optIn first, then extendContext, followed by reportEvents', async () => {
|
||||
const [optInAction, extendContextAction, ...reportEventsAction] = actions;
|
||||
expect(optInAction).to.eql({ action: 'optIn', meta: true });
|
||||
expect(extendContextAction).to.eql({ action: 'extendContext', meta: context });
|
||||
while (reportEventsAction[0].action === 'extendContext') {
|
||||
// it could happen that a context provider emits a bit delayed
|
||||
reportEventsAction.shift();
|
||||
}
|
||||
reportEventsAction.forEach((entry) => expect(entry.action).to.eql('reportEvents'));
|
||||
expect(extendContextAction).to.have.property('action', 'extendContext');
|
||||
// Checking `some` because there could be more `extendContext` actions for late context providers
|
||||
expect(reportEventsAction.some((entry) => entry.action === 'reportEvents')).to.be(true);
|
||||
});
|
||||
|
||||
it('Initial calls to reportEvents from cached events group the requests by event_type', async () => {
|
||||
|
@ -173,6 +162,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('it should extend the contexts with pid injected by "analytics_plugin_a"', async () => {
|
||||
const [event] = await ebtUIHelper.getLastEvents(1, ['test-plugin-lifecycle']);
|
||||
// Validating the remote user_agent because that's the only field that it's added by the FTR plugin.
|
||||
expect(event.context).to.have.property('user_agent');
|
||||
expect(event.context.user_agent).to.be.a('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -36,9 +36,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
return resp.body;
|
||||
};
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/132907
|
||||
// Failing: See https://github.com/elastic/kibana/issues/132910
|
||||
describe.skip('analytics service: server side', () => {
|
||||
describe('analytics service: server side', () => {
|
||||
it('should see both events enqueued and sent to the shipper', async () => {
|
||||
const telemetryCounters = await getTelemetryCounters(5);
|
||||
expect(telemetryCounters).to.eql([
|
||||
|
@ -82,28 +80,17 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
describe('after setting opt-in', () => {
|
||||
let actions: Action[];
|
||||
let context: Action['meta'];
|
||||
|
||||
before(async () => {
|
||||
actions = await getActions();
|
||||
context = actions[1].meta;
|
||||
});
|
||||
|
||||
it('it should extend the contexts with pid injected by "analytics_plugin_a"', async () => {
|
||||
// Validating the remote PID because that's the only field that it's added by the FTR plugin.
|
||||
expect(context).to.have.property('pid');
|
||||
expect(context.pid).to.be.a('number');
|
||||
});
|
||||
|
||||
it('it calls optIn first, then extendContext, followed by reportEvents', async () => {
|
||||
const [optInAction, extendContextAction, ...reportEventsAction] = actions;
|
||||
expect(optInAction).to.eql({ action: 'optIn', meta: true });
|
||||
expect(extendContextAction).to.eql({ action: 'extendContext', meta: context });
|
||||
while (reportEventsAction[0].action === 'extendContext') {
|
||||
// it could happen that a context provider emits a bit delayed
|
||||
reportEventsAction.shift();
|
||||
}
|
||||
reportEventsAction.forEach((entry) => expect(entry.action).to.eql('reportEvents'));
|
||||
expect(extendContextAction).to.have.property('action', 'extendContext');
|
||||
// Checking `some` because there could be more `extendContext` actions for late context providers
|
||||
expect(reportEventsAction.some((entry) => entry.action === 'reportEvents')).to.be(true);
|
||||
});
|
||||
|
||||
it('Initial calls to reportEvents from cached events group the requests by event_type', async () => {
|
||||
|
@ -168,6 +155,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('it should extend the contexts with pid injected by "analytics_plugin_a"', async () => {
|
||||
const [event] = await ebtServerHelper.getLastEvents(1, ['test-plugin-lifecycle']);
|
||||
// Validating the remote PID because that's the only field that it's added by the FTR plugin.
|
||||
expect(event.context).to.have.property('pid');
|
||||
expect(event.context.pid).to.be.a('number');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,12 +14,16 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
const deployment = getService('deployment');
|
||||
const ebtServerHelper = getService('kibana_ebt_server');
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/132931
|
||||
describe.skip('Core Context Providers', () => {
|
||||
describe('Core Context Providers', () => {
|
||||
let event: Event;
|
||||
before(async () => {
|
||||
// Wait for the 2nd "status_changed" event. At that point all the context providers should be set up.
|
||||
[, event] = await ebtServerHelper.getLastEvents(2, ['core-overall_status_changed']);
|
||||
let i = 2;
|
||||
do {
|
||||
// Wait until we get a GREEN "status_changed" event. At that point all the context providers should be set up.
|
||||
const events = await ebtServerHelper.getLastEvents(i, ['core-overall_status_changed']);
|
||||
event = events[i - 1];
|
||||
i++;
|
||||
} while (event.properties.overall_status_level !== 'available');
|
||||
});
|
||||
|
||||
it('should have the properties provided by the "kibana info" context provider', () => {
|
||||
|
|
|
@ -13,8 +13,7 @@ import { FtrProviderContext } from '../../../services';
|
|||
export default function ({ getService }: FtrProviderContext) {
|
||||
const ebtServerHelper = getService('kibana_ebt_server');
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/132953
|
||||
describe.skip('core-overall_status_changed', () => {
|
||||
describe('core-overall_status_changed', () => {
|
||||
let initialEvent: Event;
|
||||
let secondEvent: Event;
|
||||
|
||||
|
@ -32,6 +31,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
'Kibana is starting up'
|
||||
);
|
||||
expect(initialEvent.properties).to.have.property('overall_status_level', 'degraded');
|
||||
expect(initialEvent.properties).to.have.property('overall_status_summary');
|
||||
expect(initialEvent.properties.overall_status_summary).to.be.a('string');
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue