-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
531 additions
and
908 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
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
183 changes: 183 additions & 0 deletions
183
openmetadata-ui/src/main/resources/ui/cypress/common/Services/PostgresIngestionClass.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,183 @@ | ||
/* | ||
* Copyright 2024 Collate. | ||
* Licensed 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 { SERVICE_TYPE } from '../../constants/constants'; | ||
import { EntityType } from '../../constants/Entity.interface'; | ||
import { | ||
checkServiceFieldSectionHighlighting, | ||
handleIngestionRetry, | ||
interceptURL, | ||
scheduleIngestion, | ||
verifyResponseStatusCode, | ||
} from '../common'; | ||
import ServiceBaseClass from '../Entities/ServiceBaseClass'; | ||
import { visitServiceDetailsPage } from '../serviceUtils'; | ||
import { visitEntityDetailsPage } from '../Utils/Entity'; | ||
import { Services } from '../Utils/Services'; | ||
|
||
class PostgresIngestionClass extends ServiceBaseClass { | ||
name: string; | ||
filterPattern: string; | ||
queryLogFilePath: string; | ||
|
||
constructor() { | ||
super(Services.Database, 'cypress-Postgres', 'Postgres', 'order_items'); | ||
|
||
this.filterPattern = 'sales'; | ||
this.queryLogFilePath = | ||
'/home/airflow/ingestion/examples/sample_data/usage/query_log.csv'; | ||
} | ||
|
||
createService() { | ||
super.createService(); | ||
} | ||
|
||
updateService() { | ||
super.updateService(); | ||
} | ||
|
||
fillConnectionDetails() { | ||
cy.get('#root\\/username') | ||
.scrollIntoView() | ||
.type(Cypress.env('postgresUsername')); | ||
checkServiceFieldSectionHighlighting('username'); | ||
cy.get('#root\\/authType\\/password') | ||
.scrollIntoView() | ||
.type(Cypress.env('postgresPassword')); | ||
checkServiceFieldSectionHighlighting('password'); | ||
cy.get('#root\\/hostPort') | ||
.scrollIntoView() | ||
.type(Cypress.env('postgresHostPort')); | ||
checkServiceFieldSectionHighlighting('hostPort'); | ||
cy.get('#root\\/database') | ||
.scrollIntoView() | ||
.type(Cypress.env('postgresDatabase')); | ||
checkServiceFieldSectionHighlighting('database'); | ||
} | ||
|
||
fillIngestionDetails() { | ||
cy.get('#root\\/schemaFilterPattern\\/includes') | ||
.scrollIntoView() | ||
.type(`${this.filterPattern}{enter}`); | ||
} | ||
|
||
runAdditionalTests() { | ||
it('Add Usage ingestion', () => { | ||
interceptURL( | ||
'GET', | ||
'api/v1/teams/name/Organization?fields=*', | ||
'getSettingsPage' | ||
); | ||
interceptURL( | ||
'POST', | ||
'/api/v1/services/ingestionPipelines/deploy/*', | ||
'deployIngestion' | ||
); | ||
interceptURL( | ||
'GET', | ||
'/api/v1/permissions/ingestionPipeline/name/*', | ||
'ingestionPermissions' | ||
); | ||
|
||
visitServiceDetailsPage( | ||
{ type: SERVICE_TYPE.Database, name: this.serviceName }, | ||
false | ||
); | ||
|
||
cy.get('[data-testid="ingestions"]') | ||
.scrollIntoView() | ||
.should('be.visible') | ||
.click(); | ||
verifyResponseStatusCode('@ingestionPermissions', 200); | ||
cy.get('[data-testid="ingestion-details-container"]').should('exist'); | ||
cy.get('[data-testid="add-new-ingestion-button"]') | ||
.should('be.visible') | ||
.click(); | ||
cy.get('[data-menu-id*="usage"') | ||
.scrollIntoView() | ||
.contains('Usage Ingestion') | ||
.click(); | ||
|
||
cy.get('#root\\/queryLogFilePath') | ||
.scrollIntoView() | ||
.type(this.queryLogFilePath); | ||
cy.get('[data-testid="submit-btn"]') | ||
.scrollIntoView() | ||
.should('be.visible') | ||
.click(); | ||
|
||
scheduleIngestion(); | ||
|
||
cy.wait('@deployIngestion').then(() => { | ||
interceptURL( | ||
'GET', | ||
'/api/v1/services/ingestionPipelines?*', | ||
'ingestionPipelines' | ||
); | ||
interceptURL('GET', '/api/v1/services/*/name/*', 'serviceDetails'); | ||
interceptURL( | ||
'GET', | ||
'/api/v1/services/ingestionPipelines/status', | ||
'getIngestionPipelineStatus' | ||
); | ||
cy.get('[data-testid="view-service-button"]') | ||
.scrollIntoView() | ||
.should('be.visible') | ||
.click(); | ||
verifyResponseStatusCode('@getIngestionPipelineStatus', 200); | ||
verifyResponseStatusCode('@serviceDetails', 200); | ||
verifyResponseStatusCode('@ingestionPipelines', 200); | ||
|
||
handleIngestionRetry('database', true, 0, 'usage'); | ||
}); | ||
}); | ||
|
||
it('Verify if usage is ingested properly', () => { | ||
interceptURL( | ||
'GET', | ||
`/api/v1/tables/name/${this.serviceName}.*.*${this.entityName}?fields=*&include=all`, | ||
'entityDetailsPage' | ||
); | ||
visitEntityDetailsPage({ | ||
term: this.entityName, | ||
serviceName: this.serviceName, | ||
entity: EntityType.Table, | ||
}); | ||
verifyResponseStatusCode('@entityDetailsPage', 200); | ||
interceptURL('GET', '/api/v1/queries?*', 'queriesTab'); | ||
cy.get('[data-testid="table_queries"]') | ||
.should('be.visible') | ||
.trigger('click'); | ||
verifyResponseStatusCode('@queriesTab', 200); | ||
// Validate that the triggered query is visible in the queries container | ||
// cy.get('[data-testid="queries-container"]') | ||
// .should('be.visible') | ||
// .should('contain', selectQuery); | ||
// Validate queries count is greater than 1 | ||
// Skip since query ingestion not working as expected | ||
// cy.get('[data-testid="table_queries"] [data-testid="filter-count"]') | ||
// .invoke('text') | ||
// .should('equal', '1'); | ||
// Validate schema contains frequently joined tables and columns | ||
cy.get('[data-testid="schema"]').should('be.visible').click(); | ||
cy.get('[data-testid="related-tables-data"]').should('be.visible'); | ||
cy.get('[data-testid="frequently-joined-columns"]').should('be.visible'); | ||
}); | ||
} | ||
|
||
deleteService() { | ||
super.deleteService(); | ||
} | ||
} | ||
|
||
// eslint-disable-next-line jest/no-export | ||
export default PostgresIngestionClass; |
Oops, something went wrong.