Skip to content

Commit

Permalink
Merge branch 'master' into np-licensing-functional-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Dec 13, 2019
2 parents 9483684 + 6c1f248 commit 4f5c072
Show file tree
Hide file tree
Showing 96 changed files with 4,677 additions and 461 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ module.exports = {
allowSameFolder: true,
},
{
target: ['src/core/**/*'],
target: ['src/**/*'],
from: ['x-pack/**/*'],
errorMessage: 'OSS cannot import x-pack files.',
},
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pr-project-assigner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request:
types: [labeled, unlabeled]

jobs:
assign_to_project:
runs-on: ubuntu-latest
name: Assign a PR to project based on label
steps:
- name: Assign to project
uses: elastic/github-actions/project-assigner@v1.0.0
id: project_assigner
with:
issue-mappings: '[{"label": "Team:AppAch", "projectName": "kibana-app-arch", "columnId": 6173897}]'
ghToken: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/project-assigner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
issues:
types: [labeled, unlabeled]

jobs:
assign_to_project:
runs-on: ubuntu-latest
name: Assign issue or PR to project based on label
steps:
- name: Assign to project
uses: elastic/github-actions/project-assigner@v1.0.0
id: project_assigner
with:
issue-mappings: '[{"label": "Team:AppArch", "projectName": "kibana-app-arch", "columnId": 6173895}]'
ghToken: ${{ secrets.GITHUB_TOKEN }}


Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Wait timed out after 10055ms
at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13)]]>
</failure>
</testcase>
<testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179">
<testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" metadata-json="{&quot;messages&quot;:[&quot;foo&quot;],&quot;screenshots&quot;:[{&quot;name&quot;:&quot;failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]&quot;,&quot;url&quot;:&quot;https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png&quot;}]}">
<system-out>
<![CDATA[[00:00:00] │
[00:07:04] └-: maps app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ it('rewrites ftr reports with minimal changes', async () => {
+ at onFailure (/var/lib/jenkins/workspace/elastic+kibana+master/JOB/x-pack-ciGroup7/node/immutable/kibana/test/common/services/retry/retry_for_success.ts:68:13)
‹/failure›
‹/testcase›
‹testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179"›
‹testcase name="maps app &quot;after all&quot; hook" classname="Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps" time="0.179" metadata-json="{&quot;messages&quot;:[&quot;foo&quot;],&quot;screenshots&quot;:[{&quot;name&quot;:&quot;failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]&quot;,&quot;url&quot;:&quot;https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png&quot;}]}"
‹system-out›
- ‹![CDATA[[00:00:00] │
+ [00:00:00] │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ it('discovers failures in ftr report', async () => {
at process._tickCallback (internal/process/next_tick.js:68:7) name: 'NoSuchSessionError', remoteStacktrace: '' }
",
"likelyIrrelevant": true,
"metadata-json": "{\\"messages\\":[\\"foo\\"],\\"screenshots\\":[{\\"name\\":\\"failure[dashboard app using current data dashboard snapshots compare TSVB snapshot]\\",\\"url\\":\\"https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png\\"}]}",
"name": "maps app \\"after all\\" hook",
"time": "0.179",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.
*/

import { getReportMessageIter } from './report_metadata';
import { parseTestReport } from './test_report';
import { FTR_REPORT, JEST_REPORT, KARMA_REPORT, MOCHA_REPORT } from './__fixtures__';

it('reads messages and screenshots from metadata-json properties', async () => {
const ftrReport = await parseTestReport(FTR_REPORT);
expect(Array.from(getReportMessageIter(ftrReport))).toMatchInlineSnapshot(`
Array [
Object {
"classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps",
"message": "foo",
"name": "maps app \\"after all\\" hook",
},
Object {
"classname": "Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps",
"message": "Screenshot: failure[dashboard app using current data dashboard snapshots compare TSVB snapshot] https://storage.googleapis.com/kibana-ci-artifacts/jobs/elastic+kibana+7.x/1632/kibana-oss-tests/test/functional/screenshots/failure/dashboard%20app%20using%20current%20data%20dashboard%20snapshots%20compare%20TSVB%20snapshot.png",
"name": "maps app \\"after all\\" hook",
},
]
`);

const jestReport = await parseTestReport(JEST_REPORT);
expect(Array.from(getReportMessageIter(jestReport))).toMatchInlineSnapshot(`Array []`);

const mochaReport = await parseTestReport(MOCHA_REPORT);
expect(Array.from(getReportMessageIter(mochaReport))).toMatchInlineSnapshot(`Array []`);

const karmaReport = await parseTestReport(KARMA_REPORT);
expect(Array.from(getReportMessageIter(karmaReport))).toMatchInlineSnapshot(`Array []`);
});
25 changes: 7 additions & 18 deletions packages/kbn-test/src/failed_tests_reporter/report_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,25 @@
*/

import { TestReport, makeTestCaseIter } from './test_report';
import { Message } from './add_messages_to_report';

export function* getMetadataIter(report: TestReport) {
export function* getReportMessageIter(report: TestReport) {
for (const testCase of makeTestCaseIter(report)) {
if (!testCase.$['metadata-json']) {
yield [{}, testCase];
} else {
yield [{}, JSON.parse(testCase.$['metadata-json'])];
}
}
}
const metadata = testCase.$['metadata-json'] ? JSON.parse(testCase.$['metadata-json']) : {};

export function getReportMessages(report: TestReport) {
const messages: Message[] = [];
for (const [metadata, testCase] of getMetadataIter(report)) {
for (const message of metadata.messages || []) {
messages.push({
yield {
classname: testCase.$.classname,
name: testCase.$.name,
message,
});
message: String(message),
};
}

for (const screenshot of metadata.screenshots || []) {
messages.push({
yield {
classname: testCase.$.classname,
name: testCase.$.name,
message: `Screenshot: ${screenshot.name} ${screenshot.url}`,
});
};
}
}
return messages;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { updateFailureIssue, createFailureIssue } from './report_failure';
import { getIssueMetadata } from './issue_metadata';
import { readTestReport } from './test_report';
import { addMessagesToReport } from './add_messages_to_report';
import { getReportMessages } from './report_metadata';
import { getReportMessageIter } from './report_metadata';

export function runFailedTestsReporterCli() {
run(
Expand Down Expand Up @@ -75,7 +75,7 @@ export function runFailedTestsReporterCli() {

for (const reportPath of reportPaths) {
const report = await readTestReport(reportPath);
const messages = getReportMessages(report);
const messages = Array.from(getReportMessageIter(report));

for (const failure of await getFailures(report)) {
const pushMessage = (msg: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* 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.
*/
import ace from 'brace';

const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules');
const oop = ace.acequire('ace/lib/oop');

export const ElasticsearchSqlHighlightRules = function(this: any) {
// See https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-commands.html
const keywords =
'describe|between|in|like|not|and|or|desc|select|from|where|having|group|by|order' +
'asc|desc|pivot|for|in|as|show|columns|include|frozen|tables|escape|limit|rlike|all|distinct|is';

const builtinConstants = 'true|false';

// See https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-show-functions.html
const builtinFunctions =
'avg|count|first|first_value|last|last_value|max|min|sum|kurtosis|mad|percentile|percentile_rank|skewness' +
'|stddev_pop|sum_of_squares|var_pop|histogram|case|coalesce|greatest|ifnull|iif|isnull|least|nullif|nvl' +
'|curdate|current_date|current_time|current_timestamp|curtime|dateadd|datediff|datepart|datetrunc|date_add' +
'|date_diff|date_part|date_trunc|day|dayname|dayofmonth|dayofweek|dayofyear|day_name|day_of_month|day_of_week' +
'|day_of_year|dom|dow|doy|hour|hour_of_day|idow|isodayofweek|isodow|isoweek|isoweekofyear|iso_day_of_week|iso_week_of_year' +
'|iw|iwoy|minute|minute_of_day|minute_of_hour|month|monthname|month_name|month_of_year|now|quarter|second|second_of_minute' +
'|timestampadd|timestampdiff|timestamp_add|timestamp_diff|today|week|week_of_year|year|abs|acos|asin|atan|atan2|cbrt' +
'|ceil|ceiling|cos|cosh|cot|degrees|e|exp|expm1|floor|log|log10|mod|pi|power|radians|rand|random|round|sign|signum|sin' +
'|sinh|sqrt|tan|truncate|ascii|bit_length|char|character_length|char_length|concat|insert|lcase|left|length|locate' +
'|ltrim|octet_length|position|repeat|replace|right|rtrim|space|substring|ucase|cast|convert|database|user|st_astext|st_aswkt' +
'|st_distance|st_geometrytype|st_geomfromtext|st_wkttosql|st_x|st_y|st_z|score';

// See https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-data-types.html
const dataTypes =
'null|boolean|byte|short|integer|long|double|float|half_float|scaled_float|keyword|text|binary|date|ip|object|nested|time' +
'|interval_year|interval_month|interval_day|interval_hour|interval_minute|interval_second|interval_year_to_month' +
'inteval_day_to_hour|interval_day_to_minute|interval_day_to_second|interval_hour_to_minute|interval_hour_to_second' +
'interval_minute_to_second|geo_point|geo_shape|shape';

const keywordMapper = this.createKeywordMapper(
{
keyword: [keywords, builtinFunctions, builtinConstants, dataTypes].join('|'),
},
'identifier',
true
);

this.$rules = {
start: [
{
token: 'comment',
regex: '--.*$',
},
{
token: 'comment',
start: '/\\*',
end: '\\*/',
},
{
token: 'string', // " string
regex: '".*?"',
},
{
token: 'constant', // ' string
regex: "'.*?'",
},
{
token: 'string', // ` string (apache drill)
regex: '`.*?`',
},
{
token: 'entity.name.function', // float
regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b',
},
{
token: keywordMapper,
regex: '[a-zA-Z_$][a-zA-Z0-9_$]*\\b',
},
{
token: 'keyword.operator',
regex: '⇐|<⇒|\\*|\\.|\\:\\:|\\+|\\-|\\/|\\/\\/|%|&|\\^|~|<|>|<=|=>|==|!=|<>|=',
},
{
token: 'paren.lparen',
regex: '[\\(]',
},
{
token: 'paren.rparen',
regex: '[\\)]',
},
{
token: 'text',
regex: '\\s+',
},
],
};
this.normalizeRules();
};

oop.inherits(ElasticsearchSqlHighlightRules, TextHighlightRules);
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,33 @@
const ace = require('brace');
import { addToRules } from './x_json_highlight_rules';

const oop = ace.acequire('ace/lib/oop');
const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules');
export function InputHighlightRules() {
function mergeTokens(/* ... */) {
return [].concat.apply([], arguments);
export function addEOL(tokens, reg, nextIfEOL, normalNext) {
if (typeof reg === 'object') {
reg = reg.source;
}
return [
{ token: tokens.concat(['whitespace']), regex: reg + '(\\s*)$', next: nextIfEOL },
{ token: tokens, regex: reg, next: normalNext }
];
}

function addEOL(tokens, reg, nextIfEOL, normalNext) {
if (typeof reg === 'object') {
reg = reg.source;
}
return [
{ token: tokens.concat(['whitespace']), regex: reg + '(\\s*)$', next: nextIfEOL },
{ token: tokens, regex: reg, next: normalNext }
];
}
export function mergeTokens(/* ... */) {
return [].concat.apply([], arguments);
}

const oop = ace.acequire('ace/lib/oop');
const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules');

export function InputHighlightRules() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
/*jshint -W015 */
this.$rules = {
'start-sql': [
{ token: 'whitespace', regex: '\\s+' },
{ token: 'paren.lparen', regex: '{', next: 'json-sql', push: true },
{ regex: '', next: 'start' }
],
'start': mergeTokens([
{ 'token': 'warning', 'regex': '#!.*$' },
{ token: 'comment', regex: /^#.*$/ },
Expand All @@ -65,6 +71,7 @@ export function InputHighlightRules() {
addEOL(['whitespace'], /(\s+)/, 'start', 'url')
),
'url': mergeTokens(
addEOL(['url.part'], /(_sql)/, 'start-sql', 'url-sql'),
addEOL(['url.part'], /([^?\/,\s]+)/, 'start'),
addEOL(['url.comma'], /(,)/, 'start'),
addEOL(['url.slash'], /(\/)/, 'start'),
Expand All @@ -74,7 +81,17 @@ export function InputHighlightRules() {
addEOL(['url.param', 'url.equal', 'url.value'], /([^&=]+)(=)([^&]*)/, 'start'),
addEOL(['url.param'], /([^&=]+)/, 'start'),
addEOL(['url.amp'], /(&)/, 'start')
)
),
'url-sql': mergeTokens(
addEOL(['url.comma'], /(,)/, 'start-sql'),
addEOL(['url.slash'], /(\/)/, 'start-sql'),
addEOL(['url.questionmark'], /(\?)/, 'start-sql', 'urlParams-sql')
),
'urlParams-sql': mergeTokens(
addEOL(['url.param', 'url.equal', 'url.value'], /([^&=]+)(=)([^&]*)/, 'start-sql'),
addEOL(['url.param'], /([^&=]+)/, 'start-sql'),
addEOL(['url.amp'], /(&)/, 'start-sql')
),
};

addToRules(this);
Expand Down
Loading

0 comments on commit 4f5c072

Please sign in to comment.