Skip to content

Commit

Permalink
More robust checks on transform's state
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed May 4, 2023
1 parent 25d2372 commit a0b419d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 58 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/transform/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ With PATH_TO_CONFIG and other options as follows.
edit, clone | `test/functional/apps/transform/edit_clone/config.ts`
feature controls | `test/functional/apps/transform/feature_controls/config.ts`
permissions | `test/functional/apps/transform/permissions/config.ts`
start, reset, delete | `test/functional/apps/transform/actions/config.ts`
actions | `test/functional/apps/transform/actions/config.ts`

1. Functional UI tests with `Basic` license:

Expand All @@ -133,7 +133,7 @@ With PATH_TO_CONFIG and other options as follows.
edit, clone | `test/functional_basic/apps/transform/edit_clone/config.ts`
feature controls | `test/functional_basic/apps/transform/feature_controls/config.ts`
permissions | `test/functional_basic/apps/transform/permissions/config.ts`
start, reset, delete | `test/functional_basic/apps/transform/actions/config.ts`
actions | `test/functional_basic/apps/transform/actions/config.ts`

1. API integration tests with `Trial` license:

Expand Down
102 changes: 46 additions & 56 deletions x-pack/test/functional/apps/transform/actions/reauthorizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
* 2.0.
*/

import {
TRANSFORM_HEALTH,
TRANSFORM_HEALTH_LABEL,
TRANSFORM_HEALTH_DESCRIPTION,
} from '@kbn/transform-plugin/common/constants';
import {
import { TRANSFORM_HEALTH_LABEL, TRANSFORM_STATE } from '@kbn/transform-plugin/common/constants';
import type {
TransformLatestConfig,
TransformPivotConfig,
} from '@kbn/transform-plugin/common/types/transform';
import { SecurityCreateApiKeyResponse } from '@elastic/elasticsearch/lib/api/types';
import { FtrProviderContext } from '../../../ftr_provider_context';
import type { SecurityCreateApiKeyResponse } from '@elastic/elasticsearch/lib/api/types';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { getLatestTransformConfig, getPivotTransformConfig } from '../helpers';
import { USER } from '../../../services/transform/security_common';
import { COMMON_REQUEST_HEADERS } from '../../../services/ml/common_api';
Expand All @@ -26,11 +22,9 @@ interface TestDataPivot {
mode: 'batch' | 'continuous';
type: 'pivot';
expected: {
healthDescription: string;
healthLabel: string;
healthStatus: string;
originalState: object;
reauthorizeEnabled: boolean;
originalStatus: string;
reauthorizedState: object;
};
created_by_user: USER;
current_user: USER;
Expand All @@ -42,11 +36,9 @@ interface TestDataLatest {
mode: 'batch' | 'continuous';
type: 'latest';
expected: {
healthDescription: string;
healthLabel: string;
healthStatus: string;
originalState: object;
reauthorizeEnabled: boolean;
originalStatus: string;
reauthorizedState: object;
};
created_by_user: USER;
current_user: USER;
Expand All @@ -70,32 +62,48 @@ export default function ({ getService }: FtrProviderContext) {
describe('reauthorizing', function () {
const PREFIX = 'reauthorizing';
const testDataList: TestData[] = [
// {
// suiteTitle: 'continuous pivot transform (created by viewer, viewed by viewer)',
// originalConfig: getPivotTransformConfig(`${PREFIX}-${USER.TRANSFORM_VIEWER}-1`, true),
// mode: 'continuous',
// type: 'pivot',
// expected: {
// originalState: { status: TRANSFORM_STATE.STOPPED, health: TRANSFORM_HEALTH_LABEL.red },
// reauthorizeEnabled: false,
// reauthorizedState: { status: 'started', health: TRANSFORM_HEALTH_LABEL.green },
// },
// created_by_user: USER.TRANSFORM_VIEWER,
// current_user: USER.TRANSFORM_VIEWER,
// },
{
suiteTitle: 'continuous pivot transform (created by viewer, viewed by viewer)',
originalConfig: getPivotTransformConfig(`${PREFIX}-${USER.TRANSFORM_VIEWER}-1`, true),
mode: 'continuous',
suiteTitle: 'batch pivot transform (created by viewer, viewed by poweruser)',
originalConfig: getPivotTransformConfig(PREFIX, false),
mode: 'batch',
type: 'pivot',
expected: {
healthDescription: TRANSFORM_HEALTH_DESCRIPTION.green,
healthLabel: TRANSFORM_HEALTH_LABEL.green,
healthStatus: TRANSFORM_HEALTH.green,
originalStatus: 'stopped',
reauthorizeEnabled: false,
originalState: { status: TRANSFORM_STATE.STOPPED, health: TRANSFORM_HEALTH_LABEL.red },
reauthorizeEnabled: true,
reauthorizedState: {
status: TRANSFORM_STATE.STOPPED,
progress: '100',
health: TRANSFORM_HEALTH_LABEL.green,
},
},
created_by_user: USER.TRANSFORM_VIEWER,
current_user: USER.TRANSFORM_VIEWER,
current_user: USER.TRANSFORM_POWERUSER,
},
{
suiteTitle: 'continuous pivot transform (created by viewer, authorized by poweruser)',
originalConfig: getPivotTransformConfig(`${PREFIX}-${USER.TRANSFORM_VIEWER}-2`, true),
mode: 'continuous',
type: 'pivot',
expected: {
healthDescription: TRANSFORM_HEALTH_DESCRIPTION.green,
healthLabel: TRANSFORM_HEALTH_LABEL.green,
healthStatus: TRANSFORM_HEALTH.green,
originalStatus: 'stopped',
originalState: { status: TRANSFORM_STATE.STOPPED, health: TRANSFORM_HEALTH_LABEL.red },
reauthorizeEnabled: true,
reauthorizedState: {
status: 'started',
health: TRANSFORM_HEALTH_LABEL.green,
},
},
created_by_user: USER.TRANSFORM_VIEWER,
current_user: USER.TRANSFORM_POWERUSER,
Expand All @@ -106,12 +114,9 @@ export default function ({ getService }: FtrProviderContext) {
mode: 'continuous',
type: 'latest',
expected: {
healthDescription: TRANSFORM_HEALTH_DESCRIPTION.green,
healthLabel: TRANSFORM_HEALTH_LABEL.green,
healthStatus: TRANSFORM_HEALTH.green,
originalStatus: 'started',

originalState: { status: 'started', health: TRANSFORM_HEALTH_LABEL.green },
reauthorizeEnabled: false,
reauthorizedState: { status: 'started', health: TRANSFORM_HEALTH_LABEL.green },
},
created_by_user: USER.TRANSFORM_POWERUSER,
current_user: USER.TRANSFORM_VIEWER,
Expand All @@ -130,18 +135,6 @@ export default function ({ getService }: FtrProviderContext) {
await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');

for (const testData of testDataList) {
if (
testData.expected.healthStatus === TRANSFORM_HEALTH.yellow &&
testData.type === 'pivot'
) {
testData.originalConfig.pivot.aggregations['products.base_price.fail'] = {
avg: {
script: {
source: "def a = doc['non_existing'].value",
},
},
};
}
await transform.api.createTransform(testData.originalConfig.id, testData.originalConfig, {
deferValidation: true,
headers: generateHeaders(apiKeysForTransformUsers.get(testData.created_by_user)!),
Expand Down Expand Up @@ -184,9 +177,10 @@ export default function ({ getService }: FtrProviderContext) {
'should display the original transform in the transform list'
);
await transform.table.filterWithSearchString(transformId, 1);
await transform.table.assertTransformRowFields(transformId, {
status: testData.expected.originalStatus,
});
await transform.table.assertTransformRowFields(
transformId,
testData.expected.originalState
);

if (testData.expected.reauthorizeEnabled) {
await transform.testExecution.logTestStep('should reauthorize the transform');
Expand All @@ -198,15 +192,11 @@ export default function ({ getService }: FtrProviderContext) {
await transform.table.clickTransformRowAction(transformId, 'Reauthorize');
await transform.table.confirmReauthorizeTransform();

await transform.table.assertTransformExpandedRowHealth(
testData.expected.healthDescription,
testData.expected.healthStatus !== TRANSFORM_HEALTH.green
await transform.table.assertTransformRowFields(
transformId,
testData.expected.reauthorizedState
);
await transform.table.assertTransformRowFields(transformId, {
status: 'started',
});
}

await transform.table.clearSearchString(testDataList.length);
});
});
Expand Down

0 comments on commit a0b419d

Please sign in to comment.