-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
cloning.ts
297 lines (260 loc) · 12.1 KB
/
cloning.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrProviderContext } from '../../ftr_provider_context';
import {
isLatestTransform,
isPivotTransform,
TransformPivotConfig,
} from '../../../../plugins/transform/common/types/transform';
interface TestData {
type: 'pivot' | 'latest';
suiteTitle: string;
originalConfig: any;
transformId: string;
transformDescription: string;
destinationIndex: string;
expected: any;
}
function getTransformConfig(): TransformPivotConfig {
const date = Date.now();
return {
id: `ec_cloning_1_${date}`,
source: { index: ['ft_ecommerce'] },
pivot: {
group_by: { category: { terms: { field: 'category.keyword' } } },
aggregations: { 'products.base_price.avg': { avg: { field: 'products.base_price' } } },
},
description:
'ecommerce batch transform with avg(products.base_price) grouped by terms(category.keyword)',
frequency: '3s',
settings: {
max_page_search_size: 250,
},
dest: { index: `user-ec_2_${date}` },
};
}
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const transform = getService('transform');
describe('cloning', function () {
const transformConfigWithPivot = getTransformConfig();
// const transformConfigWithLatest = getLatestTransformConfig();
before(async () => {
await esArchiver.loadIfNeeded('ml/ecommerce');
await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');
await transform.api.createAndRunTransform(
transformConfigWithPivot.id,
transformConfigWithPivot
);
// await transform.api.createAndRunTransform(
// transformConfigWithLatest.id,
// transformConfigWithLatest
// );
await transform.testResources.setKibanaTimeZoneToUTC();
await transform.securityUI.loginAsTransformPowerUser();
});
after(async () => {
await transform.testResources.deleteIndexPatternByTitle(transformConfigWithPivot.dest.index);
// await transform.testResources.deleteIndexPatternByTitle(transformConfigWithLatest.dest.index);
await transform.api.deleteIndices(transformConfigWithPivot.dest.index);
// await transform.api.deleteIndices(transformConfigWithLatest.dest.index);
await transform.api.cleanTransformIndices();
});
const testDataList: TestData[] = [
{
type: 'pivot' as const,
suiteTitle: 'clone transform',
originalConfig: transformConfigWithPivot,
transformId: `clone_${transformConfigWithPivot.id}`,
transformDescription: `a cloned transform`,
get destinationIndex(): string {
return `user-${this.transformId}`;
},
expected: {
aggs: {
index: 0,
label: 'products.base_price.avg',
},
indexPreview: {
columns: 10,
rows: 5,
},
groupBy: {
index: 0,
label: 'category',
},
transformPreview: {
column: 0,
values: [
`Men's Accessories`,
`Men's Clothing`,
`Men's Shoes`,
`Women's Accessories`,
`Women's Clothing`,
],
},
},
},
// TODO enable tests when https://github.com/elastic/elasticsearch/issues/67148 is resolved
// {
// type: 'latest' as const,
// suiteTitle: 'clone transform with latest function',
// originalConfig: transformConfigWithLatest,
// transformId: `clone_${transformConfigWithLatest.id}`,
// transformDescription: `a cloned transform`,
// get destinationIndex(): string {
// return `user-${this.transformId}`;
// },
// expected: {
// indexPreview: {
// columns: 10,
// rows: 5,
// },
// transformPreview: {
// column: 0,
// values: [
// 'July 12th 2019, 22:16:19',
// 'July 12th 2019, 22:50:53',
// 'July 12th 2019, 23:06:43',
// 'July 12th 2019, 23:15:22',
// 'July 12th 2019, 23:31:12',
// ],
// },
// },
// },
];
for (const testData of testDataList) {
describe(`${testData.suiteTitle}`, function () {
after(async () => {
await transform.api.deleteIndices(testData.destinationIndex);
await transform.testResources.deleteIndexPatternByTitle(testData.destinationIndex);
});
it('opens the existing transform in the wizard', async () => {
await transform.testExecution.logTestStep('should load the home page');
await transform.navigation.navigateTo();
await transform.management.assertTransformListPageExists();
await transform.testExecution.logTestStep('should display the transforms table');
await transform.management.assertTransformsTableExists();
await transform.testExecution.logTestStep(
'should display the original transform in the transform list'
);
await transform.table.refreshTransformList();
await transform.table.filterWithSearchString(testData.originalConfig.id, 1);
await transform.testExecution.logTestStep('should show the actions popover');
await transform.table.assertTransformRowActions(false);
await transform.testExecution.logTestStep('should display the define pivot step');
await transform.table.clickTransformRowAction('Clone');
await transform.wizard.assertSelectedTransformFunction(testData.type);
await transform.wizard.assertDefineStepActive();
});
it('navigates through the wizard, checks and sets all needed fields', async () => {
await transform.testExecution.logTestStep('should load the index preview');
await transform.wizard.assertIndexPreviewLoaded();
await transform.testExecution.logTestStep('should show the index preview');
await transform.wizard.assertIndexPreview(
testData.expected.indexPreview.columns,
testData.expected.indexPreview.rows
);
await transform.testExecution.logTestStep('should display the query input');
await transform.wizard.assertQueryInputExists();
await transform.wizard.assertQueryValue('');
// assert define step form
if (isPivotTransform(testData.originalConfig)) {
await transform.testExecution.logTestStep(
'should show the pre-filled group-by configuration'
);
await transform.wizard.assertGroupByEntryExists(
testData.expected.groupBy.index,
testData.expected.groupBy.label
);
await transform.testExecution.logTestStep(
'should show the pre-filled aggs configuration'
);
await transform.wizard.assertAggregationEntryExists(
testData.expected.aggs.index,
testData.expected.aggs.label
);
} else if (isLatestTransform(testData.originalConfig)) {
await transform.testExecution.logTestStep('should show pre-filler unique keys');
await transform.wizard.assertUniqueKeysInputValue(
testData.originalConfig.latest.unique_key
);
await transform.testExecution.logTestStep('should show pre-filler sort field');
await transform.wizard.assertSortFieldInputValue(testData.originalConfig.latest.sort);
}
await transform.testExecution.logTestStep('should show the pivot preview');
await transform.wizard.assertPivotPreviewChartHistogramButtonMissing();
await transform.wizard.assertPivotPreviewColumnValues(
testData.expected.transformPreview.column,
testData.expected.transformPreview.values
);
await transform.testExecution.logTestStep('should load the details step');
await transform.wizard.advanceToDetailsStep();
await transform.testExecution.logTestStep('should input the transform id');
await transform.wizard.assertTransformIdInputExists();
await transform.wizard.assertTransformIdValue('');
await transform.wizard.setTransformId(testData.transformId);
await transform.testExecution.logTestStep('should input the transform description');
await transform.wizard.assertTransformDescriptionInputExists();
await transform.wizard.assertTransformDescriptionValue(
testData.originalConfig.description!
);
await transform.wizard.setTransformDescription(testData.transformDescription);
await transform.testExecution.logTestStep('should input the destination index');
await transform.wizard.assertDestinationIndexInputExists();
await transform.wizard.assertDestinationIndexValue('');
await transform.wizard.setDestinationIndex(testData.destinationIndex);
await transform.testExecution.logTestStep(
'should display the create index pattern switch'
);
await transform.wizard.assertCreateIndexPatternSwitchExists();
await transform.wizard.assertCreateIndexPatternSwitchCheckState(true);
await transform.testExecution.logTestStep('should display the continuous mode switch');
await transform.wizard.assertContinuousModeSwitchExists();
await transform.wizard.assertContinuousModeSwitchCheckState(false);
await transform.testExecution.logTestStep(
'should display the advanced settings and show pre-filled configuration'
);
await transform.wizard.openTransformAdvancedSettingsAccordion();
await transform.wizard.assertTransformFrequencyValue(testData.originalConfig.frequency!);
await transform.wizard.assertTransformMaxPageSearchSizeValue(
testData.originalConfig.settings!.max_page_search_size!
);
await transform.testExecution.logTestStep('should load the create step');
await transform.wizard.advanceToCreateStep();
await transform.testExecution.logTestStep('should display the create and start button');
await transform.wizard.assertCreateAndStartButtonExists();
await transform.wizard.assertCreateAndStartButtonEnabled(true);
await transform.testExecution.logTestStep('should display the create button');
await transform.wizard.assertCreateButtonExists();
await transform.wizard.assertCreateButtonEnabled(true);
await transform.testExecution.logTestStep('should display the copy to clipboard button');
await transform.wizard.assertCopyToClipboardButtonExists();
await transform.wizard.assertCopyToClipboardButtonEnabled(true);
});
it('runs the clone transform and displays it correctly in the job list', async () => {
await transform.testExecution.logTestStep('should create the transform');
await transform.wizard.createTransform();
await transform.testExecution.logTestStep(
'should start the transform and finish processing'
);
await transform.wizard.startTransform();
await transform.wizard.waitForProgressBarComplete();
await transform.testExecution.logTestStep('should return to the management page');
await transform.wizard.returnToManagement();
await transform.testExecution.logTestStep('should display the transforms table');
await transform.management.assertTransformsTableExists();
await transform.testExecution.logTestStep(
'should display the created transform in the transform list'
);
await transform.table.refreshTransformList();
await transform.table.filterWithSearchString(testData.transformId, 1);
});
});
}
});
}