Skip to content

Commit

Permalink
[8.11] [ML] Add functional tests for Data Drift view (elastic#167911) (
Browse files Browse the repository at this point in the history
…elastic#168756)

# Backport

This will backport the following commits from `main` to `8.11`:
- [[ML] Add functional tests for Data Drift view
(elastic#167911)](elastic#167911)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Quynh Nguyen
(Quinn)","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-12T22:52:25Z","message":"[ML]
Add functional tests for Data Drift view (elastic#167911)\n\nCo-authored-by:
Kibana Machine
<[email protected]>","sha":"f28349faf19d78bb679918297742a0bf7cb064f5","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","test_ui_functional","release_note:skip","v8.11.0","v8.12.0","v8.11.1"],"number":167911,"url":"https://github.com/elastic/kibana/pull/167911","mergeCommit":{"message":"[ML]
Add functional tests for Data Drift view (elastic#167911)\n\nCo-authored-by:
Kibana Machine
<[email protected]>","sha":"f28349faf19d78bb679918297742a0bf7cb064f5"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167911","number":167911,"mergeCommit":{"message":"[ML]
Add functional tests for Data Drift view (elastic#167911)\n\nCo-authored-by:
Kibana Machine
<[email protected]>","sha":"f28349faf19d78bb679918297742a0bf7cb064f5"}}]}]
BACKPORT-->

Co-authored-by: Quynh Nguyen (Quinn) <[email protected]>
  • Loading branch information
kibanamachine and qn895 authored Oct 13, 2023
1 parent 9f96d73 commit f611a41
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export const DataDriftOverviewTable = ({

return (
<EuiButtonIcon
data-test-subj={`dataDriftToggleDetails-${
itemIdToExpandedRowMapValues[item.featureName] ? 'expanded' : 'collapsed'
}`}
onClick={() => toggleDetails(item)}
aria-label={itemIdToExpandedRowMapValues[item.featureName] ? COLLAPSE_ROW : EXPAND_ROW}
iconType={itemIdToExpandedRowMapValues[item.featureName] ? 'arrowDown' : 'arrowRight'}
Expand Down Expand Up @@ -149,7 +152,10 @@ export const DataDriftOverviewTable = ({
'data-test-subj': 'mlDataDriftOverviewTableDriftDetected',
sortable: true,
textOnly: true,
render: (driftDetected: boolean) => {
render: (driftDetected: boolean, item) => {
// @ts-expect-error currently ES two_sided does return string NaN, will be fixed
// NaN happens when the distributions are non overlapping. This means there is a drift.
if (item.similarityTestPValue === 'NaN') return dataComparisonYesLabel;
return <span>{driftDetected ? dataComparisonYesLabel : dataComparisonNoLabel}</span>;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ export const PageHeader: FC = () => {

return (
<EuiPageHeader
pageTitle={<div css={dataViewTitleHeader}>{dataView.getName()}</div>}
pageTitle={
<div data-test-subj={'mlDataDriftPageDataViewTitle'} css={dataViewTitleHeader}>
{dataView.getName()}
</div>
}
rightSideItems={[
<EuiFlexGroup gutterSize="s" data-test-subj="dataComparisonTimeRangeSelectorSection">
{hasValidTimeField ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
* formatSignificanceLevel
* @param significanceLevel
*/
export const formatSignificanceLevel = (significanceLevel: number) => {
export const formatSignificanceLevel = (significanceLevel: number | 'NaN') => {
// NaN happens when the distributions are non overlapping. This means there is a drift, and the p-value would be astronomically small.
if (significanceLevel === 'NaN') return '< 0.000001';
if (typeof significanceLevel !== 'number' || isNaN(significanceLevel)) return '';

if (significanceLevel < 1e-6) {
return '< 0.000001';
} else if (significanceLevel < 0.01) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const DocumentCountWithDualBrush: FC<DocumentCountContentProps> = ({
timeRangeEarliest === undefined ||
timeRangeLatest === undefined
) {
return totalCount !== undefined ? <TotalCountHeader totalCount={totalCount} /> : null;
return totalCount !== undefined ? <TotalCountHeader totalCount={totalCount} id={id} /> : null;
}

const chartPoints: LogRateHistogramItem[] = Object.entries(documentCountStats.buckets).map(
Expand All @@ -166,7 +166,7 @@ export const DocumentCountWithDualBrush: FC<DocumentCountContentProps> = ({
data-test-subj={getDataTestSubject('dataDriftTotalDocCountHeader', id)}
>
<EuiFlexItem>
<TotalCountHeader totalCount={totalCount} approximate={approximate} label={label} />
<TotalCountHeader totalCount={totalCount} approximate={approximate} label={label} id={id} />
</EuiFlexItem>

<EuiFlexGroup gutterSize="m" direction="row" alignItems="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function DataDriftIndexPatternsEditor({
children: (
<EuiFlexItem grow={false}>
<DataViewEditor
key={'reference'}
id={'reference'}
label={
<FormattedMessage
id="xpack.ml.dataDrift.indexPatternsEditor.referenceData"
Expand Down Expand Up @@ -274,7 +274,7 @@ export function DataDriftIndexPatternsEditor({
children: (
<EuiFlexItem grow={false}>
<DataViewEditor
key={'comparison'}
id={'comparison'}
label={
<FormattedMessage
id="xpack.ml.dataDrift.indexPatternsEditor.comparisonDataIndexPatternHelp"
Expand Down Expand Up @@ -329,7 +329,7 @@ export function DataDriftIndexPatternsEditor({
}}
isClearable={false}
isDisabled={comparisonIndexPattern === '' && referenceIndexPattern === ''}
data-test-subj="timestampField"
data-test-subj="mlDataDriftTimestampField"
aria-label={i18n.translate(
'xpack.ml.dataDrift.indexPatternsEditor.timestampSelectAriaLabel',
{
Expand Down Expand Up @@ -389,7 +389,7 @@ export function DataDriftIndexPatternsEditor({
disabled={hasError}
onClick={createDataViewAndRedirectToDataDriftPage.bind(null, true)}
iconType="visTagCloud"
data-test-subj="analyzeDataDriftButton"
data-test-subj="analyzeDataDriftWithoutSavingButton"
aria-label={i18n.translate(
'xpack.ml.dataDrift.indexPatternsEditor.analyzeDataDriftWithoutSavingLabel',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useTableSettings } from '../../data_frame_analytics/pages/analytics_man
import { canAppendWildcard, matchedIndicesDefault } from './data_drift_index_patterns_editor';

interface DataViewEditorProps {
id: string;
label: ReactNode;
dataViewEditorService: DataViewEditorService;
indexPattern: string;
Expand All @@ -42,6 +43,7 @@ const mustMatchError = i18n.translate(
);

export function DataViewEditor({
id,
label,
dataViewEditorService,
indexPattern,
Expand Down Expand Up @@ -131,6 +133,7 @@ export function DataViewEditor({
isInvalid={errorMessage !== undefined}
fullWidth
helpText={helpText}
data-test-subj={`mlDataDriftIndexPatternFormRow-${id ?? ''}`}
>
<EuiFieldText
value={indexPattern}
Expand All @@ -149,7 +152,7 @@ export function DataViewEditor({
setIndexPattern(query);
}}
fullWidth
data-test-subj="createIndexPatternTitleInput"
data-test-subj={`mlDataDriftIndexPatternTitleInput-${id ?? ''}`}
placeholder="example-pattern*"
/>
</EuiFormRow>
Expand Down Expand Up @@ -183,6 +186,12 @@ export function DataViewEditor({
columns={columns}
pagination={pagination}
onChange={onTableChange}
data-test-subject={`mlDataDriftIndexPatternTable-${id ?? ''}`}
rowProps={(item) => {
return {
'data-test-subj': `mlDataDriftIndexPatternTableRow row-${id}`,
};
}}
/>
</EuiFlexItem>
</EuiFlexGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const DataDriftIndexOrSearchRedirect: FC = () => {
iconType="plusInCircleFilled"
onClick={() => navigateToPath(createPath(ML_PAGES.DATA_DRIFT_CUSTOM))}
disabled={!canEditDataView}
data-test-subj={'dataDriftCreateDataViewButton'}
>
<FormattedMessage
id="xpack.ml.dataDrift.createDataViewButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
: []),
{
id: 'models_map',
'data-test-subj': 'mlTrainedModelsMap',
'data-test-subj': 'mlTrainedModelMap',
name: (
<FormattedMessage
id="xpack.ml.trainedModels.modelsList.expandedRow.modelsMapLabel"
defaultMessage="Models map"
/>
),
content: (
<div data-test-subj={'mlTrainedModelDetailsContent'}>
<div data-test-subj={'mlTrainedModelMapContent'}>
<EuiSpacer size={'s'} />
<EuiFlexItem css={{ height: 300 }}>
<JobMap
Expand Down
Loading

0 comments on commit f611a41

Please sign in to comment.