Cypress: sample data testing for ingestion (#5150)

* added sample data test for bigquery

* added sample data testing for mysql connector

* added sample data testing for redshift

* added snowflake sampledata test

* miner fix

* fixing typo

* miner fix
This commit is contained in:
Shailesh Parmar 2022-05-30 11:38:55 +05:30 committed by GitHub
parent 0005bc1292
commit 1e57d03a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 160 additions and 44 deletions

View File

@ -15,6 +15,47 @@ export const uuid = () => Cypress._.random(0, 1e6);
const isDatabaseService = (type) => type === 'database';
export const handleIngestionRetry = (type, count = 0) => {
// ingestions page
const retryTimes = 25;
let retryCount = count;
const testIngestionsTab = () => {
cy.get('[data-testid="Ingestions"]').should('be.visible');
cy.get('[data-testid="Ingestions"] >> [data-testid="filter-count"]').should(
'have.text',
1
);
// click on the tab only for the first time
if (retryCount === 0) {
cy.get('[data-testid="Ingestions"]').click();
}
if (isDatabaseService(type)) {
cy.get('[data-testid="add-new-ingestion-button"]').should('be.visible');
}
};
const checkSuccessState = () => {
testIngestionsTab();
retryCount++;
// the latest run should be success
cy.get('.tableBody-row > :nth-child(4)').then(($ingestionStatus) => {
if (
($ingestionStatus.text() === 'Running' ||
$ingestionStatus.text() === 'Queued') &&
retryCount <= retryTimes
) {
// retry after waiting for 20 seconds
cy.wait(20000);
cy.reload();
checkSuccessState();
} else {
cy.get('.tableBody-row > :nth-child(4)').should('have.text', 'Success');
}
});
};
checkSuccessState();
};
export const testServiceCreationAndIngestion = (
serviceType,
connectionInput,
@ -111,44 +152,7 @@ export const testServiceCreationAndIngestion = (
cy.get('[data-testid="view-service-button"]').should('be.visible');
cy.get('[data-testid="view-service-button"]').click();
// ingestions page
const retryTimes = 25;
let retryCount = 0;
const testIngestionsTab = () => {
cy.get('[data-testid="Ingestions"]').should('be.visible');
cy.get('[data-testid="Ingestions"] >> [data-testid="filter-count"]').should(
'have.text',
1
);
// click on the tab only for the first time
if (retryCount === 0) {
cy.get('[data-testid="Ingestions"]').click();
}
if (isDatabaseService(type)) {
cy.get('[data-testid="add-new-ingestion-button"]').should('be.visible');
}
};
const checkSuccessState = () => {
testIngestionsTab();
retryCount++;
// the latest run should be success
cy.get('.tableBody-row > :nth-child(4)').then(($ingestionStatus) => {
if (
($ingestionStatus.text() === 'Running' ||
$ingestionStatus.text() === 'Queued') &&
retryCount <= retryTimes
) {
// retry after waiting for 20 seconds
cy.wait(20000);
cy.reload();
checkSuccessState();
} else {
cy.get('.tableBody-row > :nth-child(4)').should('have.text', 'Success');
}
});
};
checkSuccessState();
handleIngestionRetry(type);
};
export const goToAddNewServicePage = () => {
@ -218,3 +222,65 @@ export const searchEntity = (term) => {
cy.get('[data-testid="searchBox"]').scrollIntoView().type(term);
cy.get('.tw-cursor-pointer > [data-testid="image"]').click();
};
export const testSampleData = (entity) => {
cy.goToHomePage();
// initially sample data should not be present
searchEntity(entity.term);
cy.get(`[data-testid="${entity.entity}-tab"]`).should('be.visible').click();
cy.get(`[data-testid="${entity.entity}-tab"]`)
.should('be.visible')
.should('have.class', 'active');
cy.wait(500);
cy.get('[data-testid="table-link"]').first().should('be.visible').click();
cy.get('[data-testid="Sample Data"]').should('be.visible').click();
cy.contains('No sample data available').should('be.visible');
// go to service details and modify ingestion to enable sample data
cy.get(':nth-child(1) > .link-title').should('be.visible').click();
cy.wait(500);
if (entity.entityType === 'database') {
cy.get('[data-testid="table-container"]').contains(entity.db);
}
cy.get('[data-testid="Ingestions"]').should('be.visible').click();
cy.get('[data-testid="edit"]').should('be.visible').click();
cy.get('[data-testid="toggle-button-ingest-sample-data"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="toggle-button-ingest-sample-data"]')
.scrollIntoView()
.should('be.visible')
.should('have.class', 'open');
cy.get('[data-testid="next-button"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="dbt-source"]').should('be.visible');
cy.get('[data-testid="submit-btn"]').should('be.visible').click();
cy.get('[data-testid="ingestion-type"]').should('be.visible');
cy.get('[data-testid="deploy-button"]').should('be.visible').click();
cy.contains('has been updated and deployed successfully').should(
'be.visible'
);
cy.get('[data-testid="view-service-button"]').should('be.visible').click();
cy.get('[data-testid="Ingestions"]')
.should('be.visible')
.should('have.class', 'active');
cy.get('[data-testid="run"]').should('be.visible').click();
cy.reload();
handleIngestionRetry(entity.entityType, 1);
searchEntity(entity.term);
cy.wait(500);
cy.get('[data-testid="table-link"]').first().should('be.visible').click();
cy.get('[data-testid="Sample Data"]').should('be.visible').click();
cy.contains('No sample data available').should('not.exist');
};

View File

@ -122,6 +122,37 @@ export const NEW_ADMIN = {
description: 'Hello, I am test admin',
};
export const BIG_QUERY_TABLE = {
term: 'users',
entity: MYDATA_SUMMARY_OPTIONS.tables,
db: 'modified-leaf-330420',
schema: 'stackoverflow',
entityType: 'database',
};
export const MY_SQL_TABLE = {
term: 'user_entity',
entity: MYDATA_SUMMARY_OPTIONS.tables,
db: 'openmetadata_db',
schema: 'openmetadata_db',
entityType: 'database',
};
export const RED_SHIFT_TABLE = {
term: 'raw_customers',
entity: MYDATA_SUMMARY_OPTIONS.tables,
db: 'dev',
schema: 'dbt_jaffle',
entityType: 'database',
};
export const SNOWFLAKE_TABLE = {
term: 'snow_t1',
entity: MYDATA_SUMMARY_OPTIONS.tables,
db: 'TESTDB',
schema: 'PUBLIC',
entityType: 'database',
};
export const NEW_TAG_CATEGORY = {
name: 'TestCategory',
description: 'This is the TestCategory',

View File

@ -11,7 +11,8 @@
* limitations under the License.
*/
import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common';
import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common';
import { BIG_QUERY_TABLE } from '../../constants/constants';
describe('BigQuery Ingestion', () => {
it('add and ingest data', () => {
@ -62,4 +63,8 @@ describe('BigQuery Ingestion', () => {
addIngestionInput
);
});
it('Check for Sample data in table entry', () => {
testSampleData(BIG_QUERY_TABLE);
});
});

View File

@ -26,7 +26,7 @@ describe('Kafka Ingestion', () => {
);
cy.get('#root_schemaRegistryURL').type(
Cypress.env('kafkaSchemaRegistryUrl')
)
);
};
const addIngestionInput = () => {

View File

@ -11,7 +11,8 @@
* limitations under the License.
*/
import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common';
import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common';
import { MY_SQL_TABLE } from '../../constants/constants';
describe('MySQL Ingestion', () => {
it('add and ingest data', () => {
@ -36,4 +37,8 @@ describe('MySQL Ingestion', () => {
addIngestionInput
);
});
it('Check for Sample data in table entry', () => {
testSampleData(MY_SQL_TABLE);
});
});

View File

@ -11,7 +11,8 @@
* limitations under the License.
*/
import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common';
import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common';
import { RED_SHIFT_TABLE } from '../../constants/constants';
describe('RedShift Ingestion', () => {
it('add and ingest data', () => {
@ -43,4 +44,8 @@ describe('RedShift Ingestion', () => {
addIngestionInput
);
});
it('Check for Sample data in table entry', () => {
testSampleData(RED_SHIFT_TABLE);
});
});

View File

@ -11,7 +11,8 @@
* limitations under the License.
*/
import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common';
import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common';
import { SNOWFLAKE_TABLE } from '../../constants/constants';
describe('Snowflake Ingestion', () => {
it('add and ingest data', { defaultCommandTimeout: 8000 }, () => {
@ -28,7 +29,7 @@ describe('Snowflake Ingestion', () => {
cy.get('[data-testid="schema-filter-pattern-checkbox"]').check();
cy.get('[data-testid="filter-pattern-includes-schema"]')
.should('be.visible')
.type('test_schema');
.type('public');
};
testServiceCreationAndIngestion(
@ -36,6 +37,9 @@ describe('Snowflake Ingestion', () => {
connectionInput,
addIngestionInput
);
});
it('Check for Sample data in table entry', () => {
testSampleData(SNOWFLAKE_TABLE);
});
});