Skip to content

Commit

Permalink
Merge branch 'master' into actions/feature
Browse files Browse the repository at this point in the history
* master:
  [APM] Fix flaky e2e’s (#70790)
  [Discover] Migrate server side saved object from data to discover plugin (#70342)
  [APM] Update docs on running API tests (#70765)
  test: 💍 delete a flaky test (#70785)
  [Security Solution] Refactor GlobalTime to useGlobalTime hook and cle… (#69345)
  Remove IE11 mention from PR template [skip ci] (#70486)
  [GS] add savedObjects result provider (#68619)
  remove snapshot from disabled test suite. (#70769)
  • Loading branch information
gmmorris committed Jul 6, 2020
2 parents 76d2818 + e298317 commit 6a2b64d
Show file tree
Hide file tree
Showing 80 changed files with 2,152 additions and 1,068 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Delete any items that are not applicable to this PR.
- [ ] [Unit or functional tests](https:/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)
- [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)
- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)
- [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

Expand Down

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/plugins/data/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

export { searchSavedObjectType } from './search';
export { querySavedObjectType } from './query';
export { indexPatternSavedObjectType } from './index_patterns';
export { kqlTelemetry } from './kql_telementry';
3 changes: 0 additions & 3 deletions src/plugins/data/server/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from './types';
import { registerSearchRoute } from './routes';
import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './es_search';
import { searchSavedObjectType } from '../saved_objects';
import { DataPluginStart } from '../plugin';

export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
Expand All @@ -36,8 +35,6 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
constructor(private initializerContext: PluginInitializerContext) {}

public setup(core: CoreSetup<object, DataPluginStart>): ISearchSetup {
core.savedObjects.registerType(searchSavedObjectType);

this.registerSearchStrategy(
ES_SEARCH_STRATEGY,
esSearchStrategyProvider(this.initializerContext.config.legacy.globalConfig$)
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/discover/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import { CoreSetup, CoreStart, Plugin } from 'kibana/server';
import { uiSettings } from './ui_settings';
import { capabilitiesProvider } from './capabilities_provider';
import { searchSavedObjectType } from './saved_objects';

export class DiscoverServerPlugin implements Plugin<object, object> {
public setup(core: CoreSetup) {
core.capabilities.registerProvider(capabilitiesProvider);
core.uiSettings.register(uiSettings);
core.savedObjects.registerType(searchSavedObjectType);

return {};
}
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/discover/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { searchSavedObjectType } from './search';
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { SavedObjectsType } from 'kibana/server';
import { searchSavedObjectTypeMigrations } from './search_migrations';
import { searchMigrations } from './search_migrations';

export const searchSavedObjectType: SavedObjectsType = {
name: 'search',
Expand All @@ -43,18 +43,18 @@ export const searchSavedObjectType: SavedObjectsType = {
},
mappings: {
properties: {
columns: { type: 'keyword' },
columns: { type: 'keyword', index: false },
description: { type: 'text' },
hits: { type: 'integer' },
hits: { type: 'integer', index: false },
kibanaSavedObjectMeta: {
properties: {
searchSourceJSON: { type: 'text' },
searchSourceJSON: { type: 'text', index: false },
},
},
sort: { type: 'keyword' },
sort: { type: 'keyword', index: false },
title: { type: 'text' },
version: { type: 'integer' },
},
},
migrations: searchSavedObjectTypeMigrations as any,
migrations: searchMigrations as any,
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/

import { SavedObjectMigrationContext } from 'kibana/server';
import { searchSavedObjectTypeMigrations } from './search_migrations';
import { searchMigrations } from './search_migrations';

const savedObjectMigrationContext = (null as unknown) as SavedObjectMigrationContext;

describe('migration search', () => {
describe('6.7.2', () => {
const migrationFn = searchSavedObjectTypeMigrations['6.7.2'];
const migrationFn = searchMigrations['6.7.2'];

it('should migrate obsolete match_all query', () => {
const migratedDoc = migrationFn(
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('migration search', () => {
});

describe('7.0.0', () => {
const migrationFn = searchSavedObjectTypeMigrations['7.0.0'];
const migrationFn = searchMigrations['7.0.0'];

test('skips errors when searchSourceJSON is null', () => {
const doc = {
Expand Down Expand Up @@ -278,7 +278,7 @@ Object {
});

describe('7.4.0', function () {
const migrationFn = searchSavedObjectTypeMigrations['7.4.0'];
const migrationFn = searchMigrations['7.4.0'];

test('transforms one dimensional sort arrays into two dimensional arrays', () => {
const doc = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { flow, get } from 'lodash';
import { SavedObjectMigrationFn } from 'kibana/server';
import { DEFAULT_QUERY_LANGUAGE } from '../../common';
import { DEFAULT_QUERY_LANGUAGE } from '../../../data/common';

const migrateMatchAllQuery: SavedObjectMigrationFn<any, any> = (doc) => {
const searchSourceJSON = get(doc, 'attributes.kibanaSavedObjectMeta.searchSourceJSON');
Expand Down Expand Up @@ -121,7 +121,7 @@ const migrateSearchSortToNestedArray: SavedObjectMigrationFn<any, any> = (doc) =
};
};

export const searchSavedObjectTypeMigrations = {
export const searchMigrations = {
'6.7.2': flow(migrateMatchAllQuery),
'7.0.0': flow(setNewReferences),
'7.4.0': flow(migrateSearchSortToNestedArray),
Expand Down
11 changes: 0 additions & 11 deletions src/plugins/expressions/common/execution/execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,6 @@ describe('Execution', () => {
}
});

test('sets duration to 10 milliseconds when function executes 10 milliseconds', async () => {
const execution = createExecution('sleep 10', {}, true);
execution.start(-1);
await execution.result;

const node = execution.state.get().ast.chain[0];
expect(typeof node.debug?.duration).toBe('number');
expect(node.debug?.duration).toBeLessThan(50);
expect(node.debug?.duration).toBeGreaterThanOrEqual(5);
});

test('adds .debug field in expression AST on each executed function', async () => {
const execution = createExecution('add val=1 | add val=2 | add val=3', {}, true);
execution.start(-1);
Expand Down
15 changes: 3 additions & 12 deletions x-pack/plugins/apm/e2e/cypress/integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,21 @@

/* eslint-disable import/no-extraneous-dependencies */

const RANGE_FROM = '2020-06-01T14:59:32.686Z';
const RANGE_TO = '2020-06-16T16:59:36.219Z';

const BASE_URL = Cypress.config().baseUrl;

/** The default time in ms to wait for a Cypress command to complete */
export const DEFAULT_TIMEOUT = 60 * 1000;

export function loginAndWaitForPage(
url: string,
dateRange?: { to: string; from: string }
dateRange: { to: string; from: string }
) {
const username = Cypress.env('elasticsearch_username');
const password = Cypress.env('elasticsearch_password');

cy.log(`Authenticating via ${username} / ${password}`);
let rangeFrom = RANGE_FROM;
let rangeTo = RANGE_TO;
if (dateRange) {
rangeFrom = dateRange.from;
rangeTo = dateRange.to;
}

const fullUrl = `${BASE_URL}${url}?rangeFrom=${rangeFrom}&rangeTo=${rangeTo}`;

const fullUrl = `${BASE_URL}${url}?rangeFrom=${dateRange.from}&rangeTo=${dateRange.to}`;
cy.visit(fullUrl, { auth: { username, password } });

cy.viewport('macbook-15');
Expand Down
9 changes: 1 addition & 8 deletions x-pack/plugins/apm/e2e/cypress/integration/snapshots.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
module.exports = {
"__version": "4.5.0",
"APM": {
"Transaction duration charts": {
"1": "55 ms",
"2": "28 ms",
"3": "0 ms"
}
},
"__version": "4.9.0",
"RUM Dashboard": {
"Client metrics": {
"1": "55 ",
Expand Down
14 changes: 8 additions & 6 deletions x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export const DEFAULT_TIMEOUT = 60 * 1000;

Given(`a user browses the APM UI application`, () => {
// open service overview page
loginAndWaitForPage(`/app/apm#/services`);
loginAndWaitForPage(`/app/apm#/services`, {
from: '2020-06-01T14:59:32.686Z',
to: '2020-06-16T16:59:36.219Z',
});
});

When(`the user inspects the opbeans-node service`, () => {
Expand All @@ -34,9 +37,8 @@ Then(`should have correct y-axis ticks`, () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');

cy.get(yAxisTick).eq(2).invoke('text').snapshot();

cy.get(yAxisTick).eq(1).invoke('text').snapshot();

cy.get(yAxisTick).eq(0).invoke('text').snapshot();
// literal assertions because snapshot() doesn't retry
cy.get(yAxisTick).eq(2).should('have.text', '55 ms');
cy.get(yAxisTick).eq(1).should('have.text', '28 ms');
cy.get(yAxisTick).eq(0).should('have.text', '0 ms');
});
18 changes: 9 additions & 9 deletions x-pack/plugins/apm/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
},
"dependencies": {
"@cypress/snapshot": "^2.1.3",
"@cypress/webpack-preprocessor": "^5.2.0",
"@cypress/webpack-preprocessor": "^5.4.1",
"@types/cypress-cucumber-preprocessor": "^1.14.1",
"@types/node": "^14.0.1",
"@types/node": "^14.0.14",
"axios": "^0.19.2",
"cypress": "^4.5.0",
"cypress-cucumber-preprocessor": "^2.3.1",
"cypress": "^4.9.0",
"cypress-cucumber-preprocessor": "^2.5.2",
"ora": "^4.0.4",
"p-limit": "^2.3.0",
"p-limit": "^3.0.1",
"p-retry": "^4.2.0",
"ts-loader": "^7.0.4",
"typescript": "3.9.5",
"wait-on": "^5.0.0",
"ts-loader": "^7.0.5",
"typescript": "3.9.6",
"wait-on": "^5.0.1",
"webpack": "^4.43.0",
"yargs": "^15.3.1"
"yargs": "^15.4.0"
}
}
10 changes: 6 additions & 4 deletions x-pack/plugins/apm/e2e/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,20 @@ yarn &> ${TMP_DIR}/e2e-yarn.log
echo "" # newline
echo "${bold}Static mock data (logs: ${E2E_DIR}${TMP_DIR}/ingest-data.log)${normal}"

STATIC_MOCK_FILENAME='2020-06-12.json'

# Download static data if not already done
if [ ! -e "${TMP_DIR}/events.json" ]; then
echo 'Downloading events.json...'
curl --silent https://storage.googleapis.com/apm-ui-e2e-static-data/2020-06-12.json --output ${TMP_DIR}/events.json
if [ ! -e "${TMP_DIR}/${STATIC_MOCK_FILENAME}" ]; then
echo "Downloading ${STATIC_MOCK_FILENAME}..."
curl --silent https://storage.googleapis.com/apm-ui-e2e-static-data/${STATIC_MOCK_FILENAME} --output ${TMP_DIR}/${STATIC_MOCK_FILENAME}
fi

# echo "Deleting existing indices (apm* and .apm*)"
curl --silent --user admin:changeme -XDELETE "localhost:${ELASTICSEARCH_PORT}/.apm*" > /dev/null
curl --silent --user admin:changeme -XDELETE "localhost:${ELASTICSEARCH_PORT}/apm*" > /dev/null

# Ingest data into APM Server
node ingest-data/replay.js --server-url http://localhost:$APM_SERVER_PORT --events ${TMP_DIR}/events.json 2>> ${TMP_DIR}/ingest-data.log
node ingest-data/replay.js --server-url http://localhost:$APM_SERVER_PORT --events ${TMP_DIR}/${STATIC_MOCK_FILENAME} 2>> ${TMP_DIR}/ingest-data.log

# Abort if not all events were ingested correctly
if [ $? -ne 0 ]; then
Expand Down
Loading

0 comments on commit 6a2b64d

Please sign in to comment.