Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Fix Telemetry Api flaky test #67358

Merged
merged 6 commits into from
Jun 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -53,10 +53,11 @@ export class KibanaTelemetryAdapter {
});
}

public static clearLocalTelemetry() {
this.collector = {};
}

public static countPageView(pageView: PageViewParams) {
if (pageView.refreshTelemetryHistory) {
this.collector = {};
}
const bucketId = this.getBucketToIncrement();
const bucket = this.collector[bucketId];
if (pageView.page === 'Overview') {
Original file line number Diff line number Diff line change
@@ -29,8 +29,12 @@ export const createLogPageViewRoute: UMRestApiRouteFactory = () => ({
request,
response
): Promise<any> => {
const pageView = request.body as PageViewParams;
if (pageView.refreshTelemetryHistory) {
KibanaTelemetryAdapter.clearLocalTelemetry();
}
await KibanaTelemetryAdapter.countNoOfUniqueMonitorAndLocations(callES, savedObjectsClient);
const pageViewResult = KibanaTelemetryAdapter.countPageView(request.body as PageViewParams);
const pageViewResult = KibanaTelemetryAdapter.countPageView(pageView as PageViewParams);

return response.ok({
body: pageViewResult,
Original file line number Diff line number Diff line change
@@ -78,13 +78,18 @@ export default function ({ getService }: FtrProviderContext) {
);

await makeChecksWithStatus(es, 'mixMonitorId', 1, 1, 1, { observer: observer2 }, 'down');
await es.indices.refresh();
});

after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank'));

it('should receive expected results after calling monitor/overview logging', async () => {
beforeEach(async () => {
await es.indices.refresh();
});

it('should receive expected results after calling monitor logging', async () => {
// call monitor page
await supertest
const { body: result } = await supertest
.post(API_URLS.LOG_PAGE_VIEW)
.set('kbn-xsrf', 'true')
.send({
@@ -97,6 +102,23 @@ export default function ({ getService }: FtrProviderContext) {
})
.expect(200);

expect(result).to.eql({
overview_page: 0,
monitor_page: 1,
no_of_unique_monitors: 4,
settings_page: 0,
monitor_frequency: [120, 0.001, 60, 60],
monitor_name_stats: { min_length: 7, max_length: 22, avg_length: 12 },
no_of_unique_observer_locations: 3,
observer_location_name_stats: { min_length: 2, max_length: 7, avg_length: 4.8 },
dateRangeStart: ['now/d'],
dateRangeEnd: ['now/d'],
autoRefreshEnabled: true,
autorefreshInterval: [100],
});
});

it('should receive expected results after calling overview logging', async () => {
// call overview page
const { body: result } = await supertest
.post(API_URLS.LOG_PAGE_VIEW)