Skip to content

Commit

Permalink
refactor(#3388): Extend test to check if measurement is removed from …
Browse files Browse the repository at this point in the history
…asset links
  • Loading branch information
tenthe committed Jan 2, 2025
1 parent 08e01fc commit 94a53dd
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 37 deletions.
6 changes: 6 additions & 0 deletions ui/cypress/support/utils/asset/AssetBtns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class AssetBtns {
});
}

public static measurementCheckbox(measurementName: string) {
return cy.dataCy('select-measurement-checkbox-' + measurementName, {
timeout: 10000,
});
}

public static updateAssetLinksBtn() {
return cy.dataCy('assets-update-links-button', { timeout: 10000 });
}
Expand Down
4 changes: 4 additions & 0 deletions ui/cypress/support/utils/asset/AssetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class AssetUtils {
AssetBtns.pipelineCheckbox(pipelineName).click();
}

public static selectMeasurementAssetLink(measurementName: string) {
AssetBtns.measurementCheckbox(measurementName).click();
}

public static checkAmountOfAssets(amount: number) {
cy.dataCy('assets-table').should('have.length', amount);
}
Expand Down
21 changes: 0 additions & 21 deletions ui/cypress/support/utils/datalake/DataLakeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,6 @@ export class DataLakeUtils {
cy.dataCy('data-explorer-select-data-set-create-btn').click();
}

public static goToDatalakeConfiguration() {
cy.visit('#/configuration/datalake');
}

public static checkResults(
dataLakeIndex: string,
fileRoute: string,
Expand Down Expand Up @@ -447,23 +443,6 @@ export class DataLakeUtils {
return currentDate;
}

public static waitForCountingResults() {
cy.dataCy('datalake-number-of-events-spinner', {
timeout: 10000,
}).should('exist');
cy.dataCy('datalake-number-of-events-spinner', {
timeout: 10000,
}).should('not.exist');
}

public static getDatalakeNumberOfEvents(): Cypress.Chainable<string> {
return cy
.dataCy('datalake-number-of-events', { timeout: 10000 })
.should('be.visible')
.invoke('text')
.then(text => text.trim());
}

public static checkRowsDashboardTable(amount: number) {
cy.dataCy('dashboard-table-overview', {
timeout: 10000,
Expand Down
47 changes: 47 additions & 0 deletions ui/cypress/support/utils/datalake/MeasurementUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/

export class MeasurementUtils {
public static goToDatalakeConfiguration() {
cy.visit('#/configuration/datalake');
}

public static waitForCountingResults() {
cy.dataCy('datalake-number-of-events-spinner', {
timeout: 10000,
}).should('exist');
cy.dataCy('datalake-number-of-events-spinner', {
timeout: 10000,
}).should('not.exist');
}

public static getDatalakeNumberOfEvents(): Cypress.Chainable<string> {
return cy
.dataCy('datalake-number-of-events', { timeout: 10000 })
.should('be.visible')
.invoke('text')
.then(text => text.trim());
}

public static deleteMeasurement() {
cy.dataCy('datalake-delete-btn').should('be.visible').click();
cy.dataCy('confirm-delete-data-btn', { timeout: 10000 })
.should('be.visible')
.click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,35 @@ import { AssetBtns } from '../../../support/utils/asset/AssetBtns';
import { AssetUtils } from '../../../support/utils/asset/AssetUtils';
import { ConnectUtils } from '../../../support/utils/connect/ConnectUtils';
import { PipelineUtils } from '../../../support/utils/pipeline/PipelineUtils';
import { DataLakeUtils } from '../../../support/utils/datalake/DataLakeUtils';
import { MeasurementUtils } from '../../../support/utils/datalake/MeasurementUtils';

describe('Delete pipeline and auto remove asset links', () => {
describe('Delete pipeline and measurements and auto remove asset links', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
});

it('Perform Test', () => {
const assetName = 'TestAsset';
ConnectUtils.addMachineDataSimulator('Sample', true);
ConnectUtils.addMachineDataSimulator('sample', true);

// Add asset with pipeline
AssetUtils.goToAssets();
AssetUtils.addNewAsset(assetName);
AssetBtns.assetLinksTab().click();
AssetUtils.openManageAssetLinks();
AssetUtils.selectPipelineAssetLink('persist_sample');
AssetUtils.selectMeasurementAssetLink('sample');
AssetBtns.updateAssetLinksBtn().click();
AssetBtns.saveAssetBtn().click();

// delete pipeline
// delete resources that should remove also asset links
cy.wait(1000);
// PipelineUtils.goToPipelines();
PipelineUtils.deletePipeline();

MeasurementUtils.goToDatalakeConfiguration();
MeasurementUtils.deleteMeasurement();

// Check that asset link is removed
AssetUtils.goToAssets();
AssetUtils.checkAmountOfAssets(1);
Expand Down
11 changes: 6 additions & 5 deletions ui/cypress/tests/connect/editAdapter.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { AdapterBuilder } from '../../support/builder/AdapterBuilder';
import { ConnectEventSchemaUtils } from '../../support/utils/connect/ConnectEventSchemaUtils';
import { DataLakeUtils } from '../../support/utils/datalake/DataLakeUtils';
import { DataLakeBtns } from '../../support/utils/datalake/DataLakeBtns';
import { MeasurementUtils } from '../../support/utils/datalake/MeasurementUtils';

describe('Test Edit Adapter', () => {
beforeEach('Setup Test', () => {
Expand Down Expand Up @@ -94,21 +95,21 @@ describe('Test Edit Adapter', () => {
ConnectUtils.storeAndStartEditedAdapter();

// Validate that the data is further persisted in the database by checking if the amount of events in the data lake changes
DataLakeUtils.goToDatalakeConfiguration();
MeasurementUtils.goToDatalakeConfiguration();

DataLakeUtils.waitForCountingResults();
MeasurementUtils.waitForCountingResults();

let initialValue;

DataLakeUtils.getDatalakeNumberOfEvents().then(value => {
MeasurementUtils.getDatalakeNumberOfEvents().then(value => {
initialValue = value;
});

DataLakeBtns.refreshDataLakeMeasures().click();

DataLakeUtils.waitForCountingResults();
MeasurementUtils.waitForCountingResults();

DataLakeUtils.getDatalakeNumberOfEvents().then(newValue => {
MeasurementUtils.getDatalakeNumberOfEvents().then(newValue => {
// IMPORTANT: Currently we implemented a workaround by showing the user a warning message when the data type is changed.
// In the future, we need a migration mechanism to automatically change all the StreamPipes resources that are effected
// by the change. Once this is implemented the following line must be changed to .not.equal.
Expand Down
10 changes: 4 additions & 6 deletions ui/cypress/tests/datalake/configuration.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { PipelineUtils } from '../../support/utils/pipeline/PipelineUtils';
import { DataLakeUtils } from '../../support/utils/datalake/DataLakeUtils';
import { MeasurementUtils } from '../../support/utils/datalake/MeasurementUtils';

describe('Test Truncate data in datalake', () => {
beforeEach('Setup Test', () => {
Expand All @@ -26,7 +27,7 @@ describe('Test Truncate data in datalake', () => {
});

it('Perform Test', () => {
DataLakeUtils.goToDatalakeConfiguration();
MeasurementUtils.goToDatalakeConfiguration();

// Check if amount of events is correct
cy.dataCy('datalake-number-of-events', { timeout: 10000 })
Expand Down Expand Up @@ -57,18 +58,15 @@ describe('Delete data in datalake', () => {
});

it('Perform Test', () => {
DataLakeUtils.goToDatalakeConfiguration();
MeasurementUtils.goToDatalakeConfiguration();

// Check if amount of events is correct
cy.dataCy('datalake-number-of-events', { timeout: 10000 })
.should('be.visible')
.contains('10');

// Delete data
cy.dataCy('datalake-delete-btn').should('be.visible').click();
cy.dataCy('confirm-delete-data-btn', { timeout: 10000 })
.should('be.visible')
.click();
MeasurementUtils.deleteMeasurement();

// Check if amount of events is zero
cy.dataCy('datalake-number-of-events', { timeout: 10000 }).should(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { DashboardUtils } from '../../../support/utils/DashboardUtils';
import { DataLakeUtils } from '../../../support/utils/datalake/DataLakeUtils';
import { MeasurementUtils } from '../../../support/utils/datalake/MeasurementUtils';

describe('Validate StreamPipes after restart', () => {
beforeEach('Setup Test', () => {
Expand All @@ -26,7 +27,7 @@ describe('Validate StreamPipes after restart', () => {

it('Perform Test', () => {
// Truncate data in db
DataLakeUtils.goToDatalakeConfiguration();
MeasurementUtils.goToDatalakeConfiguration();
cy.dataCy('datalake-truncate-btn').should('be.visible').click();
cy.dataCy('confirm-truncate-data-btn', { timeout: 10000 })
.should('be.visible')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@
<mat-checkbox
color="accent"
[checked]="linkSelected(element.elementId)"
[attr.data-cy]="
'select-measurement-checkbox-' +
element.measureName
.toLowerCase()
.replaceAll(' ', '_')
"
(change)="
selectLink(
$event.checked,
Expand Down

0 comments on commit 94a53dd

Please sign in to comment.