Skip to content

Commit

Permalink
[Watcher] Fix flaky functional test (#56393) (#57292)
Browse files Browse the repository at this point in the history
* Give a bit more time for machines on CI

* Remove unnecessary sleep

* Dummy error logs [do not commit to master]

* Revert "Dummy error logs [do not commit to master]"

Also only update data (and call serializer) on a success response, not on an error response.

* Remove common.sleep and rewrite the comment explaining the use of retry.waitFor

* Fix typo

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
jloleysens and elasticmachine authored Feb 11, 2020
1 parent 148c03d commit c7aaa76
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/plugins/es_ui_shared/public/request/np_ready_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export const useRequest = (

const response = await sendRequest(httpClient, requestBody);
const { data: serializedResponseData, error: responseError } = response;
const responseData = deserializer(serializedResponseData);

// If an outdated request has resolved, DON'T update state, but DO allow the processData handler
// to execute side effects like update telemetry.
Expand All @@ -129,7 +128,12 @@ export const useRequest = (
}

setError(responseError);
setData(responseData);

if (!responseError) {
const responseData = deserializer(serializedResponseData);
setData(responseData);
}

setIsLoading(false);
setIsInitialRequest(false);

Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/watcher/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
}),
icon: 'watchesApp',
path: '/app/kibana#/management/elasticsearch/watcher/watches',
showOnHomePage: true,
showOnHomePage: false,
};

home.featureCatalogue.register(watcherHome);
Expand All @@ -85,9 +85,6 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
if (valid) {
watcherESApp.enable();
watcherHome.showOnHomePage = true;
} else {
watcherESApp.disable();
watcherHome.showOnHomePage = false;
}
});
}
Expand Down
21 changes: 17 additions & 4 deletions x-pack/test/functional/apps/watcher/watcher_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,23 @@ export default function({ getService, getPageObjects }) {
}

await browser.setWindowSize(1600, 1000);
// TODO: Remove the retry.try wrapper once https://github.com/elastic/kibana/issues/55985 is resolved
retry.try(async () => {
await PageObjects.common.navigateToApp('watcher');
await testSubjects.find('createWatchButton');

// License values are emitted ES -> Kibana Server -> Kibana Public. The current implementation
// creates a situation where the Watcher plugin may not have received a minimum required license at setup time
// so the public app may not have registered in the UI.
//
// For functional testing this is a problem. The temporary solution is we wait for watcher
// to be visible.
//
// See this issue https://github.com/elastic/kibana/issues/55985.
await retry.waitFor('watcher to display in management UI', async () => {
try {
await PageObjects.common.navigateToApp('watcher');
await testSubjects.find('createWatchButton');
} catch (e) {
return false;
}
return true;
});
});

Expand Down

0 comments on commit c7aaa76

Please sign in to comment.