[ML] Fix flaky Trained Models tests (#125484)

* add extra assertion

* prevent extra call on init

* fix stats call
This commit is contained in:
Dima Arnautov 2022-02-14 17:41:39 +01:00 committed by GitHub
parent 91314e0942
commit b51c87f24c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 9 deletions

View file

@ -81,10 +81,7 @@ export function trainedModelsApiProvider(httpService: HttpService) {
* @param params - Optional query params
*/
getTrainedModelStats(modelId?: string | string[], params?: InferenceStatsQueryParams) {
let model = modelId ?? '_all';
if (Array.isArray(modelId)) {
model = modelId.join(',');
}
const model = (Array.isArray(modelId) ? modelId.join(',') : modelId) || '_all';
return httpService.http<InferenceStatsResponse>({
path: `${apiBasePath}/trained_models/${model}/_stats`,

View file

@ -181,6 +181,7 @@ export const ModelsList: FC = () => {
useEffect(
function updateOnTimerRefresh() {
if (!refresh) return;
fetchModelsData();
},
[refresh]

View file

@ -14,8 +14,6 @@ export default function ({ getService }: FtrProviderContext) {
before(async () => {
await ml.trainedModels.createTestTrainedModels('classification', 15, true);
await ml.trainedModels.createTestTrainedModels('regression', 15);
await ml.securityUI.loginAsMlPowerUser();
await ml.navigation.navigateToTrainedModels();
});
after(async () => {
@ -46,6 +44,7 @@ export default function ({ getService }: FtrProviderContext) {
before(async () => {
await ml.securityUI.loginAsMlPowerUser();
await ml.navigation.navigateToTrainedModels();
await ml.commonUI.waitForRefreshButtonEnabled();
});
after(async () => {
@ -173,6 +172,7 @@ export default function ({ getService }: FtrProviderContext) {
before(async () => {
await ml.securityUI.loginAsMlViewer();
await ml.navigation.navigateToTrainedModels();
await ml.commonUI.waitForRefreshButtonEnabled();
});
after(async () => {

View file

@ -338,5 +338,9 @@ export function MachineLearningCommonUIProvider({
async waitForDatePickerIndicatorLoaded() {
await testSubjects.waitForEnabled('superDatePickerApplyTimeButton');
},
async waitForRefreshButtonEnabled() {
await testSubjects.waitForEnabled('~mlRefreshPageButton');
},
};
}

View file

@ -124,7 +124,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const alerting = MachineLearningAlertingProvider(context, commonUI);
const swimLane = SwimLaneProvider(context);
const trainedModels = TrainedModelsProvider(context, api, commonUI);
const trainedModelsTable = TrainedModelsTableProvider(context);
const trainedModelsTable = TrainedModelsTableProvider(context, commonUI);
const mlNodesPanel = MlNodesPanelProvider(context);
return {

View file

@ -10,7 +10,8 @@ import { ProvidedType } from '@kbn/test';
import { upperFirst } from 'lodash';
import { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../../ftr_provider_context';
import type { FtrProviderContext } from '../../ftr_provider_context';
import type { MlCommonUI } from './common_ui';
export interface TrainedModelRowData {
id: string;
@ -20,7 +21,10 @@ export interface TrainedModelRowData {
export type MlTrainedModelsTable = ProvidedType<typeof TrainedModelsTableProvider>;
export function TrainedModelsTableProvider({ getService }: FtrProviderContext) {
export function TrainedModelsTableProvider(
{ getService }: FtrProviderContext,
mlCommonUI: MlCommonUI
) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
@ -218,6 +222,7 @@ export function TrainedModelsTableProvider({ getService }: FtrProviderContext) {
await testSubjects.existOrFail('mlTrainedModelRowDetails', { timeout: 1000 });
}
});
await mlCommonUI.waitForRefreshButtonEnabled();
}
public async assertTabContent(