Skip to content

Commit

Permalink
Merge branch 'main' into fix-#11857
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-madlani authored Jan 25, 2024
2 parents c487b63 + ac4dc7f commit ddc7136
Show file tree
Hide file tree
Showing 30 changed files with 531 additions and 908 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
interceptURL,
toastNotification,
verifyResponseStatusCode,
visitEntityDetailsPage,
} from './common';
import { visitEntityDetailsPage } from './Utils/Entity';

export const validateDomainForm = () => {
// error messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ class ServiceBaseClass {
.should('contain', description);
}

runAdditionalTests() {
// Write service specific tests
}

deleteService() {
deleteService(this.category, this.serviceName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { checkServiceFieldSectionHighlighting } from '../common';
import ServiceBaseClass from '../Entities/ServiceBaseClass';
import { Services } from '../Utils/Services';

class MetabaseIngestionClass extends ServiceBaseClass {
class BigQueryIngestionClass extends ServiceBaseClass {
name: string;
filterPattern;

Expand Down Expand Up @@ -88,4 +88,4 @@ class MetabaseIngestionClass extends ServiceBaseClass {
}
}

export default MetabaseIngestionClass;
export default BigQueryIngestionClass;
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;
Loading

0 comments on commit ddc7136

Please sign in to comment.