Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-lodash-4-final
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 2, 2020
2 parents dc10eb0 + e774921 commit a0327dd
Show file tree
Hide file tree
Showing 21 changed files with 945 additions and 137 deletions.
7 changes: 4 additions & 3 deletions .ci/es-snapshots/Jenkinsfile_build_es
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def PROMOTE_WITHOUT_VERIFY = !!params.PROMOTE_WITHOUT_VERIFICATION
timeout(time: 120, unit: 'MINUTES') {
timestamps {
ansiColor('xterm') {
node(workers.label('s')) {
node(workers.label('l')) {
catchErrors {
def VERSION
def SNAPSHOT_ID
Expand Down Expand Up @@ -154,9 +154,10 @@ def buildArchives(destination) {
"NODE_NAME=",
]) {
sh """
./gradlew -p distribution/archives assemble --parallel
./gradlew -Dbuild.docker=true assemble --parallel
mkdir -p ${destination}
find distribution/archives -type f \\( -name 'elasticsearch-*-*-*-*.tar.gz' -o -name 'elasticsearch-*-*-*-*.zip' \\) -not -path *no-jdk* -exec cp {} ${destination} \\;
find distribution -type f \\( -name 'elasticsearch-*-*-*-*.tar.gz' -o -name 'elasticsearch-*-*-*-*.zip' \\) -not -path *no-jdk* -not -path *build-context* -exec cp {} ${destination} \\;
docker images "docker.elastic.co/elasticsearch/elasticsearch" --format "{{.Tag}}" | xargs -n1 bash -c 'docker save docker.elastic.co/elasticsearch/elasticsearch:\${0} | gzip > ${destination}/elasticsearch-\${0}-docker-image.tar.gz'
"""
}
}
2 changes: 1 addition & 1 deletion test/scripts/jenkins_visual_regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p "$installDir"
tar -xzf "$linuxBuild" -C "$installDir" --strip=1

echo " -> running visual regression tests from kibana directory"
yarn percy exec -t 500 -- -- \
yarn percy exec -t 10000 -- -- \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$installDir" \
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/jenkins_xpack_visual_regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tar -xzf "$linuxBuild" -C "$installDir" --strip=1

echo " -> running visual regression tests from x-pack directory"
cd "$XPACK_DIR"
yarn percy exec -t 500 -- -- \
yarn percy exec -t 10000 -- -- \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$installDir" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,29 @@ describe.skip('useFetcher', () => {
expect(hook.result.current).toEqual(true);
});

it('is true for minimum 1000ms', () => {
hook = renderHook((isLoading) => useDelayedVisibility(isLoading), {
initialProps: false,
});
// Disabled because it's flaky: https://github.com/elastic/kibana/issues/66389
// it('is true for minimum 1000ms', () => {
// hook = renderHook((isLoading) => useDelayedVisibility(isLoading), {
// initialProps: false,
// });

hook.rerender(true);
// hook.rerender(true);

act(() => {
jest.advanceTimersByTime(100);
});
// act(() => {
// jest.advanceTimersByTime(100);
// });

hook.rerender(false);
act(() => {
jest.advanceTimersByTime(900);
});
// hook.rerender(false);
// act(() => {
// jest.advanceTimersByTime(900);
// });

expect(hook.result.current).toEqual(true);
// expect(hook.result.current).toEqual(true);

act(() => {
jest.advanceTimersByTime(100);
});
// act(() => {
// jest.advanceTimersByTime(100);
// });

expect(hook.result.current).toEqual(false);
});
// expect(hook.result.current).toEqual(false);
// });
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions x-pack/plugins/infra/public/metrics_overview_fetchers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* 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 { coreMock } from 'src/core/public/mocks';
import { createMetricsHasData, createMetricsFetchData } from './metrics_overview_fetchers';
import { CoreStart } from 'kibana/public';
import { InfraClientStartDeps, InfraClientStartExports } from './types';
import moment from 'moment';
import { FAKE_SNAPSHOT_RESPONSE } from './test_utils';

function setup() {
const core = coreMock.createStart();
const mockedGetStartServices = jest.fn(() => {
const deps = {};
return Promise.resolve([
core as CoreStart,
deps as InfraClientStartDeps,
void 0 as InfraClientStartExports,
]) as Promise<[CoreStart, InfraClientStartDeps, InfraClientStartExports]>;
});
return { core, mockedGetStartServices };
}

describe('Metrics UI Observability Homepage Functions', () => {
describe('createMetricsHasData()', () => {
it('should return true when true', async () => {
const { core, mockedGetStartServices } = setup();
core.http.get.mockResolvedValue({
status: {
indexFields: [],
logIndicesExist: false,
metricIndicesExist: true,
},
});
const hasData = createMetricsHasData(mockedGetStartServices);
const response = await hasData();
expect(core.http.get).toHaveBeenCalledTimes(1);
expect(response).toBeTruthy();
});
it('should return false when false', async () => {
const { core, mockedGetStartServices } = setup();
core.http.get.mockResolvedValue({
status: {
indexFields: [],
logIndicesExist: false,
metricIndicesExist: false,
},
});
const hasData = createMetricsHasData(mockedGetStartServices);
const response = await hasData();
expect(core.http.get).toHaveBeenCalledTimes(1);
expect(response).toBeFalsy();
});
});

describe('createMetricsFetchData()', () => {
it('should just work', async () => {
const { core, mockedGetStartServices } = setup();
core.http.post.mockResolvedValue(FAKE_SNAPSHOT_RESPONSE);
const fetchData = createMetricsFetchData(mockedGetStartServices);
const endTime = moment();
const startTime = endTime.clone().subtract(1, 'h');
const bucketSize = '300s';
const response = await fetchData({
startTime: startTime.toISOString(),
endTime: endTime.toISOString(),
bucketSize,
});
expect(core.http.post).toHaveBeenCalledTimes(1);
expect(core.http.post).toHaveBeenCalledWith('/api/metrics/snapshot', {
body: JSON.stringify({
sourceId: 'default',
metrics: [{ type: 'cpu' }, { type: 'memory' }, { type: 'rx' }, { type: 'tx' }],
groupBy: [],
nodeType: 'host',
timerange: {
from: startTime.valueOf(),
to: endTime.valueOf(),
interval: '300s',
forceInterval: true,
ignoreLookback: true,
},
}),
});
expect(response).toMatchSnapshot();
});
});
});
Loading

0 comments on commit a0327dd

Please sign in to comment.