Skip to content

Commit

Permalink
[ML] Data Frame Analytics trained models: adds functional tests for '…
Browse files Browse the repository at this point in the history
…Deploy Model' action (elastic#163886)

## Summary

Adds functional tests for deploy model action for DFA trained models
with default config and with custom config.

Part of elastic#160712

Flaky test run:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2961
(updated)

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
alvarezmelissa87 and kibanamachine authored Aug 24, 2023
1 parent 2d9b46d commit b2308a9
Show file tree
Hide file tree
Showing 16 changed files with 576 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const AddInferencePipelineFlyout: FC<AddInferencePipelineFlyoutProps> = (
);

return (
<EuiFlyout onClose={onClose} className="mlTrainedModelsInferencePipelineFlyout" size="l">
<EuiFlyout onClose={onClose} size="l" data-test-subj="mlTrainedModelsInferencePipelineFlyout">
<EuiFlyoutHeader>
<EuiTitle size="m">
<h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export const AddInferencePipelineFooter: FC<Props> = ({
return (
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButtonEmpty onClick={onClose}>
<EuiButtonEmpty
onClick={onClose}
data-test-subj="mlTrainedModelsInferencePipelineCloseButton"
>
{pipelineCreated ? CLOSE_BUTTON_LABEL : CANCEL_BUTTON_LABEL}
</EuiButtonEmpty>
</EuiFlexItem>
Expand All @@ -66,6 +69,7 @@ export const AddInferencePipelineFooter: FC<Props> = ({
<EuiFlexItem grow={false}>
{nextStep !== undefined ? (
<EuiButton
data-test-subj="mlTrainedModelsInferencePipelineContinueButton"
iconType="arrowRight"
iconSide="right"
onClick={() => setStep(nextStep as AddInferencePipelineSteps)}
Expand All @@ -76,6 +80,7 @@ export const AddInferencePipelineFooter: FC<Props> = ({
</EuiButton>
) : (
<EuiButton
data-test-subj="mlTrainedModelsInferencePipelineCreateButton"
color="success"
disabled={!isContinueButtonEnabled || creatingPipeline || pipelineCreated}
fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ export const AdditionalAdvancedSettings: FC<Props> = memo(

return (
<EuiAccordion
data-test-subj="mlTrainedModelsInferenceAdvancedSettingsAccordion"
id={accordionId}
buttonContent={
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiFlexItem
grow={false}
data-test-subj="mlTrainedModelsInferenceAdvancedSettingsAccordionButton"
>
<FormattedMessage
id="xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.steps.advanced.additionalSettingsLabel"
defaultMessage="Additional settings"
Expand Down Expand Up @@ -110,6 +114,7 @@ export const AdditionalAdvancedSettings: FC<Props> = memo(
}
>
<EuiTextArea
data-test-subj="mlTrainedModelsInferenceAdvancedSettingsConditionTextArea"
aria-label={i18n.translate(
'xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.steps.advanced.conditionAriaLabel',
{ defaultMessage: 'Optional condition for running the processor' }
Expand Down Expand Up @@ -141,6 +146,7 @@ export const AdditionalAdvancedSettings: FC<Props> = memo(
}
>
<EuiFieldText
data-test-subj="mlTrainedModelsInferenceAdvancedSettingsTagInput"
value={additionalSettings?.tag ?? ''}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleAdditionalSettingsChange({ tag: e.target.value })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const OnFailureConfiguration: FC<Props> = memo(
};

return (
<EuiFlexGroup direction="column">
<EuiFlexGroup direction="column" data-test-subj="mlTrainedModelsInferenceOnFailureStep">
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexItem grow={3}>
Expand Down Expand Up @@ -146,6 +146,7 @@ export const OnFailureConfiguration: FC<Props> = memo(
<EuiFlexItem grow={false}>
<EuiFormRow fullWidth>
<EuiSwitch
data-test-subj={'mlTrainedModelsInferenceIgnoreFailureSwitch'}
label={
<FormattedMessage
id="xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.steps.advanced.ignoreFailureLabel"
Expand All @@ -161,6 +162,7 @@ export const OnFailureConfiguration: FC<Props> = memo(
{ignoreFailure === false ? (
<EuiFormRow>
<EuiSwitch
data-test-subj={'mlTrainedModelsInferenceTakeActionOnFailureSwitch'}
label={
<EuiFlexItem>
<FormattedMessage
Expand Down Expand Up @@ -236,6 +238,7 @@ export const OnFailureConfiguration: FC<Props> = memo(
<>
{!editOnFailure ? (
<EuiCodeBlock
data-test-subj="mlTrainedModelsInferenceOnFailureCodeBlock"
isCopyable={true}
overflowHeight={350}
css={{ height: '350px' }}
Expand All @@ -245,6 +248,7 @@ export const OnFailureConfiguration: FC<Props> = memo(
) : null}
{editOnFailure ? (
<CodeEditor
data-test-subj="mlTrainedModelsInferenceOnFailureEditor"
height={300}
languageId="json"
options={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const PipelineDetails: FC<Props> = memo(
isInvalid={pipelineNameError !== undefined}
>
<EuiFieldText
data-test-subj="mlTrainedModelsInferencePipelineNameInput"
fullWidth
placeholder={i18n.translate(
'xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.steps.configure.namePlaceholder',
Expand Down Expand Up @@ -173,6 +174,7 @@ export const PipelineDetails: FC<Props> = memo(
<EuiTextArea
compressed
fullWidth
data-test-subj="mlTrainedModelsInferencePipelineDescriptionInput"
placeholder={i18n.translate(
'xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.steps.configure.descriptionPlaceholder',
{
Expand Down Expand Up @@ -208,6 +210,7 @@ export const PipelineDetails: FC<Props> = memo(
>
<EuiFieldText
fullWidth
data-test-subj="mlTrainedModelsInferencePipelineTargetFieldInput"
value={targetField}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleConfigChange(e.target.value, 'targetField')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ export const ProcessorConfiguration: FC<Props> = memo(
};

return (
<EuiFlexGroup direction="column">
<EuiFlexGroup
direction="column"
data-test-subj="mlTrainedModelsInferencePipelineProcessorConfigStep"
>
{/* INFERENCE CONFIG */}
<EuiFlexItem>
<EuiFlexGroup>
Expand Down Expand Up @@ -193,6 +196,7 @@ export const ProcessorConfiguration: FC<Props> = memo(
<EuiFlexGroup gutterSize="xs" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj="mlTrainedModelsInferencePipelineInferenceConfigEditButton"
iconType="pencil"
size="xs"
onClick={() => {
Expand Down Expand Up @@ -228,6 +232,7 @@ export const ProcessorConfiguration: FC<Props> = memo(
}
error={inferenceConfigError ?? inferenceConfigError}
isInvalid={inferenceConfigError !== undefined || inferenceConfigError !== undefined}
data-test-subj="mlTrainedModelsInferencePipelineInferenceConfigEditor"
>
{editInferenceConfig ? (
<CodeEditor
Expand All @@ -242,7 +247,10 @@ export const ProcessorConfiguration: FC<Props> = memo(
onChange={handleInferenceConfigChange}
/>
) : (
<EuiCodeBlock isCopyable={true}>
<EuiCodeBlock
isCopyable={true}
data-test-subj="mlTrainedModelsInferencePipelineInferenceConfigBlock"
>
{JSON.stringify(inferenceConfig, null, 2)}
</EuiCodeBlock>
)}
Expand Down Expand Up @@ -311,6 +319,7 @@ export const ProcessorConfiguration: FC<Props> = memo(
<EuiFlexGroup gutterSize="xs" justifyContent="flexStart">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj="mlTrainedModelsInferencePipelineFieldMapEditButton"
iconType="pencil"
size="xs"
onClick={() => {
Expand Down Expand Up @@ -349,10 +358,15 @@ export const ProcessorConfiguration: FC<Props> = memo(
}
error={fieldMapError}
isInvalid={fieldMapError !== undefined}
data-test-subj="mlTrainedModelsInferencePipelineFieldMapEdit"
>
<>
{!editFieldMapping ? (
<EuiCodeBlock isCopyable={true} overflowHeight={350}>
<EuiCodeBlock
isCopyable={true}
overflowHeight={350}
data-test-subj="mlTrainedModelsInferencePipelineFieldMapBlock"
>
{JSON.stringify(fieldMap ?? {}, null, 2)}
</EuiCodeBlock>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export const ReviewAndCreatePipeline: FC<Props> = ({

const configCodeBlock = useMemo(
() => (
<EuiCodeBlock language="json" isCopyable overflowHeight="400px">
<EuiCodeBlock
language="json"
isCopyable
overflowHeight="400px"
data-test-subj="mlTrainedModelsInferenceReviewAndCreateStepConfigBlock"
>
{JSON.stringify(inferencePipeline ?? {}, null, 2)}
</EuiCodeBlock>
),
Expand All @@ -67,7 +72,11 @@ export const ReviewAndCreatePipeline: FC<Props> = ({

return (
<>
<EuiFlexGroup direction="column" gutterSize="s">
<EuiFlexGroup
direction="column"
gutterSize="s"
data-test-subj="mlTrainedModelsInferenceReviewAndCreateStep"
>
<EuiFlexItem grow={3}>
{pipelineCreated === false ? (
<EuiTitle size="s">
Expand All @@ -86,6 +95,7 @@ export const ReviewAndCreatePipeline: FC<Props> = ({
<EuiSpacer size="s" />
{pipelineCreated === true && pipelineError === undefined ? (
<EuiCallOut
data-test-subj="mlTrainedModelsInferenceReviewAndCreateStepSuccessCallout"
title={i18n.translate(
'xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.steps.create.successMessage',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ interface SaveChangesButtonProps {
}

export const SaveChangesButton: FC<SaveChangesButtonProps> = ({ onClick, disabled }) => (
<EuiButtonEmpty size="xs" onClick={onClick} disabled={disabled}>
<EuiButtonEmpty
size="xs"
onClick={onClick}
disabled={disabled}
data-test-subj="mlTrainedModelsInferencePipelineFlyoutSaveChangesButton"
>
{i18n.translate(
'xpack.ml.trainedModels.content.indices.pipelines.addInferencePipelineModal.saveChangesButton',
{ defaultMessage: 'Save changes' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export const TestPipeline: FC<Props> = memo(({ state, sourceIndex }) => {

return (
<>
<EuiFlexGroup direction="column" gutterSize="xs">
<EuiFlexGroup
direction="column"
gutterSize="xs"
data-test-subj="mlTrainedModelsInferenceTestStep"
>
<EuiFlexItem>
<EuiTitle size="s">
<h4>
Expand Down Expand Up @@ -245,6 +249,7 @@ export const TestPipeline: FC<Props> = memo(({ state, sourceIndex }) => {
<>
<EuiResizablePanel grow hasBorder initialSize={50} paddingSize="xs">
<CodeEditor
data-test-subj="mlTrainedModelsInferenceTestDocsEditor"
languageId="json"
options={{
automaticLayout: true,
Expand All @@ -259,7 +264,11 @@ export const TestPipeline: FC<Props> = memo(({ state, sourceIndex }) => {
<EuiResizableButton />

<EuiResizablePanel grow={false} hasBorder initialSize={50} paddingSize="xs">
<EuiCodeBlock language="json" isCopyable className="reviewCodeBlock">
<EuiCodeBlock
language="json"
isCopyable
data-test-subj="mlTrainedModelsInferenceTestResult"
>
{simulatePipelineError
? JSON.stringify(simulatePipelineError, null, 2)
: simulatePipelineResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const validateInferenceConfig = (
}

// If populated, inference config must have the correct model type
if (inferenceConfig && inferenceConfigKeys.length > 0) {
if (modelType && inferenceConfig && inferenceConfigKeys.length > 0) {
if (modelType === inferenceConfigKeys[0]) {
return error;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,11 @@ export function useModelActions({
onModelDeployRequest(model);
},
available: (item) => {
const isDfaTrainedModel = item.metadata?.analytics_config !== undefined;
const isDfaTrainedModel =
item.metadata?.analytics_config !== undefined ||
item.inference_config?.regression !== undefined ||
item.inference_config?.classification !== undefined;

return (
isDfaTrainedModel &&
!isBuiltInModel(item) &&
Expand Down
Loading

0 comments on commit b2308a9

Please sign in to comment.