Skip to content

Commit

Permalink
[7.6] Fix visual baseline job (elastic#59348) (elastic#59471)
Browse files Browse the repository at this point in the history
* Establish Percy baselines

* move Jenkinsfile changed back to `.ci` directory

* rename xpack workers

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
Spencer and elasticmachine authored Mar 6, 2020
1 parent e98778a commit 692e2a5
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 88 deletions.
14 changes: 8 additions & 6 deletions .ci/Jenkinsfile_visual_baseline
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ kibanaLibrary.load()
kibanaPipeline(timeoutMinutes: 120) {
catchError {
parallel([
workers.base(name: 'oss-visualRegression', label: 'linux && immutable') {
kibanaPipeline.buildOss()
kibanaPipeline.functionalTestProcess('oss-visualRegression', './test/scripts/jenkins_visual_regression.sh')
'oss-visualRegression': {
workers.ci(name: 'oss-visualRegression', label: 'linux && immutable', ramDisk: false) {
kibanaPipeline.functionalTestProcess('oss-visualRegression', './test/scripts/jenkins_visual_regression.sh')(1)
}
},
workers.base(name: 'xpack-visualRegression', label: 'linux && immutable') {
kibanaPipeline.buildXpack()
kibanaPipeline.functionalTestProcess('xpack-visualRegression', './test/scripts/jenkins_xpack_visual_regression.sh')
'xpack-visualRegression': {
workers.ci(name: 'xpack-visualRegression', label: 'linux && immutable', ramDisk: false) {
kibanaPipeline.functionalTestProcess('xpack-visualRegression', './test/scripts/jenkins_xpack_visual_regression.sh')(1)
}
},
])
}
Expand Down
6 changes: 3 additions & 3 deletions test/functional/services/elastic_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function ElasticChartProvider({ getService }: FtrProviderContext) {
return Number(renderingCount);
}

public async waitForRenderingCount(dataTestSubj: string, previousCount = 1) {
await retry.waitFor(`rendering count to be equal to [${previousCount + 1}]`, async () => {
public async waitForRenderingCount(dataTestSubj: string, minimumCount: number) {
await retry.waitFor(`rendering count to be equal to [${minimumCount}]`, async () => {
const currentRenderingCount = await this.getVisualizationRenderingCount(dataTestSubj);
log.debug(`-- currentRenderingCount=${currentRenderingCount}`);
return currentRenderingCount === previousCount + 1;
return currentRenderingCount >= minimumCount;
});
}
}
Expand Down
14 changes: 11 additions & 3 deletions test/scripts/jenkins_visual_regression.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_xpack.sh
source src/dev/ci_setup/setup_env.sh
source "$KIBANA_DIR/src/dev/ci_setup/setup_percy.sh"

checks-reporter-with-killswitch "Kibana visual regression tests" \
yarn run percy exec -t 500 \
echo " -> building and extracting OSS Kibana distributable for use in functional tests"
node scripts/build --debug --oss
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
installDir="$PARENT_DIR/install/kibana"
mkdir -p "$installDir"
tar -xzf "$linuxBuild" -C "$installDir" --strip=1

echo " -> running visual regression tests from kibana directory"
checks-reporter-with-killswitch "X-Pack visual regression tests" \
yarn percy exec -t 500 \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$installDir" \
Expand Down
18 changes: 14 additions & 4 deletions test/scripts/jenkins_xpack_visual_regression.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_xpack.sh
source src/dev/ci_setup/setup_env.sh
source "$KIBANA_DIR/src/dev/ci_setup/setup_percy.sh"

echo " -> building and extracting default Kibana distributable"
cd "$KIBANA_DIR"
node scripts/build --debug --no-oss
linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')"
installDir="$PARENT_DIR/install/kibana"
mkdir -p "$installDir"
tar -xzf "$linuxBuild" -C "$installDir" --strip=1

echo " -> running visual regression tests from x-pack directory"
cd "$XPACK_DIR"
checks-reporter-with-killswitch "X-Pack visual regression tests" \
yarn run percy exec -t 500 \
yarn percy exec -t 500 \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--config test/visual_regression/config.js;
--kibana-install-dir "$installDir" \
--config test/visual_regression/config.ts;
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export async function VisualTestingProvider({ getService }: FtrProviderContext)

return new (class VisualTesting {
public async snapshot(options: SnapshotOptions = {}) {
if (process.env.DISABLE_VISUAL_TESTING) {
log.warning(
'Capturing of percy snapshots disabled, would normally capture a snapshot here!'
);
return;
}

log.debug('Capturing percy snapshot');

if (!currentTest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

import expect from '@kbn/expect';

export default function({ getService, getPageObjects }) {
const log = getService('log');
import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const esArchiver = getService('esArchiver');
const browser = getService('browser');
Expand All @@ -34,58 +35,56 @@ export default function({ getService, getPageObjects }) {

describe('discover', function describeIndexTests() {
before(async function() {
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');

// and load a set of makelogs data
await esArchiver.loadIfNeeded('logstash_functional');
await kibanaServer.uiSettings.replace(defaultSettings);
log.debug('discover');
await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setDefaultAbsoluteRange();
});

after(function unloadMakelogs() {
return esArchiver.unload('logstash_functional');
});

async function refreshDiscover() {
await browser.refresh();
await PageObjects.header.awaitKibanaChrome();
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.waitForChartLoadingComplete(1);
}

async function takeSnapshot() {
await refreshDiscover();
await visualTesting.snapshot({
show: ['discoverChart'],
});
}

describe('query', function() {
this.tags(['skipFirefox']);
let renderCounter = 0;

it('should show bars in the correct time zone', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('should show correct data for chart interval Hourly', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Hourly');
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('should show correct data for chart interval Daily', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Daily');
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('should show correct data for chart interval Weekly', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Weekly');
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('browser back button should show previous interval Daily', async function() {
Expand All @@ -94,57 +93,31 @@ export default function({ getService, getPageObjects }) {
const actualInterval = await PageObjects.discover.getChartInterval();
expect(actualInterval).to.be('Daily');
});
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('should show correct data for chart interval Monthly', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Monthly');
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('should show correct data for chart interval Yearly', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Yearly');
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});

it('should show correct data for chart interval Auto', async function() {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Auto');
await PageObjects.discover.waitForChartLoadingComplete(++renderCounter);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});
});

describe('time zone switch', () => {
it('should show bars in the correct time zone after switching', async function() {
await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'America/Phoenix' });
await browser.refresh();
await PageObjects.header.awaitKibanaChrome();
await refreshDiscover();
await PageObjects.timePicker.setDefaultAbsoluteRange();
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.waitForChartLoadingComplete(1);
await visualTesting.snapshot({
show: ['discoverChart'],
});
await takeSnapshot();
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

import { DEFAULT_OPTIONS } from '../../services/visual_testing/visual_testing';
import { FtrProviderContext } from '../../ftr_provider_context';

// Width must be the same as visual_testing or canvas image widths will get skewed
const [SCREEN_WIDTH] = DEFAULT_OPTIONS.widths || [];

export default function({ getService, loadTestFile }) {
const esArchiver = getService('esArchiver');
export default function({ getService, loadTestFile }: FtrProviderContext) {
const browser = getService('browser');

describe('discover app', function() {
Expand All @@ -33,10 +33,6 @@ export default function({ getService, loadTestFile }) {
return browser.setWindowSize(SCREEN_WIDTH, 1000);
});

after(function unloadMakelogs() {
return esArchiver.unload('logstash_functional');
});

loadTestFile(require.resolve('./chart_visualization'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { services as ossVisualRegressionServices } from '../../../test/visual_regression/services';
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';

export default async function({ readConfigFile }) {
import { services } from './services';

export default async function({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config'));

return {
Expand All @@ -19,10 +21,7 @@ export default async function({ readConfigFile }) {
require.resolve('./tests/infra'),
],

services: {
...functionalConfig.get('services'),
visualTesting: ossVisualRegressionServices.visualTesting,
},
services,

junit: {
reportName: 'X-Pack Visual Regression Tests',
Expand Down
12 changes: 12 additions & 0 deletions x-pack/test/visual_regression/ftr_provider_context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { GenericFtrProviderContext } from '@kbn/test/types/ftr';

import { pageObjects } from './page_objects';
import { services } from './services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
9 changes: 9 additions & 0 deletions x-pack/test/visual_regression/page_objects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { pageObjects } from '../functional/page_objects';

export { pageObjects };
13 changes: 13 additions & 0 deletions x-pack/test/visual_regression/services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { services as ossVisualRegressionServices } from '../../../test/visual_regression/services';
import { services as functionalServices } from '../functional/services';

export const services = {
...functionalServices,
visualTesting: ossVisualRegressionServices.visualTesting,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

export default function({ getService, getPageObjects }) {
import { FtrProviderContext } from '../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const visualTesting = getService('visualTesting');
const testSubjects = getService('testSubjects');
Expand Down

0 comments on commit 692e2a5

Please sign in to comment.