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] Add delay in telemetry test #75162

Merged
merged 10 commits into from
Aug 21, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
import { makeChecksWithStatus } from './helper/make_checks';

const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
Expand Down Expand Up @@ -84,6 +86,7 @@ export default function ({ getService }: FtrProviderContext) {
after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank'));

beforeEach(async () => {
await delay(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the delay still needed since we've removed the check for the API response and are now just checking the response code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

await es.indices.refresh();
});

Expand Down Expand Up @@ -119,6 +122,8 @@ export default function ({ getService }: FtrProviderContext) {
});

it('should receive expected results after calling overview logging', async () => {
// wait few seconds to make sure data is refreshed, just to avoid flakiness
await delay(2000);
// call overview page
const { body: result } = await supertest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might make sense to try wrapping this supertest call in a retry block instead of hardcoding delay values. In the past when I have attempted to implement similar solutions I have usually gotten pushback because it goes against the typical pattern used when trying to keep these tests maintainable. cc @spalger

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern isn't about consistency, it's about the fact that the delay is only necessary if there's something we should be waiting for but we're not waiting for it.

What should these tests be waiting for? Can we add a wait for that thing? If we can't, then we can try retrying.

Delay's seem to work today, but they age out as performance characteristics change and become very difficult to maintain over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, will do that

.post(API_URLS.LOG_PAGE_VIEW)
Expand Down