You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/06/23 09:29:20 UTC

[incubator-streampipes] branch STREAMPIPES-380 updated (6d2a9f8 -> 0315e60)

This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a change to branch STREAMPIPES-380
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git.


    from 6d2a9f8  [STREAMPIPES-380] Add apache headers and fix linting issues
     new e25ac3d  [STREAMPIPES-380] Add cypress test to install system
     new 0315e60  [STREAMPIPES-380] Create builder for processer cypress tests

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ui/cypress/README.md                               |  2 +-
 .../installation.ts}                               | 27 ++++++++++++------
 .../pipelineElement/fieldRenamerTest1.ts           | 18 ++++++------
 .../pipelineElement/numericalFilterTest1.ts        | 16 +++++------
 .../support/builder/ProcessorTestBuilder.ts        | 33 ++++++++++++++--------
 ui/cypress/support/general/dataCy.ts               | 10 +++++--
 ui/cypress/support/general/login.ts                |  6 ++--
 .../support/model/ProcessorTest.ts}                |  8 ++++--
 ui/cypress/support/utils/AdapterUtils.ts           |  6 ++--
 ui/cypress/support/utils/DataLakeUtils.ts          |  4 +--
 ui/cypress/support/utils/PipelineUtils.ts          |  8 +++---
 .../support/utils/ProcessingElementTestUtils.ts    | 16 +++++++----
 .../cypress/support/utils/UserUtils.ts             |  7 ++---
 .../login/components/setup/setup.component.html    |  5 ++--
 14 files changed, 100 insertions(+), 66 deletions(-)
 copy ui/cypress/integration/{fileManagement/testFileManagement.ts => installation/installation.ts} (52%)
 copy streampipes-dataformat-fst/src/main/java/org/apache/streampipes/dataformat/fst/FstDataFormatFactory.java => ui/cypress/support/builder/ProcessorTestBuilder.ts (57%)
 copy ui/{src/app/pipeline-details/components/model/pipeline-details.model.ts => cypress/support/model/ProcessorTest.ts} (86%)
 copy streampipes-client/src/main/java/org/apache/streampipes/client/api/SupportsPipelineApi.java => ui/cypress/support/utils/UserUtils.ts (85%)

[incubator-streampipes] 02/02: [STREAMPIPES-380] Create builder for processer cypress tests

Posted by ze...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch STREAMPIPES-380
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 0315e6002264e1072c905b21bfdb5d5e43ab6ed2
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Jun 23 11:27:58 2021 +0200

    [STREAMPIPES-380] Create builder for processer cypress tests
---
 .../pipelineElement/fieldRenamerTest1.ts           | 18 +++++-----
 .../pipelineElement/numericalFilterTest1.ts        | 16 ++++-----
 .../builder/ProcessorTestBuilder.ts}               | 39 +++++++++++++---------
 .../model/ProcessorTest.ts}                        | 25 +++-----------
 .../support/utils/ProcessingElementTestUtils.ts    | 16 ++++++---
 5 files changed, 56 insertions(+), 58 deletions(-)

diff --git a/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts b/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
index 5d0414b..50f3c2b 100644
--- a/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
+++ b/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
@@ -18,6 +18,7 @@
 
 import { ProcessingElementTestUtils } from '../../support/utils/ProcessingElementTestUtils';
 import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
+import { ProcessorTestBuilder } from '../../support/builder/ProcessorTestBuilder';
 
 describe('Test Field Renamer 1', () => {
 
@@ -25,15 +26,14 @@ describe('Test Field Renamer 1', () => {
         cy.login();
     });
 
-    // Config
-    const testName = 'fieldRenamer1';
-    const inputFile = 'pipelineElement/fieldRenamer1/input.csv';
-    const expectedResultFile = 'pipelineElement/fieldRenamer1/expected.csv';
+    const processorTest = ProcessorTestBuilder.create('fieldRenamer1')
+      .setProcessor(
+        PipelineElementBuilder.create('field_renamer')
+          .addInput('drop-down', 'convert-property', 'count')
+          .addInput('input', 'field-name', 'newname')
+          .build())
+      .build();
 
-    const processor = PipelineElementBuilder.create('field_renamer')
-        .addInput('drop-down', 'convert-property', 'count')
-        .addInput('input', 'field-name', 'newname')
-        .build();
+    ProcessingElementTestUtils.testElement(processorTest);
 
-    ProcessingElementTestUtils.testElement(testName, inputFile, expectedResultFile, processor);
 });
diff --git a/ui/cypress/integration/pipelineElement/numericalFilterTest1.ts b/ui/cypress/integration/pipelineElement/numericalFilterTest1.ts
index 1e18773..06402c4 100644
--- a/ui/cypress/integration/pipelineElement/numericalFilterTest1.ts
+++ b/ui/cypress/integration/pipelineElement/numericalFilterTest1.ts
@@ -18,6 +18,8 @@
 
 import { ProcessingElementTestUtils } from '../../support/utils/ProcessingElementTestUtils';
 import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
+import { ProcessorTest } from '../../support/model/ProcessorTest';
+import { ProcessorTestBuilder } from '../../support/builder/ProcessorTestBuilder';
 
 describe('Test Numerical Filter 1', () => {
 
@@ -25,16 +27,14 @@ describe('Test Numerical Filter 1', () => {
         cy.login();
     });
 
-    // Config
-    const testName = 'numericalFilter1';
-    const inputFile = 'pipelineElement/numericalFilter1/input.csv';
-    const expectedResultFile = 'pipelineElement/numericalFilter1/expected.csv';
-
-    const processor = PipelineElementBuilder.create('numerical_filter')
+    const processorTest = ProcessorTestBuilder.create('numericalFilter1')
+      .setProcessor(
+        PipelineElementBuilder.create('numerical_filter')
         .addInput('drop-down', 'number-mapping', 'randomnumber')
         .addInput('radio', 'operation', '\\>')
         .addInput('input', 'value', '50')
-        .build();
+        .build())
+      .build();
 
-    ProcessingElementTestUtils.testElement(testName, inputFile, expectedResultFile, processor);
+    ProcessingElementTestUtils.testElement(processorTest);
 });
diff --git a/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts b/ui/cypress/support/builder/ProcessorTestBuilder.ts
similarity index 51%
copy from ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
copy to ui/cypress/support/builder/ProcessorTestBuilder.ts
index 5d0414b..eced60f 100644
--- a/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
+++ b/ui/cypress/support/builder/ProcessorTestBuilder.ts
@@ -16,24 +16,31 @@
  *
  */
 
-import { ProcessingElementTestUtils } from '../../support/utils/ProcessingElementTestUtils';
-import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
+import { SpecificAdapterInput } from '../model/SpecificAdapterInput';
+import { UserInput } from '../model/UserInput';
+import { ProcessorTest } from '../model/ProcessorTest';
+import { PipelineElementInput } from '../model/PipelineElementInput';
 
-describe('Test Field Renamer 1', () => {
+export class ProcessorTestBuilder {
 
-    it('Login', () => {
-        cy.login();
-    });
 
-    // Config
-    const testName = 'fieldRenamer1';
-    const inputFile = 'pipelineElement/fieldRenamer1/input.csv';
-    const expectedResultFile = 'pipelineElement/fieldRenamer1/expected.csv';
+  processorTest: ProcessorTest;
 
-    const processor = PipelineElementBuilder.create('field_renamer')
-        .addInput('drop-down', 'convert-property', 'count')
-        .addInput('input', 'field-name', 'newname')
-        .build();
+  constructor(name: string) {
+    this.processorTest = new ProcessorTest();
+    this.processorTest.name = name;
+  }
 
-    ProcessingElementTestUtils.testElement(testName, inputFile, expectedResultFile, processor);
-});
+  public static create(name: string) {
+    return new ProcessorTestBuilder(name);
+  }
+
+  public setProcessor(processor: PipelineElementInput) {
+    this.processorTest.processor = processor;
+    return this;
+  }
+
+  build() {
+    return this.processorTest;
+  }
+}
diff --git a/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts b/ui/cypress/support/model/ProcessorTest.ts
similarity index 51%
copy from ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
copy to ui/cypress/support/model/ProcessorTest.ts
index 5d0414b..bd6e40e 100644
--- a/ui/cypress/integration/pipelineElement/fieldRenamerTest1.ts
+++ b/ui/cypress/support/model/ProcessorTest.ts
@@ -16,24 +16,9 @@
  *
  */
 
-import { ProcessingElementTestUtils } from '../../support/utils/ProcessingElementTestUtils';
-import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
+import { PipelineElementInput } from './PipelineElementInput';
 
-describe('Test Field Renamer 1', () => {
-
-    it('Login', () => {
-        cy.login();
-    });
-
-    // Config
-    const testName = 'fieldRenamer1';
-    const inputFile = 'pipelineElement/fieldRenamer1/input.csv';
-    const expectedResultFile = 'pipelineElement/fieldRenamer1/expected.csv';
-
-    const processor = PipelineElementBuilder.create('field_renamer')
-        .addInput('drop-down', 'convert-property', 'count')
-        .addInput('input', 'field-name', 'newname')
-        .build();
-
-    ProcessingElementTestUtils.testElement(testName, inputFile, expectedResultFile, processor);
-});
+export class ProcessorTest {
+  name: string;
+  processor: PipelineElementInput;
+}
diff --git a/ui/cypress/support/utils/ProcessingElementTestUtils.ts b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
index cc0be3c..30e9944 100644
--- a/ui/cypress/support/utils/ProcessingElementTestUtils.ts
+++ b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
@@ -24,16 +24,22 @@ import { DataLakeUtils } from './DataLakeUtils';
 import { GenericAdapterBuilder } from '../builder/GenericAdapterBuilder';
 import { PipelineBuilder } from '../builder/PipelineBuilder';
 import { PipelineElementBuilder } from '../builder/PipelineElementBuilder';
+import { ProcessorTest } from '../model/ProcessorTest';
 
 export class ProcessingElementTestUtils {
 
-    public static testElement(testName: string, inputFile: string, expectedResultFile: string, processor: PipelineElementInput) {
+    public static testElement(pipelineElementTest: ProcessorTest) {
+    // public static testElement(testName: string, inputFile: string, expectedResultFile: string, processor: PipelineElementInput) {
         // Test
+
+        const inputFile = 'pipelineElement/' + pipelineElementTest.name + '/input.csv';
+        const expectedResultFile = 'pipelineElement/' + pipelineElementTest.name + '/expected.csv';
+
         FileManagementUtils.addFile(inputFile);
 
-        const dataLakeIndex = testName.toLowerCase();
+        const dataLakeIndex = pipelineElementTest.name.toLowerCase();
 
-        const adapterName = testName.toLowerCase();
+        const adapterName = pipelineElementTest.name.toLowerCase();
 
         // Build adapter
         const adapterInput = GenericAdapterBuilder
@@ -49,9 +55,9 @@ export class ProcessingElementTestUtils {
         AdapterUtils.addGenericSetAdapter(adapterInput);
 
         // Build Pipeline
-        const pipelineInput = PipelineBuilder.create(testName)
+        const pipelineInput = PipelineBuilder.create(pipelineElementTest.name)
             .addSource(adapterName)
-            .addProcessingElement(processor)
+            .addProcessingElement(pipelineElementTest.processor)
             .addSink(
                 PipelineElementBuilder.create('data_lake')
                     .addInput('input', 'db_measurement', dataLakeIndex)

[incubator-streampipes] 01/02: [STREAMPIPES-380] Add cypress test to install system

Posted by ze...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch STREAMPIPES-380
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit e25ac3d0000baf615388222bcb5734323eceb306
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Jun 23 11:00:07 2021 +0200

    [STREAMPIPES-380] Add cypress test to install system
---
 ui/cypress/README.md                               |  2 +-
 .../installation/installation.ts}                  | 41 ++++++++++++----------
 ui/cypress/support/general/dataCy.ts               | 10 ++++--
 ui/cypress/support/general/login.ts                |  6 ++--
 ui/cypress/support/utils/AdapterUtils.ts           |  6 ++--
 ui/cypress/support/utils/DataLakeUtils.ts          |  4 +--
 ui/cypress/support/utils/PipelineUtils.ts          |  8 ++---
 .../{general/dataCy.ts => utils/UserUtils.ts}      | 16 ++-------
 .../login/components/setup/setup.component.html    |  5 +--
 9 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/ui/cypress/README.md b/ui/cypress/README.md
index 0d3ab5e..99bf847 100644
--- a/ui/cypress/README.md
+++ b/ui/cypress/README.md
@@ -28,7 +28,7 @@ npm run test-e2e
 
 **User**: test@streampipes.apache.org **Password**: test1234
 
->**Note:** This can be changed in **support/general/login.ts**
+>**Note:** This can be changed in **support/utils/UserUtils.ts**
 
 
 >**Note:** The base URL can be configured in **cypress.json**
diff --git a/ui/cypress/support/general/login.ts b/ui/cypress/integration/installation/installation.ts
similarity index 52%
copy from ui/cypress/support/general/login.ts
copy to ui/cypress/integration/installation/installation.ts
index a6e709e..e5781d6 100644
--- a/ui/cypress/support/general/login.ts
+++ b/ui/cypress/integration/installation/installation.ts
@@ -16,25 +16,28 @@
  *
  */
 
-declare global {
-    namespace Cypress {
-        interface Chainable {
-            /**
-             * Login into streampipes with standard test user
-             * @example cy.login();
-             */
-            login: typeof login;
-        }
-    }
-}
+import { UserUtils } from '../../support/utils/UserUtils';
 
-export const login = () => {
-    Cypress.Cookies.defaults({
-        preserve: 'JSESSIONID'
-    });
+describe('Install StreamPipes', () => {
+  it('Open Streampipes', () => {
+    cy.visit('#/login');
+  });
+
+  let isSetupPage: boolean;
+
+  it('Install StreamPipes', () => {
+    cy.url({ timeout: 60000 }).then(($route) => {
+      isSetupPage = ($route.endsWith('setup')) ? true : false;
+      if (isSetupPage) {
+        cy.get('input[name="email"]').type(UserUtils.testUserName);
+        cy.get('input[name="password"]').type(UserUtils.testUserPassword);
 
-    cy.request('POST', '/streampipes-backend/api/v2/admin/login', {
-        username: 'test@streampipes.apache.org',
-        password: 'test1234'
+        cy.get('button').contains('Install').parent().click();
+
+        cy.dataCy('sp-button-finish-installation', { timeout: 240000 }).should('be.visible');
+        cy.dataCy('sp-button-finish-installation').click();
+      }
     });
-};
+  });
+
+});
diff --git a/ui/cypress/support/general/dataCy.ts b/ui/cypress/support/general/dataCy.ts
index 0162ce3..7a2e98a 100644
--- a/ui/cypress/support/general/dataCy.ts
+++ b/ui/cypress/support/general/dataCy.ts
@@ -22,11 +22,15 @@ declare global {
             /**
              * Select cypress id's ([data-cy=...])
              */
-            dataCy(value: string): Chainable<Element>;
+            dataCy(value: string, config?: any): Chainable<Element>;
         }
     }
 }
 
-export const dataCy = (value) => {
-    return cy.get(`[data-cy=${value}]`);
+export const dataCy = (value, config?) => {
+    if (config) {
+        return cy.get(`[data-cy=${value}]`, config);
+    } else {
+        return cy.get(`[data-cy=${value}]`);
+    }
 };
diff --git a/ui/cypress/support/general/login.ts b/ui/cypress/support/general/login.ts
index a6e709e..d165242 100644
--- a/ui/cypress/support/general/login.ts
+++ b/ui/cypress/support/general/login.ts
@@ -16,6 +16,8 @@
  *
  */
 
+import { UserUtils } from '../utils/UserUtils';
+
 declare global {
     namespace Cypress {
         interface Chainable {
@@ -34,7 +36,7 @@ export const login = () => {
     });
 
     cy.request('POST', '/streampipes-backend/api/v2/admin/login', {
-        username: 'test@streampipes.apache.org',
-        password: 'test1234'
+        username: UserUtils.testUserName,
+        password: UserUtils.testUserPassword
     });
 };
diff --git a/ui/cypress/support/utils/AdapterUtils.ts b/ui/cypress/support/utils/AdapterUtils.ts
index c244ab4..b2e2cbf 100644
--- a/ui/cypress/support/utils/AdapterUtils.ts
+++ b/ui/cypress/support/utils/AdapterUtils.ts
@@ -156,7 +156,7 @@ export class AdapterUtils {
 
     private static finishEventSchemaConfiguration() {
         it('Click next', () => {
-            cy.get('[data-cy=sp-connect-schema-editor]', { timeout: 10000 }).should('be.visible');
+            cy.dataCy('sp-connect-schema-editor', { timeout: 10000 }).should('be.visible');
             cy.get('#event-schema-next-button').click();
         });
     }
@@ -171,12 +171,12 @@ export class AdapterUtils {
 
     private static startAdapter(name , successElement) {
         it('Set adapter name', () => {
-            cy.get('[data-cy=sp-adapter-name]').type(name);
+            cy.dataCy('sp-adapter-name').type(name);
         });
 
         it('Start adapter', () => {
             cy.get('#button-startAdapter').click();
-            cy.get('[data-cy=' + successElement + ']', { timeout: 10000 }).should('be.visible');
+            cy.dataCy(successElement , { timeout: 10000 }).should('be.visible');
         });
 
         it('Close adapter preview', () => {
diff --git a/ui/cypress/support/utils/DataLakeUtils.ts b/ui/cypress/support/utils/DataLakeUtils.ts
index 480120e..a969cc7 100644
--- a/ui/cypress/support/utils/DataLakeUtils.ts
+++ b/ui/cypress/support/utils/DataLakeUtils.ts
@@ -18,14 +18,14 @@
 
 // tslint:disable-next-line:no-implicit-dependencies
 import * as CSV from 'csv-string';
+import { UserUtils } from './UserUtils';
 
 export class DataLakeUtils {
 
     public static checkResults(dataLakeIndex: string, fileRoute: string) {
 
         it('Validate result in datalake', () => {
-            const streamPipesUser = 'riemer@fzi.de';
-            cy.request('GET', '/streampipes-backend/api/v3/users/' + streamPipesUser + '/datalake/data/' + dataLakeIndex + '/download?format=csv',
+            cy.request('GET', '/streampipes-backend/api/v3/users/' + UserUtils.testUserName + '/datalake/data/' + dataLakeIndex + '/download?format=csv',
                 {'content-type': 'application/octet-stream'}).should((response) => {
                 const expectedResultString = response.body;
                 cy.readFile(fileRoute).then((actualResultString) => {
diff --git a/ui/cypress/support/utils/PipelineUtils.ts b/ui/cypress/support/utils/PipelineUtils.ts
index 2f2178a..5c52f07 100644
--- a/ui/cypress/support/utils/PipelineUtils.ts
+++ b/ui/cypress/support/utils/PipelineUtils.ts
@@ -59,7 +59,7 @@ export class PipelineUtils {
     private static configurePipeline(pipelineInput: PipelineInput) {
 
         it('Select processor', () => {
-            cy.get('[data-cy=sp-possible-elements-' + pipelineInput.dataSource + ']', { timeout: 10000 }).click();
+            cy.dataCy('sp-possible-elements-' + pipelineInput.dataSource, { timeout: 10000 }).click();
             cy.dataCy('sp-compatible-elements-' + pipelineInput.processingElement.name).click();
         });
 
@@ -88,8 +88,8 @@ export class PipelineUtils {
             cy.dataCy('sp-editor-pipeline-name').type(pipelineInput.pipelineName);
             cy.dataCy('sp-editor-checkbox-start-immediately').children().click();
             cy.dataCy('sp-editor-save').click();
-            cy.get('[data-cy=sp-pipeline-started-dialog]', { timeout: 10000 }).should('be.visible');
-            cy.get('[data-cy=sp-pipeline-dialog-close]', { timeout: 10000 }).click();
+            cy.dataCy('sp-pipeline-started-dialog', { timeout: 10000 }).should('be.visible');
+            cy.dataCy('sp-pipeline-dialog-close', { timeout: 10000 }).click();
         });
     }
 
@@ -99,7 +99,7 @@ export class PipelineUtils {
             cy.dataCy('delete').should('have.length', 1);
             cy.dataCy('delete').click();
             cy.dataCy('sp-pipeline-stop-and-delete').click();
-            cy.get('[data-cy=delete]', { timeout: 10000 }).should('have.length', 0);
+            cy.dataCy('delete', { timeout: 10000 }).should('have.length', 0);
         });
     }
 }
diff --git a/ui/cypress/support/general/dataCy.ts b/ui/cypress/support/utils/UserUtils.ts
similarity index 72%
copy from ui/cypress/support/general/dataCy.ts
copy to ui/cypress/support/utils/UserUtils.ts
index 0162ce3..d22a751 100644
--- a/ui/cypress/support/general/dataCy.ts
+++ b/ui/cypress/support/utils/UserUtils.ts
@@ -16,17 +16,7 @@
  *
  */
 
-declare global {
-    namespace Cypress {
-        interface Chainable {
-            /**
-             * Select cypress id's ([data-cy=...])
-             */
-            dataCy(value: string): Chainable<Element>;
-        }
-    }
+export class UserUtils {
+  public static testUserName = 'test@streampipes.apache.org';
+  public static testUserPassword = 'test1234';
 }
-
-export const dataCy = (value) => {
-    return cy.get(`[data-cy=${value}]`);
-};
diff --git a/ui/src/app/login/components/setup/setup.component.html b/ui/src/app/login/components/setup/setup.component.html
index efef941..9c6dcb7 100644
--- a/ui/src/app/login/components/setup/setup.component.html
+++ b/ui/src/app/login/components/setup/setup.component.html
@@ -74,13 +74,14 @@
                 <mat-divider></mat-divider>
                 <div fxLayout="row" fxLayoutAlign="center center">
                     <div fxLayout="row" style="margin-top: 10px; margin-bottom: 10px;">
-                        <button mat-button mat-raised-button color="primary"
+                        <button  mat-button mat-raised-button color="primary"
                                 [disabled]="!(setupForm.valid) || loading || installationFinished"
                                 (click)="configure(0)" *ngIf="!installationFinished">
                             <span>{{!installationRunning ? 'Install' : 'Installing...'}}</span>
                         </button>
                         <button mat-button mat-raised-button color="primary"
-                                (click)="openLoginPage()" *ngIf="installationFinished">
+                                (click)="openLoginPage()" *ngIf="installationFinished"
+                                data-cy="sp-button-finish-installation">
                             <mat-icon>arrow_forward</mat-icon>
                             <span>Go to login page</span>
                         </button>