forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] MongoDB Connector cypress test. (elastic#155886)
## Summary Add automated tests via Cypress for MongoDB and Web Crawler happy paths. Tests are quite basic and covers only adding simple one time sync paths. Fill in the `cypress.env.json` with the credentials before running. Mongo specs will run only against a local environment (via `./cypress.sh dev`) as connector has to be running locally as well. ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
8c87a3f
commit a4953ed
Showing
22 changed files
with
299 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"mongo_test": { | ||
"host": "", | ||
"username": "", | ||
"password": "", | ||
"database": "", | ||
"collection": "" | ||
}, | ||
"crawler_test": { | ||
"domain": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
x-pack/plugins/enterprise_search/cypress/e2e/content/new_index/mongo_connector.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { login } from '../../../tasks/login'; | ||
import { | ||
CONNECTOR_INDEX, | ||
getIndexRoute, | ||
INDEX_OVERVIEW, | ||
NEW_INDEX_CARD, | ||
NEW_CONNECTOR_PAGE, | ||
ROUTES, | ||
SELECT_CONNECTOR, | ||
SEARCH_INDICES, | ||
} from '../selectors'; | ||
|
||
describe('Enterprise Search MongoDB connector', () => { | ||
it('succesfully syncs documents with single sync', () => { | ||
// Get configuration information from cypress.env.json | ||
const mongoConfig = Cypress.env('mongo_test'); | ||
const indexName = 'cypress-mongodb-' + Math.random(); | ||
const baseUrl = Cypress.config().baseUrl; | ||
login(); | ||
|
||
cy.visit(ROUTES.SEARCH_INDICES_OVERVIEW); | ||
cy.getBySel(SEARCH_INDICES.CREATE_INDEX_BUTTON).click(); | ||
|
||
cy.url().should('eq', baseUrl + ROUTES.NEW_INDEX); | ||
|
||
// select connector | ||
cy.getBySel(NEW_INDEX_CARD.SELECT_CONNECTOR).click(); | ||
|
||
// we are in correct route | ||
cy.url().should('contain', ROUTES.SELECT_CONNECTOR); | ||
|
||
// Select MongoDB from the list | ||
cy.get('#checkableCard-mongodb').should('not.be.selected'); | ||
cy.get('#checkableCard-mongodb-details') | ||
.find('a') | ||
.invoke('attr', 'href') | ||
.should('include', 'connectors-mongodb.html'); | ||
|
||
cy.get('#checkableCard-mongodb').click(); | ||
|
||
cy.getBySel(SELECT_CONNECTOR.SELECT_AND_CONFIGURE_BUTTON).click(); | ||
|
||
// Connector URL, mongo selected | ||
cy.url().should('contain', 'service_type=mongodb'); | ||
|
||
cy.getBySel(NEW_CONNECTOR_PAGE.INDEX_NAME_INPUT).type(indexName); | ||
|
||
// create index | ||
cy.getBySel(NEW_CONNECTOR_PAGE.CREATE_BUTTON).click(); | ||
|
||
// make sure we are in new index route | ||
cy.url().should('contain', getIndexRoute(indexName) + 'configuration'); | ||
|
||
// Fill in connector configuration | ||
cy.getBySel(CONNECTOR_INDEX.getConfigurationRow('host')).type(mongoConfig.host); | ||
cy.getBySel(CONNECTOR_INDEX.getConfigurationRow('user')).type(mongoConfig.username); | ||
cy.getBySel(CONNECTOR_INDEX.getConfigurationRow('password')).type(mongoConfig.password); | ||
cy.getBySel(CONNECTOR_INDEX.getConfigurationRow('database')).type(mongoConfig.database); | ||
cy.getBySel(CONNECTOR_INDEX.getConfigurationRow('collection')).type(mongoConfig.collection); | ||
cy.getBySel(CONNECTOR_INDEX.SAVE_CONFIG).click(); | ||
|
||
// Wait until configuration is saved | ||
cy.getBySel(CONNECTOR_INDEX.EDIT_CONFIG); | ||
cy.getBySel(CONNECTOR_INDEX.SET_SCHEDULE_BUTTON).click(); | ||
|
||
// Scheduling Tab opened | ||
cy.url().should('contain', getIndexRoute(indexName) + 'scheduling'); | ||
|
||
// Start one time sync | ||
cy.getBySel(CONNECTOR_INDEX.HEADER_SYNC_MENU).click(); | ||
cy.getBySel(CONNECTOR_INDEX.HEADER_SYNC_MENU_START).click(); | ||
|
||
// go to overview tab | ||
cy.getBySel(INDEX_OVERVIEW.TABS.OVERVIEW).click(); | ||
|
||
cy.getBySel(INDEX_OVERVIEW.STATS.INGESTION_TYPE).should('contain.text', 'Connector'); | ||
cy.getBySel(INDEX_OVERVIEW.STATS.CONNECTOR_TYPE).should('contain.text', 'MongoDB'); | ||
cy.getBySel(INDEX_OVERVIEW.STATS.INGESTION_STATUS).should('contain.text', 'Configured'); | ||
cy.getBySel(INDEX_OVERVIEW.STATS.INGESTION_STATUS).should('contain.text', 'Connected'); | ||
|
||
// Wait until document count > 0 | ||
cy.getBySel(INDEX_OVERVIEW.STATS.DOCUMENT_COUNT).should((el) => { | ||
const text = el.text(); | ||
const count = parseInt(text.match(/[0-9]+/g), 10); | ||
expect(count).to.gt(0); | ||
}); | ||
}); | ||
}); |
70 changes: 70 additions & 0 deletions
70
x-pack/plugins/enterprise_search/cypress/e2e/content/selectors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export const ROUTES = { | ||
CRAWLER_INDEX: '/app/enterprise_search/content/search_indices/new_index/crawler', | ||
NEW_INDEX: '/app/enterprise_search/content/search_indices/new_index', | ||
SEARCH_INDICES_OVERVIEW: '/app/enterprise_search/content/search_indices/', | ||
SELECT_CONNECTOR: '/app/enterprise_search/content/search_indices/new_index/select_connector', | ||
}; | ||
|
||
export const SEARCH_INDICES = { | ||
CREATE_INDEX_BUTTON: 'entSearchContent-searchIndices-createButton', | ||
}; | ||
|
||
export const SELECT_CONNECTOR = { | ||
SELECT_AND_CONFIGURE_BUTTON: 'entSearchContent-connector-selectConnector-selectAndConfigure', | ||
}; | ||
|
||
export const NEW_CONNECTOR_PAGE = { | ||
CREATE_BUTTON: 'entSearchContent-connector-newIndex-createIndex', | ||
INDEX_NAME_INPUT: 'entSearchContent-connector-newIndex-editName', | ||
}; | ||
|
||
export const CONNECTOR_INDEX = { | ||
EDIT_CONFIG: 'entSearchContent-connector-configuration-editConfiguration', | ||
HEADER_SYNC_MENU: 'entSearchContent-connector-header-sync-menu', | ||
HEADER_SYNC_MENU_START: 'entSearchContent-connector-header-sync-startSync', | ||
SAVE_CONFIG: 'entSearchContent-connector-configuration-saveConfiguration', | ||
SET_SCHEDULE_BUTTON: 'entSearchContent-connector-configuration-setScheduleAndSync', | ||
getConfigurationRow: (rowkey: string) => | ||
`entSearchContent-connector-configuration-formrow-${rowkey}`, | ||
}; | ||
|
||
export const NEW_INDEX_CARD = { | ||
SELECT_CONNECTOR: 'entSearchContent-newIndexCard-button-connector', | ||
SELECT_CRAWLER: 'entSearchContent-newIndexCard-button-crawler', | ||
}; | ||
|
||
export const CRAWLER_INDEX = { | ||
CRAWL_ALL_DOMAINS: 'entSearchContent-crawler-startCrawlMenu-crawlAllDomains', | ||
CRAWL_DROPDOWN: 'entSearchContent-crawler-startCrawlMenu-menuButton', | ||
CREATE_BUTTON: 'entSearchContent-crawler-newIndex-createIndex', | ||
DOMAIN_MANAGEMENT: { | ||
DOMAIN_BUTTON: 'entSearchContent-crawler-addDomainForm-validate-button', | ||
DOMAIN_INPUT: 'entSearchContent-crawler-addDomainForm-validate-input', | ||
SUBMIT_BUTTON: 'entSearchContent-crawler-addDomain-submitButton', | ||
}, | ||
INDEX_NAME_INPUT: 'entSearchContent-crawler-newIndex-editName', | ||
}; | ||
|
||
export const INDEX_OVERVIEW = { | ||
STATS: { | ||
CONNECTOR_TYPE: 'entSearchContent-indexOverview-totalStats-connectorType', | ||
DOCUMENT_COUNT: 'entSearchContent-indexOverview-totalStats-documentCount', | ||
INGESTION_STATUS: 'entSearchContent-indexOverview-connectorStats-ingestionStatus', | ||
INGESTION_TYPE: 'entSearchContent-indexOverview-totalStats-ingestionType', | ||
}, | ||
TABS: { | ||
CRAWLER_SCHEDULER: 'entSearchContent-index-crawler-scheduler-tab', | ||
OVERVIEW: 'entSearchContent-index-overview-tab', | ||
}, | ||
}; | ||
|
||
export const getIndexRoute = (indexName: string) => { | ||
return `/app/enterprise_search/content/search_indices/search-${indexName}/`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.