Skip to content

Commit

Permalink
Added Flow Framework Dashboards integ tests fixes
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <saimedhi@amazon.com>
  • Loading branch information
saimedhi committed Oct 16, 2024
1 parent bc94f7d commit ce749af
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"took": 54,
"ingest_took": 126,
"errors": false,
"items": [
{
"index": {
"_index": "knn_index",
"_id": "_5eb4274ecd07877b",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "knn_index",
"_id": "_5c2109b59f22a89b",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 1,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "knn_index",
"_id": "_1a09251a492ae577",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 2,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "knn_index",
"_id": "_2a44dbf9e356a851",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 3,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "knn_index",
"_id": "_0e3c03e40a1ccdd2",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 4,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "knn_index",
"_id": "_07be3515c6668af1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 5,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "knn_index",
"_id": "_fc3aa8e1c935cbfb",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 6,
"_primary_term": 1,
"status": 201
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
[
{
"item_text": "purpul high heels",
"item_price": 150
},
{
"item_text": "pair of jordans",
"item_price": 250
},
{
"item_text": "baseball cleats",
"item_price": 85
},
{
"item_text": "red pants",
"item_price": 95
{
"hits": {
"hits": [
{
"_source": {
"shoes": [
{
"item_text": "purpul high heels",
"item_price": 150
},
{
"item_text": "pair of jordans",
"item_price": 250
},
{
"item_text": "baseball cleats",
"item_price": 85
}
]
}
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
import {
FF_URL,
FF_FIXTURE_BASE_PATH,
MODEL_PARAMETERS,
WORKFLOW_DETAIL_URL_SEGMENT,
FF_TIMEOUT,
} from '../../../utils/constants';
import createConnectorBody from '../../../fixtures/plugins/dashboards-flow-framework/create_connector.json';
import registerModelBody from '../../../fixtures/plugins/dashboards-flow-framework/register_model.json';
import { getLastPathSegment } from '../../../utils/plugins/dashboards-flow-framework/helpers';

var modelId = '';

describe('Creating Workflows Using Various Methods', () => {
before(() => {
cy.createConnector(createConnectorBody)
.then((connectorResponse) => {
MODEL_PARAMETERS.CONNECTOR_ID = connectorResponse.connector_id;
return cy.registerModel({
body: {
...registerModelBody,
connector_id: MODEL_PARAMETERS.CONNECTOR_ID,
connector_id: connectorResponse.connector_id,
function_name: 'remote',
},
});
})
.then((modelResponse) => {
MODEL_PARAMETERS.MODEL_ID = modelResponse.model_id;
return cy.deployModel(MODEL_PARAMETERS.MODEL_ID);
modelId = modelResponse.model_id;
return cy.deployModel(modelId);
});
});

Expand Down Expand Up @@ -105,7 +105,7 @@ describe('Creating Workflows Using Various Methods', () => {
cy.getElementByDataTestId('uploadSourceDataButton')
.should('be.visible')
.click();
const filePath = `cypress/fixtures/${FF_FIXTURE_BASE_PATH}/semantic_search/source_data.json`;
const filePath = `cypress/fixtures/${FF_FIXTURE_BASE_PATH}semantic_search/source_data.json`;
cy.get('input[type=file]').selectFile(filePath);
cy.getElementByDataTestId('closeSourceDataButton')
.should('be.visible')
Expand All @@ -115,6 +115,27 @@ describe('Creating Workflows Using Various Methods', () => {
.should('be.visible')
.click();
});
// Checking Run ingestion response
cy.sa_getElementByText('button.euiTab', 'Run ingestion')
.should('be.visible')
.click();
cy.fixture(FF_FIXTURE_BASE_PATH + 'semantic_search/ingest_response').then(
(expectedJson) => {
cy.get('#tools_panel_id .ace_editor .ace_content')
.should('be.visible')
.invoke('text')
.then((editorText) => {
expect(editorText).to.include(`"took": ${expectedJson.took}`);
expect(editorText).to.include(
`"ingest_took": ${expectedJson.ingest_took}`
);
expect(editorText).to.include(`"errors": ${expectedJson.errors}`);
expect(editorText).to.include(
`"result": "${expectedJson.items[0].index.result}"`
);
});
}
);
cy.getElementByDataTestId('searchPipelineButton')
.should('be.visible')
.click();
Expand Down Expand Up @@ -143,6 +164,24 @@ describe('Creating Workflows Using Various Methods', () => {
cy.mockSemanticSearchIndexSearch(() => {
cy.getElementByDataTestId('runQueryButton').should('be.visible').click();
});
// Checking Run query response
cy.sa_getElementByText('button.euiTab', 'Run query')
.should('be.visible')
.click();

cy.fixture(FF_FIXTURE_BASE_PATH + 'semantic_search/search_response').then(
(expectedSearchJson) => {
cy.get('#tools_panel_id .ace_editor .ace_content')
.should('be.visible')
.invoke('text')
.then((editorText) => {
const editorJson = JSON.parse(editorText);
expect(JSON.stringify(editorJson)).to.contain(
JSON.stringify(expectedSearchJson['hits']['hits'][0]['_source'])
);
});
}
);
});

it('create workflow using Sentiment Analysis template', () => {
Expand Down Expand Up @@ -200,13 +239,9 @@ describe('Creating Workflows Using Various Methods', () => {
});

after(() => {
if (MODEL_PARAMETERS.MODEL_ID != '') {
cy.undeployMLCommonsModel(MODEL_PARAMETERS.MODEL_ID).then((Response) => {
console.log('Response:', Response);
});
cy.deleteMLCommonsModel(MODEL_PARAMETERS.MODEL_ID).then((Response) => {
console.log('Response:', Response);
});
if (modelId != '') {
cy.undeployMLCommonsModel(modelId);
cy.deleteMLCommonsModel(modelId);
}
});
});
16 changes: 10 additions & 6 deletions cypress/utils/plugins/dashboards-flow-framework/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ Cypress.Commands.add('getWorkflowId', () => {
});

Cypress.Commands.add('mockIngestion', (funcMockedOn) => {
cy.intercept('POST', INGEST_NODE_API_PATH, {
statusCode: 200,
body: {},
}).as('ingestionRequest');
funcMockedOn();
cy.wait('@ingestionRequest');
cy.fixture(
FF_FIXTURE_BASE_PATH + 'semantic_search/ingest_response.json'
).then((ingestResponse) => {
cy.intercept('POST', INGEST_NODE_API_PATH, {
statusCode: 200,
body: ingestResponse,
}).as('ingestionRequest');
funcMockedOn();
cy.wait('@ingestionRequest');
});
});

Cypress.Commands.add('mockSemanticSearchIndexSearch', (funcMockedOn) => {
Expand Down
5 changes: 0 additions & 5 deletions cypress/utils/plugins/dashboards-flow-framework/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,3 @@ export const SEARCH_NODE_API_PATH =
export const FF_FIXTURE_BASE_PATH = 'plugins/dashboards-flow-framework/';

export const FF_TIMEOUT = 20000;

export const MODEL_PARAMETERS = {
CONNECTOR_ID: '',
MODEL_ID: '',
};

0 comments on commit ce749af

Please sign in to comment.