Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Backport workbench fixes to 7.9.1 #937

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/sql-workbench-release-workflow.yml
Expand Up @@ -38,7 +38,6 @@ jobs:

- name: Move Workbench to Plugins Dir
run: |
mkdir kibana/plugins
mv workbench kibana/plugins

- name: Kibana Plugin Bootstrap
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle
Expand Up @@ -111,7 +111,7 @@ afterEvaluate {

license 'ASL-2.0'
maintainer 'OpenDistro for Elasticsearch Team <opendistro@amazon.com>'
url 'https://opendistro.github.io/elasticsearch/downloads'
url 'https://opendistro.github.io/for-elasticsearch/downloads.html'
summary '''
SQL plugin for OpenDistro for Elasticsearch.
Reference documentation can be found at https://opendistro.github.io/for-elasticsearch-docs/.
Expand Down
132 changes: 82 additions & 50 deletions workbench/.cypress/integration/ui.spec.js
Expand Up @@ -23,41 +23,49 @@ describe('Test PPL UI', () => {
beforeEach(() => {
cy.visit('app/opendistro-query-workbench');
cy.wait(delay);
cy.get('.euiToggle__input[title=PPL]').click();
cy.get('.euiToggle__input[title=PPL]').click({ force: true });
cy.wait(delay);
});

it('Confirm results are empty', () => {
cy.get('.euiTextAlign').contains('Enter a query in the query editor above to see results.').should('have.length', 1);
cy.get('.euiTextAlign')
.contains('Enter a query in the query editor above to see results.')
.should('have.length', 1);
});

it('Test Run button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiTab__content').contains('Events').click();
cy.get('.euiTab__content').contains('Events').click({ force: true });

cy.get('span.euiTableCellContent__text').eq(21).should((employer) => {
expect(employer).to.contain('Pyrami');
});
cy.get('span.euiTableCellContent__text')
.eq(19)
.should((employer) => {
expect(employer).to.contain('Pyrami');
});
});

it('Test Clear button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiTab__content').contains('Events').click();
cy.get('.euiTab__content').contains('Events').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Clear').click();
cy.get('.euiButton__text').contains('Clear').click({ force: true });
cy.wait(delay);

cy.get('.euiTextAlign').contains('Enter a query in the query editor above to see results.').should('have.length', 1);
cy.get('.ace_content').eq(0).then((queryEditor) => {
const editor = edit(queryEditor[0]);
expect(editor.getValue()).to.equal('');
});
cy.get('.euiTextAlign')
.contains('Enter a query in the query editor above to see results.')
.should('have.length', 1);
cy.get('.ace_content')
.eq(0)
.then((queryEditor) => {
const editor = edit(queryEditor[0]);
expect(editor.getValue()).to.equal('');
});
});

it('Test full screen view', () => {
Expand All @@ -66,13 +74,13 @@ describe('Test PPL UI', () => {

cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Full screen view').click();
cy.get('.euiButton__text').contains('Full screen view').click({ force: true });

cy.get('.euiTitle').should('not.exist');

cy.get('button#exit-fullscreen-button').click();
cy.get('button#exit-fullscreen-button').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Full screen view').should('exist');
cy.get('.euiTitle').contains('Query Workbench').should('exist');
Expand All @@ -83,56 +91,70 @@ describe('Test SQL UI', () => {
beforeEach(() => {
cy.visit('app/opendistro-query-workbench');
cy.wait(delay);
cy.get('.euiToggle__input[title=SQL]').click();
cy.get('.euiToggle__input[title=SQL]').click({ force: true });
cy.wait(delay);
});

it('Confirm results are empty', () => {
cy.get('.euiTextAlign').contains('Enter a query in the query editor above to see results.').should('have.length', 1);
cy.get('.euiTextAlign')
.contains('Enter a query in the query editor above to see results.')
.should('have.length', 1);
});

it('Test Run button and field search', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('{enter}select * from accounts where balance > 49500;', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('{enter}select * from accounts where balance > 49500;', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiTab__content').contains('accounts').click();
cy.get('.euiTab__content').contains('accounts').click({ force: true });

cy.get('input.euiFieldSearch').type('marissa');
cy.get('span.euiTableCellContent__text').eq(15).should((account_number) => {
expect(account_number).to.contain('803');
});
cy.get('span.euiTableCellContent__text')
.eq(13)
.should((account_number) => {
expect(account_number).to.contain('803');
});
});

it('Test Translate button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('{selectall}{backspace}', { force: true });
cy.wait(delay);
cy.get('textarea.ace_text-input').eq(0).focus().type('{selectall}{backspace}select log(balance) from accounts where abs(age) > 20;', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('{selectall}{backspace}select log(balance) from accounts where abs(age) > 20;', {
force: true,
});
cy.wait(delay);
cy.get('.euiButton__text').contains('Explain').click();
cy.get('.euiButton__text').contains('Explain').click({ force: true });
cy.wait(delay);

// hard to get euiCodeBlock content, check length instead
cy.get('.euiCodeBlock__code').children().should('have.length', 37);
});

it('Test Clear button', () => {
cy.get('.euiButton__text').contains('Clear').click();
cy.get('.euiButton__text').contains('Clear').click({ force: true });
cy.wait(delay);

cy.get('.ace_content').eq(0).then((queryEditor) => {
const editor = edit(queryEditor[0]);
expect(editor.getValue()).to.equal('');
});
cy.get('.ace_content')
.eq(0)
.then((queryEditor) => {
const editor = edit(queryEditor[0]);
expect(editor.getValue()).to.equal('');
});
});

it('Test full screen view', () => {
cy.get('.euiButton__text').contains('Full screen view').should('not.exist');
cy.get('.euiTitle').contains('Query Workbench').should('exist');

cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Full screen view').click();
cy.get('.euiButton__text').contains('Full screen view').click({ force: true });

cy.get('.euiTitle').should('not.exist');
});
Expand All @@ -147,13 +169,13 @@ describe('Test and verify SQL downloads', () => {
url: url,
headers: {
'content-type': 'application/json;charset=UTF-8',
'kbn-version': '7.9.1',
'kbn-version': '7.10.0',
},
body: {
'query': 'select * from accounts where balance > 49500'
}
}).then(response => {
expect(response.body.resp).to.have.string(files[file]);
}).then((response) => {
expect(response.body.data.resp).to.have.string(files[file]);
});
});
});
Expand All @@ -163,35 +185,45 @@ describe('Test table display', () => {
beforeEach(() => {
cy.visit('app/opendistro-query-workbench');
cy.wait(delay);
cy.get('.euiToggle__input[title=SQL]').click();
cy.get('.euiToggle__input[title=SQL]').click({ force: true });
cy.wait(delay);
cy.get('textarea.ace_text-input').eq(0).focus().type('{selectall}{backspace}', { force: true });
cy.wait(delay);
});

testQueries.map(({ title, query, cell_idx, expected_string }) => {
it(title, () => {
cy.get('textarea.ace_text-input').eq(0).focus().type(`{selectall}{backspace}${query}`, { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type(`{selectall}{backspace}${query}`, { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);

cy.get('span.euiTableCellContent__text').eq(cell_idx).should((cell) => {
expect(cell).to.contain(expected_string);
});
cy.get('span.euiTableCellContent__text')
.eq(cell_idx)
.should((cell) => {
expect(cell).to.contain(expected_string);
});
});
});

it('Test nested fields display', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type(`{selectall}{backspace}select * from employee_nested;`, { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type(`{selectall}{backspace}select * from employee_nested;`, { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click();
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);

cy.get('span.euiTableCellContent__text').eq(21).click();
cy.get('button.euiLink').eq(2).click({ force: true });
cy.wait(delay);
cy.get('span.euiTableCellContent__text').eq(27).should((cell) => {
expect(cell).to.contain('2018-06-23');
});
cy.get('span.euiTableCellContent__text')
.eq(24)
.should((cell) => {
expect(cell).to.contain('2018-06-23');
});
});
});
12 changes: 6 additions & 6 deletions workbench/.cypress/utils/constants.js
Expand Up @@ -42,32 +42,32 @@ export const testQueries = [
{
title: 'Test GROUP BY',
query: 'select count(*) from accounts group by gender;',
cell_idx: 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np/question: what's the reason for the value changes here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id column was removed and the cell index shifted

cell_idx: 3,
expected_string: '507'
},
{
title: 'Test GROUP BY with aliases and scalar function',
query: 'SELECT ABS(age) AS a FROM accounts GROUP BY ABS(age);',
cell_idx: 17,
expected_string: '35.0'
expected_string: '28.0'
},
{
title: 'Test GROUP BY and HAVING',
query: 'SELECT age, MAX(balance) FROM accounts GROUP BY age HAVING MIN(balance) > 3000;',
cell_idx: 15,
expected_string: '49339'
cell_idx: 5,
expected_string: '47257'
},
{
title: 'Test ORDER BY',
query: 'SELECT account_number FROM accounts ORDER BY account_number DESC;',
cell_idx: 5,
expected_string: '999'
expected_string: '998'
},
{
title: 'Test JOIN',
query: 'select a.account_number, a.firstname, a.lastname, e.id, e.name from accounts a join employee_nested e order by a.account_number;',
cell_idx: 45,
expected_string: 'Amber'
expected_string: 'Duke'
},
];

Expand Down
1 change: 1 addition & 0 deletions workbench/.gitignore
Expand Up @@ -2,3 +2,4 @@ node_modules/
/build/
.cypress/screenshots
.cypress/videos
/target/*
17 changes: 17 additions & 0 deletions workbench/common/index.ts
@@ -0,0 +1,17 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file 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 const PLUGIN_ID = 'opendistroQueryWorkbench';
export const PLUGIN_NAME = 'Query Workbench';
60 changes: 0 additions & 60 deletions workbench/index.js

This file was deleted.

8 changes: 8 additions & 0 deletions workbench/kibana.json
@@ -0,0 +1,8 @@
{
"id": "opendistroQueryWorkbench",
"version": "7.9.1",
"server": true,
"ui": true,
"requiredPlugins": ["navigation"],
"optionalPlugins": []
}