Skip to content

Commit

Permalink
update serverless tests, fix helper text for static
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Oct 14, 2024
1 parent 3b939f8 commit 3389784
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const DeploymentSetup: FC<DeploymentSetupProps> = ({
const helperText = useMemo<string | undefined>(() => {
const vcpuRange = deploymentParamsMapper.getVCPURange(config.vCPUUsage);

if (cloudInfo.isCloud && cloudInfo.isMlAutoscalingEnabled) {
if (cloudInfo.isCloud && cloudInfo.isMlAutoscalingEnabled && showNodeInfo) {
// Running in cloud with ML autoscaling enabled
if (config.adaptiveResources) {
// With adaptive resources
Expand Down Expand Up @@ -286,7 +286,7 @@ export const DeploymentSetup: FC<DeploymentSetupProps> = ({
}
}
} else if (
(cloudInfo.isCloud && !cloudInfo.isMlAutoscalingEnabled) ||
(cloudInfo.isCloud && !cloudInfo.isMlAutoscalingEnabled && showNodeInfo) ||
(!cloudInfo.isCloud && showNodeInfo)
) {
// Running in cloud with autoscaling disabled or on-prem
Expand Down Expand Up @@ -387,6 +387,29 @@ export const DeploymentSetup: FC<DeploymentSetupProps> = ({
}
);
}
} else {
// Static allocations are allowed for Search projects
switch (config.vCPUUsage) {
case 'low':
return i18n.translate(
'xpack.ml.trainedModels.modelsList.startDeployment.serverless.lowCpuStaticHelp',
{
defaultMessage:
'This level set resources to {staticVCUs, plural, one {VCU} other {# VCUs}}, which may be suitable for development, testing, and demos depending on your parameters. It is not recommended for production use.',
values: { staticVCUs: vcuRange.static },
}
);
case 'medium':
case 'high':
return i18n.translate(
'xpack.ml.trainedModels.modelsList.startDeployment.serverless.mediumCpuStaticHelp',
{
defaultMessage:
'Your model will consume {staticVCUs, plural, one {VCU} other {# VCUs}}, even when not in use.',
values: { staticVCUs: vcuRange.static },
}
);
}
}
}
}, [
Expand Down
27 changes: 27 additions & 0 deletions x-pack/test/functional/services/ml/trained_models_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,33 @@ export function TrainedModelsTableProvider(
await this.assertAdvancedConfigurationOpen(open);
}

public async assertAdaptiveResourcesSwitchExists(expectExist: boolean) {
if (expectExist) {
await testSubjects.existOrFail('mlModelsStartDeploymentModalAdaptiveResources');
} else {
await testSubjects.missingOrFail('mlModelsStartDeploymentModalAdaptiveResources');
}
}

public async toggleAdaptiveResourcesSwitch(enabled: boolean) {
await mlCommonUI.toggleSwitchIfNeeded(
'mlModelsStartDeploymentModalAdaptiveResources',
enabled
);

await this.assertAdaptiveResourcesSwitchChecked(enabled);
}

public async assertAdaptiveResourcesSwitchChecked(expectedValue: boolean) {
const isChecked = await testSubjects.isEuiSwitchChecked(
'mlModelsStartDeploymentModalAdaptiveResources'
);
expect(isChecked).to.eql(
expectedValue,
`Expected adaptive resources switch to be ${expectedValue ? 'checked' : 'unchecked'}`
);
}

public async startDeploymentWithParams(
modelId: string,
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const ml = getService('ml');
const PageObjects = getPageObjects(['svlCommonPage']);

describe('Trained models list', () => {
describe('Trained models list', function () {
const tinyElser = SUPPORTED_TRAINED_MODELS.TINY_ELSER;

before(async () => {
await PageObjects.svlCommonPage.loginWithPrivilegedRole();
await ml.api.importTrainedModel(tinyElser.name, tinyElser.name);
// Make sure the .ml-stats index is created in advance, see https://github.com/elastic/elasticsearch/issues/65846
await ml.api.assureMlStatsIndexExists();
await ml.api.syncSavedObjects();
});

after(async () => {
await ml.api.deleteAllTrainedModelsES();
});

describe('page navigation', () => {
it('renders trained models list', async () => {
await ml.navigation.navigateToMl();
Expand All @@ -25,18 +34,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.testExecution.logTestStep(
'should display the stats bar and the analytics table with 1 installed trained model and built in elser models in the table'
);
await ml.trainedModels.assertStats(1);
await ml.trainedModels.assertStats(2);
await ml.trainedModelsTable.assertTableIsPopulated();
});
});

describe('trained models table', () => {
const tinyElser = SUPPORTED_TRAINED_MODELS.TINY_ELSER;

before(async () => {
await ml.api.importTrainedModel(tinyElser.name, tinyElser.name);
});

it('sets correct VCU ranges for start model deployment', async () => {
await ml.trainedModelsTable.openStartDeploymentModal(tinyElser.name);
await ml.trainedModelsTable.toggleAdvancedConfiguration(true);
Expand All @@ -54,7 +57,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
await ml.trainedModelsTable.setVCPULevel('high');
await ml.trainedModelsTable.assertVCPUHelperText(
'Your model will scale up to a maximum of 4096 VCUs per hour based on your search or ingest load. It will automatically scale down when demand decreases, and you only pay for the resources you use.'
'Your model will scale up to a maximum of 4,096 VCUs per hour based on your search or ingest load. It will automatically scale down when demand decreases, and you only pay for the resources you use.'
);

// Adaptive resources switch should be checked by default
await ml.trainedModelsTable.assertAdaptiveResourcesSwitchChecked(true);

// Static allocations should be allowed for search projects
await ml.trainedModelsTable.toggleAdaptiveResourcesSwitch(false);

await ml.trainedModelsTable.assertVCPUHelperText(
'Your model will consume 4,096 VCUs, even when not in use.'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['svlCommonPage']);

describe('Trained models list', function () {
const tinyElser = SUPPORTED_TRAINED_MODELS.TINY_ELSER;

before(async () => {
await PageObjects.svlCommonPage.loginWithRole(ServerlessRoleName.PLATFORM_ENGINEER);
await ml.api.importTrainedModel(tinyElser.name, tinyElser.name);
// Make sure the .ml-stats index is created in advance, see https://github.com/elastic/elasticsearch/issues/65846
await ml.api.assureMlStatsIndexExists();
await ml.api.syncSavedObjects();
});

after(async () => {
await ml.api.deleteAllTrainedModelsES();
});

describe('page navigation', () => {
it('renders trained models list', async () => {
await ml.navigation.navigateToMl();
Expand All @@ -28,22 +37,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.testExecution.logTestStep(
'should display the stats bar and the analytics table with one trained model'
);
await ml.trainedModels.assertStats(1);
await ml.trainedModels.assertStats(2);
await ml.trainedModelsTable.assertTableIsPopulated();
});
});

describe('trained models table', () => {
const tinyElser = SUPPORTED_TRAINED_MODELS.TINY_ELSER;

before(async () => {
await ml.api.importTrainedModel(tinyElser.name, tinyElser.name);
});

it('sets correct VCU ranges for start model deployment', async () => {
await ml.trainedModelsTable.openStartDeploymentModal(tinyElser.name);
await ml.trainedModelsTable.toggleAdvancedConfiguration(true);

// Adaptive resources switch should be hidden
await ml.trainedModelsTable.assertAdaptiveResourcesSwitchExists(false);

await ml.testExecution.logTestStep('should have correct default VCU level');
// Assert that the default selected level is Low
await ml.trainedModelsTable.assertVCPULevel('low');
Expand All @@ -57,7 +63,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
await ml.trainedModelsTable.setVCPULevel('high');
await ml.trainedModelsTable.assertVCPUHelperText(
'Your model will scale up to a maximum of 1024 VCUs per hour based on your search or ingest load. It will automatically scale down when demand decreases, and you only pay for the resources you use.'
'Your model will scale up to a maximum of 1,024 VCUs per hour based on your search or ingest load. It will automatically scale down when demand decreases, and you only pay for the resources you use.'
);
});
});
Expand Down

0 comments on commit 3389784

Please sign in to comment.