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/08/11 20:12:52 UTC

[incubator-streampipes] branch STREAMPIPES-319 updated (ea2f6ef -> 6354270)

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

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


    from ea2f6ef  Merge branch 'STREAMPIPES-319' of github.com:apache/incubator-streampipes into STREAMPIPES-319
     new d2041a5  [STREAMPIPES-404] Add REST endpoint to reset StreamPipes instance
     new 4b1dab4  [STREAMPIPES-404] Add functionality to reset streampipes before each e2e test
     new 6354270  [STREAMPIPES-404] Update all tests to reset system in before

The 3 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:
 .../backend/StreamPipesResourceConfig.java         |  3 +-
 .../container/master/general/ResetManagement.java  | 78 ++++++++++++++++++++++
 streampipes-pipeline-management/pom.xml            |  1 -
 .../streampipes/manager/file/FileManager.java      | 20 ++++++
 streampipes-rest/pom.xml                           |  5 ++
 .../streampipes/rest/impl/PipelineElementFile.java | 14 +---
 ...eElementRuntimeInfo.java => ResetResource.java} | 36 +++++-----
 ui/cypress/support/general/InitStreamPipesTest.ts  | 47 +++++++++++++
 .../cypress/support/general/resetStreamPipes.ts    | 17 +++--
 ui/cypress/support/index.ts                        |  4 ++
 ui/cypress/support/utils/AdapterUtils.ts           |  4 --
 ui/cypress/support/utils/PipelineUtils.ts          |  2 -
 .../support/utils/ProcessingElementTestUtils.ts    |  5 --
 ui/cypress/tests/adapter/fileStream.ts             | 12 ++--
 ui/cypress/tests/adapter/machineDataSimulator.ts   |  7 ++
 .../adapter/randomDataSimulatorStream.spec.ts      |  6 ++
 .../tests/fileManagement/testFileManagement.ts     | 18 ++---
 ui/cypress/tests/installation/installation.ts      |  4 +-
 ui/cypress/tests/pipeline/pipelineTest.ts          |  7 +-
 .../tests/pipelineElement/AllPipelineElements.ts   | 10 +--
 .../tests/pipelineElement/SinglePipelineElement.ts |  9 +--
 21 files changed, 228 insertions(+), 81 deletions(-)
 create mode 100644 streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/general/ResetManagement.java
 copy streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/{PipelineElementRuntimeInfo.java => ResetResource.java} (57%)
 create mode 100644 ui/cypress/support/general/InitStreamPipesTest.ts
 copy streampipes-connect-api/src/main/java/org/apache/streampipes/connect/api/exception/ParseException.java => ui/cypress/support/general/resetStreamPipes.ts (72%)

[incubator-streampipes] 03/03: [STREAMPIPES-404] Update all tests to reset system in before

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

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

commit 6354270408981ebe023abc63ae689f5e9af6ecc8
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Aug 11 22:11:30 2021 +0200

    [STREAMPIPES-404] Update all tests to reset system in before
---
 ui/cypress/support/utils/ProcessingElementTestUtils.ts |  5 -----
 ui/cypress/tests/adapter/fileStream.ts                 |  9 +++++----
 ui/cypress/tests/adapter/machineDataSimulator.ts       |  7 +++++++
 .../tests/adapter/randomDataSimulatorStream.spec.ts    |  6 ++++++
 ui/cypress/tests/fileManagement/testFileManagement.ts  | 18 +++++++-----------
 ui/cypress/tests/installation/installation.ts          |  4 +++-
 ui/cypress/tests/pipeline/pipelineTest.ts              |  1 -
 .../tests/pipelineElement/AllPipelineElements.ts       | 10 ++++++----
 .../tests/pipelineElement/SinglePipelineElement.ts     |  9 +++++----
 9 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/ui/cypress/support/utils/ProcessingElementTestUtils.ts b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
index 29d1b4f..c549e43 100644
--- a/ui/cypress/support/utils/ProcessingElementTestUtils.ts
+++ b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
@@ -80,10 +80,5 @@ export class ProcessingElementTestUtils {
 
         DataLakeUtils.checkResults(dataLakeIndex, 'cypress/fixtures/' + expectedResultFile);
 
-        // PipelineUtils.deletePipeline();
-
-        // AdapterUtils.deleteAdapter();
-
-        // FileManagementUtils.deleteFile();
     }
 }
diff --git a/ui/cypress/tests/adapter/fileStream.ts b/ui/cypress/tests/adapter/fileStream.ts
index f320cdd..ea56758 100644
--- a/ui/cypress/tests/adapter/fileStream.ts
+++ b/ui/cypress/tests/adapter/fileStream.ts
@@ -20,14 +20,15 @@ import { AdapterUtils } from '../../support/utils/AdapterUtils';
 import { FileManagementUtils } from '../../support/utils/FileManagementUtils';
 import { GenericAdapterBuilder } from '../../support/builder/GenericAdapterBuilder';
 
-describe('Test File Stream Adapter', () => {
-
-    it('Login', () => {
-        cy.login();
+before('Setup Test', () => {
+    it('Initialize Test', () => {
+        cy.initStreamPipesTest();
     });
 
     FileManagementUtils.addFile('fileTest/random.csv');
+});
 
+describe('Test File Stream Adapter', () => {
     const adapterInput = GenericAdapterBuilder
         .create('File_Stream')
         .setName('File Stream Adapter Test')
diff --git a/ui/cypress/tests/adapter/machineDataSimulator.ts b/ui/cypress/tests/adapter/machineDataSimulator.ts
index 7b7c07f..2add7dd 100644
--- a/ui/cypress/tests/adapter/machineDataSimulator.ts
+++ b/ui/cypress/tests/adapter/machineDataSimulator.ts
@@ -18,6 +18,13 @@
 
 import { AdapterUtils } from '../../support/utils/AdapterUtils';
 import { SpecificAdapterBuilder } from '../../support/builder/SpecificAdapterBuilder';
+import { FileManagementUtils } from '../../support/utils/FileManagementUtils';
+
+before('Setup Test', () => {
+    it('Initialize Test', () => {
+        cy.initStreamPipesTest();
+    });
+});
 
 describe('Test Random Data Simulator Stream Adapter', () => {
     const adapterInput = SpecificAdapterBuilder
diff --git a/ui/cypress/tests/adapter/randomDataSimulatorStream.spec.ts b/ui/cypress/tests/adapter/randomDataSimulatorStream.spec.ts
index 5f85aa2..8489023 100644
--- a/ui/cypress/tests/adapter/randomDataSimulatorStream.spec.ts
+++ b/ui/cypress/tests/adapter/randomDataSimulatorStream.spec.ts
@@ -19,6 +19,12 @@
 import { AdapterUtils } from '../../support/utils/AdapterUtils';
 import { SpecificAdapterBuilder } from '../../support/builder/SpecificAdapterBuilder';
 
+before('Setup Test', () => {
+    it('Initialize Test', () => {
+        cy.initStreamPipesTest();
+    });
+});
+
 describe('Test Random Data Simulator Stream Adapter', () => {
 
     const adapterInput = SpecificAdapterBuilder
diff --git a/ui/cypress/tests/fileManagement/testFileManagement.ts b/ui/cypress/tests/fileManagement/testFileManagement.ts
index 49ec9c0..b726ae8 100644
--- a/ui/cypress/tests/fileManagement/testFileManagement.ts
+++ b/ui/cypress/tests/fileManagement/testFileManagement.ts
@@ -18,17 +18,13 @@
 
 import { FileManagementUtils } from '../../support/utils/FileManagementUtils';
 
-describe('Test File Management', () => {
-    it('Login', () => {
-        cy.login();
-    });
-
-    FileManagementUtils.addFile('fileTest/test.csv')
-
-    FileManagementUtils.deleteFile()
-
-    it('Logout', () => {
-        cy.logout();
+before('Setup Test', () => {
+    it('Initialize Test', () => {
+        cy.initStreamPipesTest();
     });
+});
 
+describe('Test File Management', () => {
+    FileManagementUtils.addFile('fileTest/test.csv');
+    FileManagementUtils.deleteFile();
 });
diff --git a/ui/cypress/tests/installation/installation.ts b/ui/cypress/tests/installation/installation.ts
index e5781d6..b162489 100644
--- a/ui/cypress/tests/installation/installation.ts
+++ b/ui/cypress/tests/installation/installation.ts
@@ -18,11 +18,13 @@
 
 import { UserUtils } from '../../support/utils/UserUtils';
 
-describe('Install StreamPipes', () => {
+before('Setup Test', () => {
   it('Open Streampipes', () => {
     cy.visit('#/login');
   });
+});
 
+describe('Install StreamPipes', () => {
   let isSetupPage: boolean;
 
   it('Install StreamPipes', () => {
diff --git a/ui/cypress/tests/pipeline/pipelineTest.ts b/ui/cypress/tests/pipeline/pipelineTest.ts
index 6e73cd4..19cb63c 100644
--- a/ui/cypress/tests/pipeline/pipelineTest.ts
+++ b/ui/cypress/tests/pipeline/pipelineTest.ts
@@ -32,7 +32,6 @@ before('Setup Test', () => {
 });
 
 describe('Test Random Data Simulator Stream Adapter', () => {
-
  const pipelineInput = PipelineBuilder.create('Pipeline Test')
     .addSource(adapterName)
     .addProcessingElement(
diff --git a/ui/cypress/tests/pipelineElement/AllPipelineElements.ts b/ui/cypress/tests/pipelineElement/AllPipelineElements.ts
index ca85e1b..20472a5 100644
--- a/ui/cypress/tests/pipelineElement/AllPipelineElements.ts
+++ b/ui/cypress/tests/pipelineElement/AllPipelineElements.ts
@@ -18,16 +18,18 @@
 
 import { ProcessingElementTestUtils } from '../../support/utils/ProcessingElementTestUtils';
 import { ProcessorTest } from '../../support/model/ProcessorTest';
+import { AdapterUtils } from '../../support/utils/AdapterUtils';
 
 const allTests = Cypress.env('processingElements');
 
 allTests.forEach(test => {
-  describe('Test Processor ' + test['name'], () => {
-
-    it('Login', () => {
-      cy.login();
+  before('Setup Test', () => {
+    it('Initialize Test', () => {
+      cy.initStreamPipesTest();
     });
+  });
 
+  describe('Test Processor ' + test['name'], () => {
     const processorTest = test as ProcessorTest;
 
     ProcessingElementTestUtils.testElement(processorTest);
diff --git a/ui/cypress/tests/pipelineElement/SinglePipelineElement.ts b/ui/cypress/tests/pipelineElement/SinglePipelineElement.ts
index 06f7c73..7769e7b 100644
--- a/ui/cypress/tests/pipelineElement/SinglePipelineElement.ts
+++ b/ui/cypress/tests/pipelineElement/SinglePipelineElement.ts
@@ -27,12 +27,13 @@ allTests.forEach(test => {
   const processorTest = test as ProcessorTest;
 
   if (processorTest.name === testName) {
-    describe('Test Processor ' + test.dir, () => {
-
-      it('Login', () => {
-        cy.login();
+    before('Setup Test', () => {
+      it('Initialize Test', () => {
+        cy.initStreamPipesTest();
       });
+    });
 
+    describe('Test Processor ' + test.dir, () => {
       ProcessingElementTestUtils.testElement(processorTest);
     });
   }

[incubator-streampipes] 01/03: [STREAMPIPES-404] Add REST endpoint to reset StreamPipes instance

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

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

commit d2041a57476eaeb3831ec50200132a2b2fcc5ca5
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Aug 11 21:49:28 2021 +0200

    [STREAMPIPES-404] Add REST endpoint to reset StreamPipes instance
---
 .../backend/StreamPipesResourceConfig.java         |  3 +-
 .../container/master/general/ResetManagement.java  | 78 ++++++++++++++++++++++
 streampipes-pipeline-management/pom.xml            |  1 -
 .../streampipes/manager/file/FileManager.java      | 20 ++++++
 streampipes-rest/pom.xml                           |  5 ++
 .../streampipes/rest/impl/PipelineElementFile.java | 14 +---
 .../streampipes/rest/impl/ResetResource.java       | 50 ++++++++++++++
 7 files changed, 156 insertions(+), 15 deletions(-)

diff --git a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
index e99ea98..a429102 100644
--- a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
+++ b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
@@ -62,6 +62,7 @@ public class StreamPipesResourceConfig extends ResourceConfig {
         register(DataLakeNoUserResourceV3.class);
         register(DataStream.class);
         register(Deployment.class);
+        register(ExtensionsServiceEndpointResource.class);
         register(FileServingResource.class);
         register(InternalPipelineTemplates.class);
         register(LabelResource.class);
@@ -85,11 +86,11 @@ public class StreamPipesResourceConfig extends ResourceConfig {
         register(PipelineNoUserResource.class);
         register(PipelineTemplate.class);
         register(PipelineResource.class);
-        register(ExtensionsServiceEndpointResource.class);
         register(SemanticEventConsumer.class);
         register(SemanticEventProcessingAgent.class);
         register(SemanticEventProducer.class);
         register(Setup.class);
+        register(ResetResource.class);
         register(User.class);
         register(Version.class);
         register(PipelineElementAsset.class);
diff --git a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/general/ResetManagement.java b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/general/ResetManagement.java
new file mode 100644
index 0000000..f994fce
--- /dev/null
+++ b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/general/ResetManagement.java
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.streampipes.connect.container.master.general;
+
+import org.apache.streampipes.connect.api.exception.AdapterException;
+import org.apache.streampipes.connect.container.master.management.AdapterMasterManagement;
+import org.apache.streampipes.manager.file.FileManager;
+import org.apache.streampipes.manager.pipeline.PipelineManager;
+import org.apache.streampipes.model.client.file.FileMetadata;
+import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.model.pipeline.Pipeline;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class ResetManagement {
+    // This class should be moved into another package. I moved it here because I got a cyclic maven
+    // dependency between this package and streampipes-pipeline-management
+    // See in issue [STREAMPIPES-405]
+
+    private static final Logger logger = LoggerFactory.getLogger(ResetManagement.class);
+
+    /**
+     * Remove all configurations for this user. This includes [pipelines, adapters, files]
+     * @param username
+     */
+    public static void reset(String username) {
+        logger.info("Start resetting the system");
+
+        // Stop and delete all pipelines
+        List<Pipeline> allPipelines = PipelineManager.getOwnPipelines(username);
+        allPipelines.forEach(pipeline -> {
+            PipelineManager.stopPipeline(pipeline.getPipelineId(), true);
+            PipelineManager.deletePipeline(pipeline.getPipelineId());
+        });
+
+        // Stop and delete all adapters
+        AdapterMasterManagement adapterMasterManagement = new AdapterMasterManagement();
+
+        try {
+            List<AdapterDescription> allAdapters = adapterMasterManagement.getAllAdapters();
+            allAdapters.forEach(adapterDescription -> {
+                try {
+                    adapterMasterManagement.deleteAdapter(adapterDescription.getId());
+                } catch (AdapterException e) {
+                    logger.error("Failed to delete adapter with id: " + adapterDescription.getAdapterId(), e);
+                }
+            });
+        } catch (AdapterException e) {
+            logger.error("Failed to load all adapter descriptions", e);
+        }
+
+        // Stop and delete all files
+        List<FileMetadata> allFiles = FileManager.getAllFiles();
+        allFiles.forEach(fileMetadata -> {
+            FileManager.deleteFile(fileMetadata.getFileId());
+        });
+
+        logger.info("Resetting the system was completed");
+    }
+}
diff --git a/streampipes-pipeline-management/pom.xml b/streampipes-pipeline-management/pom.xml
index 8b0568f..0f90493 100644
--- a/streampipes-pipeline-management/pom.xml
+++ b/streampipes-pipeline-management/pom.xml
@@ -112,7 +112,6 @@
             <artifactId>streampipes-user-management</artifactId>
             <version>0.69.0-SNAPSHOT</version>
         </dependency>
-
         <!-- External dependencies -->
         <dependency>
             <groupId>org.apache.maven.shared</groupId>
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
index 7c794b8..86e979b 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
@@ -26,10 +26,22 @@ import org.apache.streampipes.storage.management.StorageDispatcher;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
 import java.util.UUID;
+import java.util.stream.Collectors;
 
 public class FileManager {
 
+  public static List<FileMetadata> getAllFiles() {
+      return getAllFiles(null);
+  }
+
+  public static List<FileMetadata> getAllFiles(String filetypes) {
+    List<FileMetadata> allFiles = getFileMetadataStorage().getAllFileMetadataDescriptions();
+    return filetypes != null ? filterFiletypes(allFiles, filetypes) : allFiles;
+  }
+
   /**
    * Store a file in the internal file storage.
    * For csv files the bom is removed
@@ -108,4 +120,12 @@ public class FileManager {
     return UUID.randomUUID().toString() + "." + filetype;
   }
 
+  private static List<FileMetadata> filterFiletypes(List<FileMetadata> allFiles, String filetypes) {
+    return allFiles
+            .stream()
+            .filter(fileMetadata -> Arrays
+                    .stream(filetypes.split(","))
+                    .anyMatch(ft -> ft.equals(fileMetadata.getFiletype())))
+            .collect(Collectors.toList());
+  }
 }
diff --git a/streampipes-rest/pom.xml b/streampipes-rest/pom.xml
index 4b6c8fb..0b2bb05 100644
--- a/streampipes-rest/pom.xml
+++ b/streampipes-rest/pom.xml
@@ -90,6 +90,11 @@
             <artifactId>streampipes-user-management</artifactId>
             <version>0.69.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.streampipes</groupId>
+            <artifactId>streampipes-connect-container-master</artifactId>
+            <version>0.69.0-SNAPSHOT</version>
+        </dependency>
 
         <!-- External dependencies -->
         <dependency>
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
index bd36e42..4a30550 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
@@ -26,9 +26,6 @@ import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
 
 @Path("/v2/users/{username}/files")
 public class PipelineElementFile extends AbstractRestResource {
@@ -56,17 +53,8 @@ public class PipelineElementFile extends AbstractRestResource {
   @GET
   @Produces(MediaType.APPLICATION_JSON)
   public Response getFileInfo(@QueryParam("filetypes") String filetypes) {
-    List<FileMetadata> allFiles = getFileMetadataStorage().getAllFileMetadataDescriptions();
-    return filetypes != null ? ok(filterFiletypes(allFiles, filetypes)) : ok(allFiles);
+    return ok(FileManager.getAllFiles(filetypes));
   }
 
-  private List<FileMetadata> filterFiletypes(List<FileMetadata> allFiles, String filetypes) {
-    return allFiles
-            .stream()
-            .filter(fileMetadata -> Arrays
-                    .stream(filetypes.split(","))
-                    .anyMatch(ft -> ft.equals(fileMetadata.getFiletype())))
-            .collect(Collectors.toList());
-  }
 
 }
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ResetResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ResetResource.java
new file mode 100644
index 0000000..cfd629c
--- /dev/null
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ResetResource.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.streampipes.rest.impl;
+
+import io.swagger.v3.oas.annotations.Operation;
+import org.apache.streampipes.connect.container.master.general.ResetManagement;
+import org.apache.streampipes.model.message.Notifications;
+import org.apache.streampipes.model.message.SuccessMessage;
+import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("/v2/users/{username}/reset")
+public class ResetResource extends AbstractAuthGuardedRestResource {
+    private static final Logger logger = LoggerFactory.getLogger(ResetResource.class);
+
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    @JacksonSerialized
+    @Operation(summary = "Resets StreamPipes instance")
+    public Response reset(@PathParam("username") String username) {
+        ResetManagement.reset(username);
+        SuccessMessage message = Notifications.success("Reset of system successfully performed");
+        return ok(message);
+    }
+
+}

[incubator-streampipes] 02/03: [STREAMPIPES-404] Add functionality to reset streampipes before each e2e test

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

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

commit 4b1dab4a14dcd5a21f26178e643e9bff8ff8aa86
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Aug 11 21:58:57 2021 +0200

    [STREAMPIPES-404] Add functionality to reset streampipes before each e2e
    test
---
 ui/cypress/support/general/InitStreamPipesTest.ts  | 47 ++++++++++++++++++++++
 .../{index.ts => general/resetStreamPipes.ts}      | 22 +++++-----
 ui/cypress/support/index.ts                        |  4 ++
 ui/cypress/support/utils/AdapterUtils.ts           |  4 --
 ui/cypress/support/utils/PipelineUtils.ts          |  2 -
 .../support/utils/ProcessingElementTestUtils.ts    |  6 +--
 ui/cypress/tests/adapter/fileStream.ts             |  3 +-
 ui/cypress/tests/pipeline/pipelineTest.ts          |  6 +--
 8 files changed, 68 insertions(+), 26 deletions(-)

diff --git a/ui/cypress/support/general/InitStreamPipesTest.ts b/ui/cypress/support/general/InitStreamPipesTest.ts
new file mode 100644
index 0000000..5b7ccf4
--- /dev/null
+++ b/ui/cypress/support/general/InitStreamPipesTest.ts
@@ -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.
+ *
+ */
+/*
+ * 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.
+ *
+ */
+
+declare global {
+  namespace Cypress {
+    interface Chainable {
+      initStreamPipesTest: typeof initStreamPipesTest;
+    }
+  }
+}
+
+export const initStreamPipesTest = () => {
+  cy.login();
+  cy.resetStreamPipes();
+};
diff --git a/ui/cypress/support/index.ts b/ui/cypress/support/general/resetStreamPipes.ts
similarity index 67%
copy from ui/cypress/support/index.ts
copy to ui/cypress/support/general/resetStreamPipes.ts
index 60f803f..13d4e84 100644
--- a/ui/cypress/support/index.ts
+++ b/ui/cypress/support/general/resetStreamPipes.ts
@@ -16,16 +16,16 @@
  *
  */
 
-import { login } from './general/login';
-import { logout } from './general/logout';
-import { dataCy } from './general/dataCy';
-// tslint:disable-next-line:no-implicit-dependencies
-import 'cypress-file-upload';
-
-// General commands
-Cypress.Commands.add('login', login);
-Cypress.Commands.add('logout', logout);
-Cypress.Commands.add('dataCy', dataCy);
-// Cypress.Commands.add('readDir', readDir);
+import { UserUtils } from '../utils/UserUtils';
 
+declare global {
+  namespace Cypress {
+    interface Chainable {
+      resetStreamPipes: typeof resetStreamPipes;
+    }
+  }
+}
 
+export const resetStreamPipes = () => {
+  cy.request('POST', `/streampipes-backend/api/v2/users/${UserUtils.testUserName}/reset`, {});
+};
diff --git a/ui/cypress/support/index.ts b/ui/cypress/support/index.ts
index 60f803f..a0009f0 100644
--- a/ui/cypress/support/index.ts
+++ b/ui/cypress/support/index.ts
@@ -21,11 +21,15 @@ import { logout } from './general/logout';
 import { dataCy } from './general/dataCy';
 // tslint:disable-next-line:no-implicit-dependencies
 import 'cypress-file-upload';
+import { resetStreamPipes } from './general/resetStreamPipes';
+import { initStreamPipesTest } from './general/InitStreamPipesTest';
 
 // General commands
 Cypress.Commands.add('login', login);
 Cypress.Commands.add('logout', logout);
 Cypress.Commands.add('dataCy', dataCy);
+Cypress.Commands.add('resetStreamPipes', resetStreamPipes);
+Cypress.Commands.add('initStreamPipesTest', initStreamPipesTest);
 // Cypress.Commands.add('readDir', readDir);
 
 
diff --git a/ui/cypress/support/utils/AdapterUtils.ts b/ui/cypress/support/utils/AdapterUtils.ts
index 56f68c8..b29dd55 100644
--- a/ui/cypress/support/utils/AdapterUtils.ts
+++ b/ui/cypress/support/utils/AdapterUtils.ts
@@ -36,16 +36,12 @@ export class AdapterUtils {
 
         AdapterUtils.startStreamAdapter(adapterConfiguration.adapterName);
 
-        AdapterUtils.deleteAdapter();
-
     }
 
     public static testGenericStreamAdapter(adapterConfiguration: GenericAdapterInput) {
 
         AdapterUtils.addGenericStreamAdapter(adapterConfiguration);
 
-        AdapterUtils.deleteAdapter();
-
     }
 
 
diff --git a/ui/cypress/support/utils/PipelineUtils.ts b/ui/cypress/support/utils/PipelineUtils.ts
index f1b2a72..d8aa243 100644
--- a/ui/cypress/support/utils/PipelineUtils.ts
+++ b/ui/cypress/support/utils/PipelineUtils.ts
@@ -25,8 +25,6 @@ export class PipelineUtils {
 
         PipelineUtils.addPipeline(pipelineInput);
 
-        PipelineUtils.deletePipeline();
-
     }
 
     public static addPipeline(pipelineInput: PipelineInput) {
diff --git a/ui/cypress/support/utils/ProcessingElementTestUtils.ts b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
index f600ac3..29d1b4f 100644
--- a/ui/cypress/support/utils/ProcessingElementTestUtils.ts
+++ b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
@@ -80,10 +80,10 @@ export class ProcessingElementTestUtils {
 
         DataLakeUtils.checkResults(dataLakeIndex, 'cypress/fixtures/' + expectedResultFile);
 
-        PipelineUtils.deletePipeline();
+        // PipelineUtils.deletePipeline();
 
-        AdapterUtils.deleteAdapter();
+        // AdapterUtils.deleteAdapter();
 
-        FileManagementUtils.deleteFile();
+        // FileManagementUtils.deleteFile();
     }
 }
diff --git a/ui/cypress/tests/adapter/fileStream.ts b/ui/cypress/tests/adapter/fileStream.ts
index 03f809b..f320cdd 100644
--- a/ui/cypress/tests/adapter/fileStream.ts
+++ b/ui/cypress/tests/adapter/fileStream.ts
@@ -41,5 +41,4 @@ describe('Test File Stream Adapter', () => {
 
     AdapterUtils.testGenericStreamAdapter(adapterInput);
 
-    FileManagementUtils.deleteFile();
-});
\ No newline at end of file
+});
diff --git a/ui/cypress/tests/pipeline/pipelineTest.ts b/ui/cypress/tests/pipeline/pipelineTest.ts
index 630012a..6e73cd4 100644
--- a/ui/cypress/tests/pipeline/pipelineTest.ts
+++ b/ui/cypress/tests/pipeline/pipelineTest.ts
@@ -24,8 +24,8 @@ import { PipelineBuilder } from '../../support/builder/PipelineBuilder';
 const adapterName = 'simulator';
 
 before('Setup Test', () => {
-  it('Login', () => {
-    cy.login();
+  it('Initialize Test', () => {
+    cy.initStreamPipesTest();
   });
 
   AdapterUtils.addMachineDataSimulator(adapterName);
@@ -47,7 +47,5 @@ describe('Test Random Data Simulator Stream Adapter', () => {
     .build();
 
   PipelineUtils.testPipeline(pipelineInput);
-
-  AdapterUtils.deleteAdapter();
 });