Skip to content

Commit d9a4752

Browse files
authored
[ML] Data Frame Analytics: Fix color assertion with risk of percentage being rounded to 0. (#95797)
- Fix color assertion with risk of percentage being rounded to 0. - Better naming of attributes of expected values. - Adds assertions to use the sample size dropdown and randomize query switch.
1 parent d10935c commit d9a4752

File tree

11 files changed

+279
-86
lines changed

11 files changed

+279
-86
lines changed

x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
331331
fullWidth
332332
>
333333
<EuiSelect
334+
data-test-subj="mlScatterplotMatrixSampleSizeSelect"
334335
compressed
335336
options={sampleSizeOptions}
336337
value={fetchSize}
@@ -355,6 +356,7 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
355356
fullWidth
356357
>
357358
<EuiSwitch
359+
data-test-subj="mlScatterplotMatrixRandomizeQuerySwitch"
358360
name="mlScatterplotMatrixRandomizeQuery"
359361
label={randomizeQuery ? TOGGLE_ON : TOGGLE_OFF}
360362
checked={randomizeQuery}

x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export default function ({ getService }: FtrProviderContext) {
1212
const ml = getService('ml');
1313
const editedDescription = 'Edited description';
1414

15-
// FLAKY: https://github.com/elastic/kibana/issues/91450
16-
describe.skip('classification creation', function () {
15+
describe('classification creation', function () {
1716
before(async () => {
1817
await esArchiver.loadIfNeeded('ml/bm_classification');
1918
await ml.testResources.createIndexPatternIfNeeded('ft_bank_marketing', '@timestamp');
@@ -44,18 +43,18 @@ export default function ({ getService }: FtrProviderContext) {
4443
expected: {
4544
rocCurveColorState: [
4645
// tick/grid/axis
47-
{ key: '#DDDDDD', value: 50 },
46+
{ color: '#DDDDDD', percentage: 50 },
4847
// line
49-
{ key: '#98A2B3', value: 30 },
48+
{ color: '#98A2B3', percentage: 30 },
5049
],
5150
scatterplotMatrixColorStats: [
5251
// marker colors
53-
{ key: '#7FC6B3', value: 1 },
54-
{ key: '#88ADD0', value: 0.03 },
52+
{ color: '#7FC6B3', percentage: 1 },
53+
{ color: '#88ADD0', percentage: 0.03 },
5554
// tick/grid/axis
56-
{ key: '#DDDDDD', value: 8 },
57-
{ key: '#D3DAE6', value: 8 },
58-
{ key: '#F5F7FA', value: 20 },
55+
{ color: '#DDDDDD', percentage: 8 },
56+
{ color: '#D3DAE6', percentage: 8 },
57+
{ color: '#F5F7FA', percentage: 15 },
5958
],
6059
row: {
6160
type: 'classification',
@@ -78,6 +77,10 @@ export default function ({ getService }: FtrProviderContext) {
7877
await ml.navigation.navigateToDataFrameAnalytics();
7978

8079
await ml.testExecution.logTestStep('loads the source selection modal');
80+
81+
// Disable anti-aliasing to stabilize canvas image rendering assertions
82+
await ml.commonUI.disableAntiAliasing();
83+
8184
await ml.dataFrameAnalytics.startAnalyticsCreation();
8285

8386
await ml.testExecution.logTestStep(
@@ -106,6 +109,16 @@ export default function ({ getService }: FtrProviderContext) {
106109
await ml.testExecution.logTestStep('displays the include fields selection');
107110
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
108111

112+
await ml.testExecution.logTestStep(
113+
'sets the sample size to 10000 for the scatterplot matrix'
114+
);
115+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixSampleSizeSelectValue('10000');
116+
117+
await ml.testExecution.logTestStep(
118+
'sets the randomize query switch to true for the scatterplot matrix'
119+
);
120+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixRandomizeQueryCheckState(true);
121+
109122
await ml.testExecution.logTestStep('displays the scatterplot matrix');
110123
await ml.dataFrameAnalyticsCreation.assertScatterplotMatrix(
111124
testData.expected.scatterplotMatrixColorStats
@@ -237,6 +250,12 @@ export default function ({ getService }: FtrProviderContext) {
237250
await ml.testExecution.logTestStep('displays the results view for created job');
238251
await ml.dataFrameAnalyticsTable.openResultsView(testData.jobId);
239252
await ml.dataFrameAnalyticsResults.assertClassificationEvaluatePanelElementsExists();
253+
await ml.dataFrameAnalyticsResults.assertClassificationTablePanelExists();
254+
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
255+
await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist();
256+
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
257+
258+
await ml.testExecution.logTestStep('displays the ROC curve chart');
240259
await ml.commonUI.assertColorsInCanvasElement(
241260
'mlDFAnalyticsClassificationExplorationRocCurveChart',
242261
testData.expected.rocCurveColorState,
@@ -247,13 +266,23 @@ export default function ({ getService }: FtrProviderContext) {
247266
// since the returned colors vary quite a bit on each run.
248267
20
249268
);
250-
await ml.dataFrameAnalyticsResults.assertClassificationTablePanelExists();
251-
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
252-
await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist();
253-
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
269+
270+
await ml.testExecution.logTestStep(
271+
'sets the sample size to 10000 for the scatterplot matrix'
272+
);
273+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixSampleSizeSelectValue('10000');
274+
275+
await ml.testExecution.logTestStep(
276+
'sets the randomize query switch to true for the scatterplot matrix'
277+
);
278+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixRandomizeQueryCheckState(true);
279+
280+
await ml.testExecution.logTestStep('displays the scatterplot matrix');
254281
await ml.dataFrameAnalyticsResults.assertScatterplotMatrix(
255282
testData.expected.scatterplotMatrixColorStats
256283
);
284+
285+
await ml.commonUI.resetAntiAliasing();
257286
});
258287

259288
it('displays the analytics job in the map view', async () => {

x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ export default function ({ getService }: FtrProviderContext) {
5252
],
5353
scatterplotMatrixColorsWizard: [
5454
// markers
55-
{ key: '#52B398', value: 25 },
55+
{ color: '#52B398', percentage: 15 },
5656
// grey boilerplate
57-
{ key: '#6A717D', value: 30 },
57+
{ color: '#6A717D', percentage: 33 },
5858
],
5959
scatterplotMatrixColorStatsResults: [
6060
// red markers
61-
{ key: '#D98071', value: 1 },
61+
{ color: '#D98071', percentage: 1 },
6262
// tick/grid/axis, grey markers
63-
{ key: '#6A717D', value: 30 },
64-
{ key: '#D3DAE6', value: 8 },
65-
{ key: '#98A1B3', value: 25 },
63+
{ color: '#6A717D', percentage: 33 },
64+
{ color: '#D3DAE6', percentage: 8 },
65+
{ color: '#98A1B3', percentage: 12 },
6666
// anti-aliasing
67-
{ key: '#F5F7FA', value: 27 },
67+
{ color: '#F5F7FA', percentage: 30 },
6868
],
6969
row: {
7070
type: 'outlier_detection',
@@ -126,6 +126,16 @@ export default function ({ getService }: FtrProviderContext) {
126126
await ml.testExecution.logTestStep('displays the include fields selection');
127127
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
128128

129+
await ml.testExecution.logTestStep(
130+
'sets the sample size to 10000 for the scatterplot matrix'
131+
);
132+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixSampleSizeSelectValue('10000');
133+
134+
await ml.testExecution.logTestStep(
135+
'sets the randomize query switch to true for the scatterplot matrix'
136+
);
137+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixRandomizeQueryCheckState(true);
138+
129139
await ml.testExecution.logTestStep('displays the scatterplot matrix');
130140
await ml.dataFrameAnalyticsCreation.assertScatterplotMatrix(
131141
testData.expected.scatterplotMatrixColorsWizard
@@ -255,9 +265,23 @@ export default function ({ getService }: FtrProviderContext) {
255265
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
256266
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
257267
await ml.dataFrameAnalyticsResults.assertFeatureInfluenceCellNotEmpty();
268+
269+
await ml.testExecution.logTestStep(
270+
'sets the sample size to 10000 for the scatterplot matrix'
271+
);
272+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixSampleSizeSelectValue('10000');
273+
274+
await ml.testExecution.logTestStep(
275+
'sets the randomize query switch to true for the scatterplot matrix'
276+
);
277+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixRandomizeQueryCheckState(true);
278+
279+
await ml.testExecution.logTestStep('displays the scatterplot matrix');
258280
await ml.dataFrameAnalyticsResults.assertScatterplotMatrix(
259281
testData.expected.scatterplotMatrixColorStatsResults
260282
);
283+
284+
await ml.commonUI.resetAntiAliasing();
261285
});
262286

263287
it('displays the analytics job in the map view', async () => {

x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ export default function ({ getService }: FtrProviderContext) {
4242
expected: {
4343
scatterplotMatrixColorStats: [
4444
// some marker colors of the continuous color scale
45-
{ key: '#61AFA3', value: 2 },
46-
{ key: '#D1E5E0', value: 2 },
45+
{ color: '#61AFA3', percentage: 2 },
46+
{ color: '#D1E5E0', percentage: 2 },
4747
// tick/grid/axis
48-
{ key: '#6A717D', value: 10 },
49-
{ key: '#F5F7FA', value: 12 },
50-
{ key: '#D3DAE6', value: 3 },
48+
{ color: '#6A717D', percentage: 10 },
49+
{ color: '#F5F7FA', percentage: 10 },
50+
{ color: '#D3DAE6', percentage: 3 },
5151
],
5252
row: {
5353
type: 'regression',
@@ -71,6 +71,10 @@ export default function ({ getService }: FtrProviderContext) {
7171
await ml.navigation.navigateToDataFrameAnalytics();
7272

7373
await ml.testExecution.logTestStep('loads the source selection modal');
74+
75+
// Disable anti-aliasing to stabilize canvas image rendering assertions
76+
await ml.commonUI.disableAntiAliasing();
77+
7478
await ml.dataFrameAnalytics.startAnalyticsCreation();
7579

7680
await ml.testExecution.logTestStep(
@@ -99,6 +103,16 @@ export default function ({ getService }: FtrProviderContext) {
99103
await ml.testExecution.logTestStep('displays the include fields selection');
100104
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
101105

106+
await ml.testExecution.logTestStep(
107+
'sets the sample size to 10000 for the scatterplot matrix'
108+
);
109+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixSampleSizeSelectValue('10000');
110+
111+
await ml.testExecution.logTestStep(
112+
'sets the randomize query switch to true for the scatterplot matrix'
113+
);
114+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixRandomizeQueryCheckState(true);
115+
102116
await ml.testExecution.logTestStep('displays the scatterplot matrix');
103117
await ml.dataFrameAnalyticsCreation.assertScatterplotMatrix(
104118
testData.expected.scatterplotMatrixColorStats
@@ -229,9 +243,23 @@ export default function ({ getService }: FtrProviderContext) {
229243
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
230244
await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist();
231245
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
246+
247+
await ml.testExecution.logTestStep(
248+
'sets the sample size to 10000 for the scatterplot matrix'
249+
);
250+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixSampleSizeSelectValue('10000');
251+
252+
await ml.testExecution.logTestStep(
253+
'sets the randomize query switch to true for the scatterplot matrix'
254+
);
255+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixRandomizeQueryCheckState(true);
256+
257+
await ml.testExecution.logTestStep('displays the scatterplot matrix');
232258
await ml.dataFrameAnalyticsResults.assertScatterplotMatrix(
233259
testData.expected.scatterplotMatrixColorStats
234260
);
261+
262+
await ml.commonUI.resetAntiAliasing();
235263
});
236264

237265
it('displays the analytics job in the map view', async () => {

x-pack/test/functional/apps/transform/creation_index_pattern.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ export default function ({ getService }: FtrProviderContext) {
161161
id: 'currency',
162162
legend: '1 category',
163163
colorStats: [
164-
{ key: '#000000', value: 10 },
165-
{ key: '#54B399', value: 90 },
164+
{ color: '#000000', percentage: 10 },
165+
{ color: '#54B399', percentage: 90 },
166166
],
167167
},
168168
{
@@ -177,17 +177,17 @@ export default function ({ getService }: FtrProviderContext) {
177177
id: 'customer_gender',
178178
legend: '2 categories',
179179
colorStats: [
180-
{ key: '#000000', value: 15 },
181-
{ key: '#54B399', value: 85 },
180+
{ color: '#000000', percentage: 15 },
181+
{ color: '#54B399', percentage: 85 },
182182
],
183183
},
184184
{
185185
chartAvailable: true,
186186
id: 'customer_id',
187187
legend: 'top 20 of 46 categories',
188188
colorStats: [
189-
{ key: '#54B399', value: 35 },
190-
{ key: '#000000', value: 60 },
189+
{ color: '#54B399', percentage: 35 },
190+
{ color: '#000000', percentage: 60 },
191191
],
192192
},
193193
{ chartAvailable: false, id: 'customer_last_name', legend: 'Chart not supported.' },
@@ -196,17 +196,17 @@ export default function ({ getService }: FtrProviderContext) {
196196
id: 'customer_phone',
197197
legend: '1 category',
198198
colorStats: [
199-
{ key: '#000000', value: 10 },
200-
{ key: '#54B399', value: 90 },
199+
{ color: '#000000', percentage: 10 },
200+
{ color: '#54B399', percentage: 90 },
201201
],
202202
},
203203
{
204204
chartAvailable: true,
205205
id: 'day_of_week',
206206
legend: '7 categories',
207207
colorStats: [
208-
{ key: '#000000', value: 20 },
209-
{ key: '#54B399', value: 75 },
208+
{ color: '#000000', percentage: 20 },
209+
{ color: '#54B399', percentage: 75 },
210210
],
211211
},
212212
],

x-pack/test/functional/apps/transform/creation_runtime_mappings.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import { TRANSFORM_STATE } from '../../../../plugins/transform/common/constants';
99

1010
import { FtrProviderContext } from '../../ftr_provider_context';
11+
12+
import type { HistogramCharts } from '../../services/transform/wizard';
13+
1114
import {
1215
GroupByEntry,
1316
isLatestTransformTestData,
@@ -44,22 +47,22 @@ export default function ({ getService }: FtrProviderContext) {
4447
});
4548

4649
// Only testing that histogram charts are available for runtime fields here
47-
const histogramCharts = [
50+
const histogramCharts: HistogramCharts = [
4851
{
4952
chartAvailable: true,
5053
id: 'rt_airline_lower',
5154
legend: '19 categories',
5255
colorStats: [
53-
{ key: '#000000', value: 48 },
54-
{ key: '#54B399', value: 41 },
56+
{ color: '#000000', percentage: 48 },
57+
{ color: '#54B399', percentage: 41 },
5558
],
5659
},
5760
{
5861
chartAvailable: true,
5962
id: 'rt_responsetime_x_2',
6063
colorStats: [
61-
{ key: '#54B399', value: 5 },
62-
{ key: '#000000', value: 95 },
64+
{ color: '#54B399', percentage: 5 },
65+
{ color: '#000000', percentage: 95 },
6366
],
6467
},
6568
];

0 commit comments

Comments
 (0)