From 6d0a2218f5ba08acbd0b84b8c243e35156e921f5 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Aug 2019 12:02:35 +0200 Subject: [PATCH 1/6] [ML] Update mock to reflect to stats structure. --- .../data_frame_transform_list_row.json | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__mocks__/data_frame_transform_list_row.json b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__mocks__/data_frame_transform_list_row.json index 5165c693326a..6723e8f749e8 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__mocks__/data_frame_transform_list_row.json +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__mocks__/data_frame_transform_list_row.json @@ -1,19 +1,36 @@ { "config": { "id": "fq_date_histogram_1m_1441", - "source": { "index": ["farequote-2019"], "query": { "match_all": {} } }, - "dest": { "index": "fq_date_histogram_1m_1441" }, + "source": { + "index": [ + "farequote-2019" + ], + "query": { + "match_all": { } + } + }, + "dest": { + "index": "fq_date_histogram_1m_1441" + }, "pivot": { "group_by": { "@timestamp": { - "date_histogram": { "field": "@timestamp", "calendar_interval": "1m" } + "date_histogram": { + "field": "@timestamp", + "calendar_interval": "1m" + } } }, - "aggregations": { "responsetime.avg": { "avg": { "field": "responsetime" } } } + "aggregations": { + "responsetime.avg": { + "avg": { + "field": "responsetime" + } + } + } }, "version": "8.0.0", - "create_time": 1564388146667, - "mode": "batch" + "create_time": 1564388146667 }, "id": "fq_date_histogram_1m_1441", "checkpointing": { @@ -21,20 +38,12 @@ "checkpoint": 1, "timestamp_millis": 1564388281199 }, - "next": { - "checkpoint": 2, - "indexer_state": "stopped", - "checkpoint_progress": { - "total_docs": 86274, - "docs_remaining": 0, - "percent_complete": 100 - } - }, "operations_behind": 0 }, + "mode": "batch", "stats": { "id": "fq_date_histogram_1m_1441", - "task_state": "stopped", + "state": "stopped", "stats": { "pages_processed": 16, "documents_processed": 86274, @@ -52,15 +61,6 @@ "checkpoint": 1, "timestamp_millis": 1564388281199 }, - "next": { - "checkpoint": 2, - "indexer_state": "stopped", - "checkpoint_progress": { - "total_docs": 86274, - "docs_remaining": 0, - "percent_complete": 100 - } - }, "operations_behind": 0 } } From be8e4e800930b845c2c1bcf2983d17bd45d76d4e Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Aug 2019 12:23:45 +0200 Subject: [PATCH 2/6] [ML] Rename task_state to state. --- .../__snapshots__/expanded_row.test.tsx.snap | 4 +-- .../transform_list/action_delete.tsx | 4 +-- .../components/transform_list/actions.tsx | 4 +-- .../components/transform_list/columns.tsx | 20 ++++++++------- .../components/transform_list/common.test.ts | 8 ++---- .../components/transform_list/common.ts | 25 +++++++------------ .../transform_list/transform_list.tsx | 8 +++--- .../transform_service/delete_transform.ts | 6 ++--- .../transform_service/start_transform.ts | 4 +-- .../transform_service/stop_transform.ts | 4 +-- 10 files changed, 39 insertions(+), 48 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap index 9063535b4445..c4d0b6ea351e 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap @@ -17,7 +17,7 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = }, Object { "description": "stopped", - "title": "task_state", + "title": "state", }, ], "position": "left", @@ -110,7 +110,7 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = }, Object { "description": "stopped", - "title": "task_state", + "title": "state", }, ], "position": "left", diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx index 8787ef49492c..7e88b0b2791a 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx @@ -21,14 +21,14 @@ import { createPermissionFailureMessage, } from '../../../../../privilege/check_privilege'; -import { DataFrameTransformListRow, DATA_FRAME_TASK_STATE } from './common'; +import { DataFrameTransformListRow, DATA_FRAME_STATE } from './common'; interface DeleteActionProps { item: DataFrameTransformListRow; } export const DeleteAction: SFC = ({ item }) => { - const disabled = item.stats.task_state === DATA_FRAME_TASK_STATE.STARTED; + const disabled = item.stats.state === DATA_FRAME_STATE.STARTED; const canDeleteDataFrame: boolean = checkPermission('canDeleteDataFrame'); diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx index 1aaa3df71f80..bfcf5b2541d5 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx @@ -13,7 +13,7 @@ import { createPermissionFailureMessage, } from '../../../../../privilege/check_privilege'; -import { DataFrameTransformListRow, DATA_FRAME_TASK_STATE } from './common'; +import { DataFrameTransformListRow, DATA_FRAME_STATE } from './common'; import { stopTransform } from '../../services/transform_service'; import { StartAction } from './action_start'; @@ -26,7 +26,7 @@ export const getActions = () => { { isPrimary: true, render: (item: DataFrameTransformListRow) => { - if (item.stats.task_state !== DATA_FRAME_TASK_STATE.STARTED) { + if (item.stats.state !== DATA_FRAME_STATE.STARTED) { return ; } diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx index 9455fbe179f1..2b876377bfe8 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx @@ -20,26 +20,28 @@ import { import { DataFrameTransformId } from '../../../../common'; import { getTransformProgress, - DATA_FRAME_TASK_STATE, + DATA_FRAME_STATE, DataFrameTransformListColumn, DataFrameTransformListRow, DataFrameTransformStats, } from './common'; import { getActions } from './actions'; -enum TASK_STATE_COLOR { +enum STATE_COLOR { + aborting = 'warning', failed = 'danger', started = 'primary', stopped = 'hollow', + stopping = 'hollow', } export const getTaskStateBadge = ( - state: DataFrameTransformStats['task_state'], + state: DataFrameTransformStats['state'], reason?: DataFrameTransformStats['reason'] ) => { - const color = TASK_STATE_COLOR[state]; + const color = STATE_COLOR[state]; - if (state === DATA_FRAME_TASK_STATE.FAILED && reason !== undefined) { + if (state === DATA_FRAME_STATE.FAILED && reason !== undefined) { return ( @@ -126,10 +128,10 @@ export const getColumns = ( }, { name: i18n.translate('xpack.ml.dataframe.status', { defaultMessage: 'Status' }), - sortable: (item: DataFrameTransformListRow) => item.stats.task_state, + sortable: (item: DataFrameTransformListRow) => item.stats.state, truncateText: true, render(item: DataFrameTransformListRow) { - return getTaskStateBadge(item.stats.task_state, item.stats.reason); + return getTaskStateBadge(item.stats.state, item.stats.reason); }, width: '100px', }, @@ -170,10 +172,10 @@ export const getColumns = ( {!isBatchTransform && ( - {item.stats.task_state === DATA_FRAME_TASK_STATE.STARTED && ( + {item.stats.state === DATA_FRAME_STATE.STARTED && ( )} - {item.stats.task_state === DATA_FRAME_TASK_STATE.STOPPED && ( + {item.stats.state === DATA_FRAME_STATE.STOPPED && ( )} diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts index 73483b516c7f..b2f17cb6a84a 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts @@ -6,11 +6,7 @@ import mockDataFrameTransformListRow from './__mocks__/data_frame_transform_list_row.json'; -import { - DataFrameTransformListRow, - isCompletedBatchTransform, - DATA_FRAME_TASK_STATE, -} from './common'; +import { DataFrameTransformListRow, isCompletedBatchTransform, DATA_FRAME_STATE } from './common'; describe('Data Frame: isCompletedBatchTransform()', () => { test('isCompletedBatchTransform()', () => { @@ -20,7 +16,7 @@ describe('Data Frame: isCompletedBatchTransform()', () => { const row = mockDataFrameTransformListRow as DataFrameTransformListRow; expect(row.stats.checkpointing.last.checkpoint === 1).toBe(true); expect(row.config.sync === undefined).toBe(true); - expect(row.stats.task_state === DATA_FRAME_TASK_STATE.STOPPED).toBe(true); + expect(row.stats.state === DATA_FRAME_STATE.STOPPED).toBe(true); expect(isCompletedBatchTransform(mockDataFrameTransformListRow)).toBe(true); // adapt the mock config to resemble a non-completed transform. diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts index e99e54442ebf..e8f5bf0aeea3 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts @@ -10,16 +10,14 @@ import { Dictionary } from '../../../../../../common/types/common'; import { DataFrameTransformId, DataFrameTransformPivotConfig } from '../../../../common'; -export enum DATA_FRAME_INDEXER_STATE { - FAILED = 'failed', - STARTED = 'started', - STOPPED = 'stopped', -} - -export enum DATA_FRAME_TASK_STATE { +// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/transforms/DataFrameTransformStats.java#L243 +export enum DATA_FRAME_STATE { + ABORTING = 'aborting', FAILED = 'failed', + INDEXING = 'indexing', STARTED = 'started', STOPPED = 'stopped', + STOPPING = 'stopping', } export enum DATA_FRAME_MODE { @@ -50,9 +48,6 @@ export interface DataFrameTransformStats { }; next?: { checkpoint: number; - // indexer_state is a backend internal attribute - // and should not be considered in the UI. - indexer_state: DATA_FRAME_INDEXER_STATE; checkpoint_progress?: { total_docs: number; docs_remaining: number; @@ -74,9 +69,7 @@ export interface DataFrameTransformStats { trigger_count: number; }; reason?: string; - // task_state is the attribute to check against if a transform - // is running or not. - task_state: DATA_FRAME_TASK_STATE; + state: DATA_FRAME_STATE; } export function getTransformProgress(item: DataFrameTransformListRow) { @@ -93,8 +86,8 @@ export function isDataFrameTransformStats(arg: any): arg is DataFrameTransformSt return ( typeof arg === 'object' && arg !== null && - {}.hasOwnProperty.call(arg, 'task_state') && - Object.values(DATA_FRAME_TASK_STATE).includes(arg.task_state) + {}.hasOwnProperty.call(arg, 'state') && + Object.values(DATA_FRAME_STATE).includes(arg.state) ); } @@ -122,6 +115,6 @@ export function isCompletedBatchTransform(item: DataFrameTransformListRow) { return ( item.stats.checkpointing.last.checkpoint === 1 && item.config.sync === undefined && - item.stats.task_state === DATA_FRAME_TASK_STATE.STOPPED + item.stats.state === DATA_FRAME_STATE.STOPPED ); } diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx index 30e021257dd3..a70b4c059d1e 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx @@ -22,7 +22,7 @@ import { DataFrameTransformListColumn, DataFrameTransformListRow, ItemIdToExpandedRowMap, - DATA_FRAME_TASK_STATE, + DATA_FRAME_STATE, DATA_FRAME_MODE, Query, Clause, @@ -152,7 +152,7 @@ export const DataFrameTransformList: SFC = () => { // filter other clauses, i.e. the mode and status filters if (Array.isArray(c.value)) { // the status value is an array of string(s) e.g. ['failed', 'stopped'] - ts = transforms.filter(transform => c.value.includes(transform.stats.task_state)); + ts = transforms.filter(transform => c.value.includes(transform.stats.state)); } else { ts = transforms.filter(transform => transform.mode === c.value); } @@ -245,10 +245,10 @@ export const DataFrameTransformList: SFC = () => { filters: [ { type: 'field_value_selection', - field: 'state.task_state', + field: 'state.state', name: i18n.translate('xpack.ml.dataframe.statusFilter', { defaultMessage: 'Status' }), multiSelect: 'or', - options: Object.values(DATA_FRAME_TASK_STATE).map(val => ({ + options: Object.values(DATA_FRAME_STATE).map(val => ({ value: val, name: val, view: getTaskStateBadge(val), diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts index ad563a6e40ba..2a65d7a24e8b 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts @@ -11,16 +11,16 @@ import { ml } from '../../../../../services/ml_api_service'; import { refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../../../../common'; import { - DATA_FRAME_TASK_STATE, + DATA_FRAME_STATE, DataFrameTransformListRow, } from '../../components/transform_list/common'; export const deleteTransform = async (d: DataFrameTransformListRow) => { try { - if (d.stats.task_state === DATA_FRAME_TASK_STATE.FAILED) { + if (d.stats.state === DATA_FRAME_STATE.FAILED) { await ml.dataFrame.stopDataFrameTransform( d.config.id, - d.stats.task_state === DATA_FRAME_TASK_STATE.FAILED, + d.stats.state === DATA_FRAME_STATE.FAILED, true ); } diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts index 0e1f7562143c..5ddca1b7880b 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts @@ -11,7 +11,7 @@ import { ml } from '../../../../../services/ml_api_service'; import { refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../../../../common'; import { - DATA_FRAME_TASK_STATE, + DATA_FRAME_STATE, DataFrameTransformListRow, } from '../../components/transform_list/common'; @@ -19,7 +19,7 @@ export const startTransform = async (d: DataFrameTransformListRow) => { try { await ml.dataFrame.startDataFrameTransform( d.config.id, - d.stats.task_state === DATA_FRAME_TASK_STATE.FAILED + d.stats.state === DATA_FRAME_STATE.FAILED ); toastNotifications.addSuccess( i18n.translate('xpack.ml.dataframe.transformList.startTransformSuccessMessage', { diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts index 61550291255c..b359d5709684 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts @@ -11,7 +11,7 @@ import { ml } from '../../../../../services/ml_api_service'; import { refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../../../../common'; import { - DATA_FRAME_TASK_STATE, + DATA_FRAME_STATE, DataFrameTransformListRow, } from '../../components/transform_list/common'; @@ -19,7 +19,7 @@ export const stopTransform = async (d: DataFrameTransformListRow) => { try { await ml.dataFrame.stopDataFrameTransform( d.config.id, - d.stats.task_state === DATA_FRAME_TASK_STATE.FAILED, + d.stats.state === DATA_FRAME_STATE.FAILED, true ); toastNotifications.addSuccess( From a5bd1b26c2938d78b3fcc57da3530326604ec52d Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Aug 2019 12:54:51 +0200 Subject: [PATCH 3/6] [ML] Fix state checks. --- .../components/transform_list/action_delete.tsx | 4 ++-- .../components/transform_list/actions.tsx | 4 ++-- .../components/transform_list/columns.tsx | 17 +++++++++++------ .../components/transform_list/common.test.ts | 8 ++++++-- .../components/transform_list/common.ts | 8 ++++---- .../transform_list/transform_list.tsx | 4 ++-- .../transform_service/delete_transform.ts | 10 +++------- .../transform_service/start_transform.ts | 4 ++-- .../transform_service/stop_transform.ts | 4 ++-- 9 files changed, 34 insertions(+), 29 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx index 7e88b0b2791a..826cc6b75e11 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/action_delete.tsx @@ -21,14 +21,14 @@ import { createPermissionFailureMessage, } from '../../../../../privilege/check_privilege'; -import { DataFrameTransformListRow, DATA_FRAME_STATE } from './common'; +import { DataFrameTransformListRow, DATA_FRAME_TRANSFORM_STATE } from './common'; interface DeleteActionProps { item: DataFrameTransformListRow; } export const DeleteAction: SFC = ({ item }) => { - const disabled = item.stats.state === DATA_FRAME_STATE.STARTED; + const disabled = item.stats.state !== DATA_FRAME_TRANSFORM_STATE.STOPPED; const canDeleteDataFrame: boolean = checkPermission('canDeleteDataFrame'); diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx index bfcf5b2541d5..e6c3da495e6a 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/actions.tsx @@ -13,7 +13,7 @@ import { createPermissionFailureMessage, } from '../../../../../privilege/check_privilege'; -import { DataFrameTransformListRow, DATA_FRAME_STATE } from './common'; +import { DataFrameTransformListRow, DATA_FRAME_TRANSFORM_STATE } from './common'; import { stopTransform } from '../../services/transform_service'; import { StartAction } from './action_start'; @@ -26,7 +26,7 @@ export const getActions = () => { { isPrimary: true, render: (item: DataFrameTransformListRow) => { - if (item.stats.state !== DATA_FRAME_STATE.STARTED) { + if (item.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED) { return ; } diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx index 2b876377bfe8..e5855354e49f 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx @@ -20,7 +20,7 @@ import { import { DataFrameTransformId } from '../../../../common'; import { getTransformProgress, - DATA_FRAME_STATE, + DATA_FRAME_TRANSFORM_STATE, DataFrameTransformListColumn, DataFrameTransformListRow, DataFrameTransformStats, @@ -30,6 +30,7 @@ import { getActions } from './actions'; enum STATE_COLOR { aborting = 'warning', failed = 'danger', + indexing = 'primary', started = 'primary', stopped = 'hollow', stopping = 'hollow', @@ -41,7 +42,7 @@ export const getTaskStateBadge = ( ) => { const color = STATE_COLOR[state]; - if (state === DATA_FRAME_STATE.FAILED && reason !== undefined) { + if (state === DATA_FRAME_TRANSFORM_STATE.FAILED && reason !== undefined) { return ( @@ -172,10 +173,14 @@ export const getColumns = ( {!isBatchTransform && ( - {item.stats.state === DATA_FRAME_STATE.STARTED && ( - - )} - {item.stats.state === DATA_FRAME_STATE.STOPPED && ( + {/* If not stopped or failed show the animated progress bar */} + {item.stats.state !== DATA_FRAME_TRANSFORM_STATE.STOPPED && + item.stats.state !== DATA_FRAME_TRANSFORM_STATE.FAILED && ( + + )} + {/* If stopped or failed show an empty (0%) progress bar */} + {(item.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED || + item.stats.state === DATA_FRAME_TRANSFORM_STATE.FAILED) && ( )} diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts index b2f17cb6a84a..38ac75d46ca9 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.test.ts @@ -6,7 +6,11 @@ import mockDataFrameTransformListRow from './__mocks__/data_frame_transform_list_row.json'; -import { DataFrameTransformListRow, isCompletedBatchTransform, DATA_FRAME_STATE } from './common'; +import { + DataFrameTransformListRow, + isCompletedBatchTransform, + DATA_FRAME_TRANSFORM_STATE, +} from './common'; describe('Data Frame: isCompletedBatchTransform()', () => { test('isCompletedBatchTransform()', () => { @@ -16,7 +20,7 @@ describe('Data Frame: isCompletedBatchTransform()', () => { const row = mockDataFrameTransformListRow as DataFrameTransformListRow; expect(row.stats.checkpointing.last.checkpoint === 1).toBe(true); expect(row.config.sync === undefined).toBe(true); - expect(row.stats.state === DATA_FRAME_STATE.STOPPED).toBe(true); + expect(row.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED).toBe(true); expect(isCompletedBatchTransform(mockDataFrameTransformListRow)).toBe(true); // adapt the mock config to resemble a non-completed transform. diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts index e8f5bf0aeea3..b499efc42ed3 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts @@ -11,7 +11,7 @@ import { Dictionary } from '../../../../../../common/types/common'; import { DataFrameTransformId, DataFrameTransformPivotConfig } from '../../../../common'; // reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/transforms/DataFrameTransformStats.java#L243 -export enum DATA_FRAME_STATE { +export enum DATA_FRAME_TRANSFORM_STATE { ABORTING = 'aborting', FAILED = 'failed', INDEXING = 'indexing', @@ -69,7 +69,7 @@ export interface DataFrameTransformStats { trigger_count: number; }; reason?: string; - state: DATA_FRAME_STATE; + state: DATA_FRAME_TRANSFORM_STATE; } export function getTransformProgress(item: DataFrameTransformListRow) { @@ -87,7 +87,7 @@ export function isDataFrameTransformStats(arg: any): arg is DataFrameTransformSt typeof arg === 'object' && arg !== null && {}.hasOwnProperty.call(arg, 'state') && - Object.values(DATA_FRAME_STATE).includes(arg.state) + Object.values(DATA_FRAME_TRANSFORM_STATE).includes(arg.state) ); } @@ -115,6 +115,6 @@ export function isCompletedBatchTransform(item: DataFrameTransformListRow) { return ( item.stats.checkpointing.last.checkpoint === 1 && item.config.sync === undefined && - item.stats.state === DATA_FRAME_STATE.STOPPED + item.stats.state === DATA_FRAME_TRANSFORM_STATE.STOPPED ); } diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx index a70b4c059d1e..d95c48edbe38 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/transform_list.tsx @@ -22,7 +22,7 @@ import { DataFrameTransformListColumn, DataFrameTransformListRow, ItemIdToExpandedRowMap, - DATA_FRAME_STATE, + DATA_FRAME_TRANSFORM_STATE, DATA_FRAME_MODE, Query, Clause, @@ -248,7 +248,7 @@ export const DataFrameTransformList: SFC = () => { field: 'state.state', name: i18n.translate('xpack.ml.dataframe.statusFilter', { defaultMessage: 'Status' }), multiSelect: 'or', - options: Object.values(DATA_FRAME_STATE).map(val => ({ + options: Object.values(DATA_FRAME_TRANSFORM_STATE).map(val => ({ value: val, name: val, view: getTaskStateBadge(val), diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts index 2a65d7a24e8b..307f32e69afe 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/delete_transform.ts @@ -11,18 +11,14 @@ import { ml } from '../../../../../services/ml_api_service'; import { refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../../../../common'; import { - DATA_FRAME_STATE, + DATA_FRAME_TRANSFORM_STATE, DataFrameTransformListRow, } from '../../components/transform_list/common'; export const deleteTransform = async (d: DataFrameTransformListRow) => { try { - if (d.stats.state === DATA_FRAME_STATE.FAILED) { - await ml.dataFrame.stopDataFrameTransform( - d.config.id, - d.stats.state === DATA_FRAME_STATE.FAILED, - true - ); + if (d.stats.state === DATA_FRAME_TRANSFORM_STATE.FAILED) { + await ml.dataFrame.stopDataFrameTransform(d.config.id, true, true); } await ml.dataFrame.deleteDataFrameTransform(d.config.id); toastNotifications.addSuccess( diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts index 5ddca1b7880b..b96ecfb82bc1 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/start_transform.ts @@ -11,7 +11,7 @@ import { ml } from '../../../../../services/ml_api_service'; import { refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../../../../common'; import { - DATA_FRAME_STATE, + DATA_FRAME_TRANSFORM_STATE, DataFrameTransformListRow, } from '../../components/transform_list/common'; @@ -19,7 +19,7 @@ export const startTransform = async (d: DataFrameTransformListRow) => { try { await ml.dataFrame.startDataFrameTransform( d.config.id, - d.stats.state === DATA_FRAME_STATE.FAILED + d.stats.state === DATA_FRAME_TRANSFORM_STATE.FAILED ); toastNotifications.addSuccess( i18n.translate('xpack.ml.dataframe.transformList.startTransformSuccessMessage', { diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts index b359d5709684..63a68f6c3e40 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/stop_transform.ts @@ -11,7 +11,7 @@ import { ml } from '../../../../../services/ml_api_service'; import { refreshTransformList$, REFRESH_TRANSFORM_LIST_STATE } from '../../../../common'; import { - DATA_FRAME_STATE, + DATA_FRAME_TRANSFORM_STATE, DataFrameTransformListRow, } from '../../components/transform_list/common'; @@ -19,7 +19,7 @@ export const stopTransform = async (d: DataFrameTransformListRow) => { try { await ml.dataFrame.stopDataFrameTransform( d.config.id, - d.stats.state === DATA_FRAME_STATE.FAILED, + d.stats.state === DATA_FRAME_TRANSFORM_STATE.FAILED, true ); toastNotifications.addSuccess( From fbc04752afdb5fba5dafe0cebde9a1090e9cdc6a Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Aug 2019 13:05:34 +0200 Subject: [PATCH 4/6] [ML] Updated snapshots. --- .../__snapshots__/expanded_row.test.tsx.snap | 10 ---------- .../__snapshots__/expanded_row_json_pane.test.tsx.snap | 3 +-- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap index c4d0b6ea351e..9434285ba302 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap @@ -29,10 +29,6 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = "description": "{\\"checkpoint\\":1,\\"timestamp_millis\\":1564388281199}", "title": "last", }, - Object { - "description": "{\\"checkpoint\\":2,\\"indexer_state\\":\\"stopped\\",\\"checkpoint_progress\\":{\\"total_docs\\":86274,\\"docs_remaining\\":0,\\"percent_complete\\":100}}", - "title": "next", - }, Object { "description": "0", "title": "operations_behind", @@ -122,10 +118,6 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = "description": "{\\"checkpoint\\":1,\\"timestamp_millis\\":1564388281199}", "title": "last", }, - Object { - "description": "{\\"checkpoint\\":2,\\"indexer_state\\":\\"stopped\\",\\"checkpoint_progress\\":{\\"total_docs\\":86274,\\"docs_remaining\\":0,\\"percent_complete\\":100}}", - "title": "next", - }, Object { "description": "0", "title": "operations_behind", @@ -195,7 +187,6 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = "index": "fq_date_histogram_1m_1441", }, "id": "fq_date_histogram_1m_1441", - "mode": "batch", "pivot": Object { "aggregations": Object { "responsetime.avg": Object { @@ -244,7 +235,6 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = "index": "fq_date_histogram_1m_1441", }, "id": "fq_date_histogram_1m_1441", - "mode": "batch", "pivot": Object { "aggregations": Object { "responsetime.avg": Object { diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap index 3ff1f2652c3c..86f6e80d8f40 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row_json_pane.test.tsx.snap @@ -46,8 +46,7 @@ exports[`Data Frame: Transform List Expanded Row Minimal } }, \\"version\\": \\"8.0.0\\", - \\"create_time\\": 1564388146667, - \\"mode\\": \\"batch\\" + \\"create_time\\": 1564388146667 }" /> From 6ece13a3b0e3e7dc7d4405a461cda50cb32c9721 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Aug 2019 14:26:59 +0200 Subject: [PATCH 5/6] [ML] Tweak expanded row job details. --- .../__snapshots__/expanded_row.test.tsx.snap | 24 +++-- .../components/transform_list/columns.tsx | 6 +- .../components/transform_list/common.ts | 14 ++- .../transform_list/expanded_row.tsx | 92 +++++++++++++++++-- .../transform_service/get_transforms.ts | 1 - 5 files changed, 117 insertions(+), 20 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap index 9434285ba302..c42d5d7d3ca1 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap @@ -26,12 +26,16 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = Object { "items": Array [ Object { - "description": "{\\"checkpoint\\":1,\\"timestamp_millis\\":1564388281199}", - "title": "last", + "description": 1, + "title": "last.checkpoint", }, Object { - "description": "0", - "title": "operations_behind", + "description": "July 29th 2019, 10:18:01", + "title": "last.timestamp", + }, + Object { + "description": 1564388281199, + "title": "last.timestamp_millis", }, ], "position": "left", @@ -115,12 +119,16 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = Object { "items": Array [ Object { - "description": "{\\"checkpoint\\":1,\\"timestamp_millis\\":1564388281199}", - "title": "last", + "description": 1, + "title": "last.checkpoint", }, Object { - "description": "0", - "title": "operations_behind", + "description": "July 29th 2019, 10:18:01", + "title": "last.timestamp", + }, + Object { + "description": 1564388281199, + "title": "last.timestamp_millis", }, ], "position": "left", diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx index e5855354e49f..313fddc679d2 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/columns.tsx @@ -149,13 +149,17 @@ export const getColumns = ( }, { name: i18n.translate('xpack.ml.dataframe.progress', { defaultMessage: 'Progress' }), - sortable: getTransformProgress, + sortable: getTransformProgress || 0, truncateText: true, render(item: DataFrameTransformListRow) { const progress = getTransformProgress(item); const isBatchTransform = typeof item.config.sync === 'undefined'; + if (progress === undefined && isBatchTransform === true) { + return null; + } + return ( {isBatchTransform && ( diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts index b499efc42ed3..d6b8ca1fbf18 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/common.ts @@ -56,6 +56,13 @@ export interface DataFrameTransformStats { }; operations_behind: number; }; + node?: { + id: string; + name: string; + ephemeral_id: string; + transport_address: string; + attributes: Record; + }; stats: { documents_indexed: number; documents_processed: number; @@ -77,9 +84,9 @@ export function getTransformProgress(item: DataFrameTransformListRow) { return 100; } - return Math.round( - idx(item, _ => _.stats.checkpointing.next.checkpoint_progress.percent_complete) || 0 - ); + const progress = idx(item, _ => _.stats.checkpointing.next.checkpoint_progress.percent_complete); + + return progress !== undefined ? Math.round(progress) : undefined; } export function isDataFrameTransformStats(arg: any): arg is DataFrameTransformStats { @@ -93,7 +100,6 @@ export function isDataFrameTransformStats(arg: any): arg is DataFrameTransformSt export interface DataFrameTransformListRow { id: DataFrameTransformId; - checkpointing: object; config: DataFrameTransformPivotConfig; mode?: string; // added property on client side to allow filtering by this field stats: DataFrameTransformStats; diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.tsx index 893c1c0c350b..0e2091d08ae8 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.tsx @@ -10,6 +10,8 @@ import { EuiTabbedContent } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { formatHumanReadableDateTimeSeconds } from '../../../../../util/date_utils'; + import { DataFrameTransformListRow } from './common'; import { ExpandedRowDetailsPane, SectionConfig } from './expanded_row_details_pane'; import { ExpandedRowJsonPane } from './expanded_row_json_pane'; @@ -24,6 +26,11 @@ function getItemDescription(value: any) { return value.toString(); } +interface Item { + title: string; + description: any; +} + interface Props { item: DataFrameTransformListRow; } @@ -33,19 +40,92 @@ export const ExpandedRow: SFC = ({ item }) => { delete stateValues.stats; delete stateValues.checkpointing; + const stateItems: Item[] = []; + stateItems.push( + { + title: 'id', + description: item.id, + }, + { + title: 'state', + description: item.stats.state, + } + ); + if (item.stats.node !== undefined) { + stateItems.push( + { + title: 'node.id', + description: item.stats.node.id, + }, + { + title: 'node.name', + description: item.stats.node.name, + }, + { + title: 'node.ephemeral_id', + description: item.stats.node.ephemeral_id, + }, + { + title: 'node.transport_address', + description: item.stats.node.transport_address, + }, + { + title: 'node.attributes', + description: getItemDescription(item.stats.node.attributes), + } + ); + } + const state: SectionConfig = { title: 'State', - items: Object.entries(stateValues).map(s => { - return { title: s[0].toString(), description: getItemDescription(s[1]) }; - }), + items: stateItems, position: 'left', }; + const checkpointingItems: Item[] = []; + if (item.stats.checkpointing.last !== undefined) { + checkpointingItems.push({ + title: 'last.checkpoint', + description: item.stats.checkpointing.last.checkpoint, + }); + if (item.stats.checkpointing.last.timestamp_millis !== undefined) { + checkpointingItems.push({ + title: 'last.timestamp', + description: formatHumanReadableDateTimeSeconds( + item.stats.checkpointing.last.timestamp_millis + ), + }); + checkpointingItems.push({ + title: 'last.timestamp_millis', + description: item.stats.checkpointing.last.timestamp_millis, + }); + } + } + + if (item.stats.checkpointing.next !== undefined) { + checkpointingItems.push({ + title: 'next.checkpoint', + description: item.stats.checkpointing.next.checkpoint, + }); + if (item.stats.checkpointing.next.checkpoint_progress !== undefined) { + checkpointingItems.push({ + title: 'next.checkpoint_progress.total_docs', + description: item.stats.checkpointing.next.checkpoint_progress.total_docs, + }); + checkpointingItems.push({ + title: 'next.checkpoint_progress.docs_remaining', + description: item.stats.checkpointing.next.checkpoint_progress.docs_remaining, + }); + checkpointingItems.push({ + title: 'next.checkpoint_progress.percent_complete', + description: item.stats.checkpointing.next.checkpoint_progress.percent_complete, + }); + } + } + const checkpointing: SectionConfig = { title: 'Checkpointing', - items: Object.entries(item.checkpointing).map(s => { - return { title: s[0].toString(), description: getItemDescription(s[1]) }; - }), + items: checkpointingItems, position: 'left', }; diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/get_transforms.ts b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/get_transforms.ts index 51aa36512556..e6245d148e7d 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/get_transforms.ts +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/services/transform_service/get_transforms.ts @@ -89,7 +89,6 @@ export const getTransformsFactory = ( // Table with expandable rows requires `id` on the outer most level reducedtableRows.push({ id: config.id, - checkpointing: stats.checkpointing, config, mode: typeof config.sync !== 'undefined' From 0b0d90fdd671386d4b63246947081f4cb0f09122 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Aug 2019 15:11:57 +0200 Subject: [PATCH 6/6] [ML] Fix timezone for test. --- .../__snapshots__/expanded_row.test.tsx.snap | 4 ++-- .../components/transform_list/expanded_row.test.tsx | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap index c42d5d7d3ca1..1744c2c2635b 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__snapshots__/expanded_row.test.tsx.snap @@ -30,7 +30,7 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = "title": "last.checkpoint", }, Object { - "description": "July 29th 2019, 10:18:01", + "description": "July 29th 2019, 04:18:01", "title": "last.timestamp", }, Object { @@ -123,7 +123,7 @@ exports[`Data Frame: Transform List Minimal initialization 1`] = "title": "last.checkpoint", }, Object { - "description": "July 29th 2019, 10:18:01", + "description": "July 29th 2019, 04:18:01", "title": "last.timestamp", }, Object { diff --git a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.test.tsx b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.test.tsx index 2922381026f7..62ee2a268e31 100644 --- a/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.test.tsx +++ b/x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/expanded_row.test.tsx @@ -6,6 +6,7 @@ import { shallow } from 'enzyme'; import React from 'react'; +import moment from 'moment-timezone'; import { DataFrameTransformListRow } from './common'; import { ExpandedRow } from './expanded_row'; @@ -13,6 +14,15 @@ import { ExpandedRow } from './expanded_row'; import dataFrameTransformListRow from './__mocks__/data_frame_transform_list_row.json'; describe('Data Frame: Transform List ', () => { + // Set timezone to US/Eastern for consistent test results. + beforeEach(() => { + moment.tz.setDefault('US/Eastern'); + }); + + afterEach(() => { + moment.tz.setDefault('Browser'); + }); + test('Minimal initialization', () => { const item: DataFrameTransformListRow = dataFrameTransformListRow;