This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit c380f5d5d51cd9106b3bd687f665ba163447642f Author: Philipp Zehnder <[email protected]> AuthorDate: Mon Jan 3 08:26:59 2022 +0100 [STREAMPIPES-492] Provide test for archetypes --- ui/.gitignore | 2 + .../tests/experimental/testJvmArchetype/.env | 20 +++ .../testJvmArchetype/armDockerFile/Dockerfile | 25 +++ .../experimental/testJvmArchetype/backend/.env | 20 +++ .../testJvmArchetype/backend/docker-compose.yml | 51 +++++++ .../testJvmArchetype/docker-compose.yml | 167 +++++++++++++++++++++ .../experimental/testJvmArchetype/testArchetype.sh | 29 ++++ .../testJvmArchetype/testJvmArchetype.ts | 63 ++++++++ 8 files changed, 377 insertions(+) diff --git a/ui/.gitignore b/ui/.gitignore index fe19d16..757a0d6 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -37,6 +37,8 @@ ui/src/assets/img/sp/logo-navigation.png # dependencies /node_modules + + # IDEs and editors /.idea .project diff --git a/ui/cypress/tests/experimental/testJvmArchetype/.env b/ui/cypress/tests/experimental/testJvmArchetype/.env new file mode 100644 index 0000000..6aacc5e --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/.env @@ -0,0 +1,20 @@ +# 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. + +SP_VERSION=0.69.0-SNAPSHOT +SP_DOCKER_REGISTRY=apachestreampipes +SP_SUBNET=172.31.0.0/16 +SP_CONSUL_CONTAINER_IP=172.31.0.9 +COMPOSE_PROJECT_NAME=streampipes diff --git a/ui/cypress/tests/experimental/testJvmArchetype/armDockerFile/Dockerfile b/ui/cypress/tests/experimental/testJvmArchetype/armDockerFile/Dockerfile new file mode 100644 index 0000000..abe2a24 --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/armDockerFile/Dockerfile @@ -0,0 +1,25 @@ +# 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. + +ARG BASE_IMAGE=arm32v7/openjdk:11-jre-slim +FROM $BASE_IMAGE + +ENV CONSUL_LOCATION consul + +EXPOSE 8090 + +COPY ../../../../../../../delme/automated-test/target/automated-test.jar /streampipes-extensions-service.jar + +ENTRYPOINT ["java", "-jar", "/streampipes-extensions-service.jar"] diff --git a/ui/cypress/tests/experimental/testJvmArchetype/backend/.env b/ui/cypress/tests/experimental/testJvmArchetype/backend/.env new file mode 100644 index 0000000..6aacc5e --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/backend/.env @@ -0,0 +1,20 @@ +# 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. + +SP_VERSION=0.69.0-SNAPSHOT +SP_DOCKER_REGISTRY=apachestreampipes +SP_SUBNET=172.31.0.0/16 +SP_CONSUL_CONTAINER_IP=172.31.0.9 +COMPOSE_PROJECT_NAME=streampipes diff --git a/ui/cypress/tests/experimental/testJvmArchetype/backend/docker-compose.yml b/ui/cypress/tests/experimental/testJvmArchetype/backend/docker-compose.yml new file mode 100644 index 0000000..104d19e --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/backend/docker-compose.yml @@ -0,0 +1,51 @@ +# 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. +version: "3.4" + +# global logging +x-logging: + &default-logging + options: + max-size: '12m' + max-file: '5' + driver: json-file + +services: + + # StreamPipes services + backend: + image: "${SP_DOCKER_REGISTRY}/backend:${SP_VERSION}" + volumes: + - backend:/root/.streampipes + - files:/spImages + logging: *default-logging + restart: unless-stopped + networks: + spnet: + +volumes: + backend: + files: + +networks: + spnet: + driver: bridge + ipam: + config: + - subnet: ${SP_SUBNET} diff --git a/ui/cypress/tests/experimental/testJvmArchetype/docker-compose.yml b/ui/cypress/tests/experimental/testJvmArchetype/docker-compose.yml new file mode 100644 index 0000000..f8a53f2 --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/docker-compose.yml @@ -0,0 +1,167 @@ +# 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. +version: "3.4" + +# global logging +x-logging: + &default-logging + options: + max-size: '12m' + max-file: '5' + driver: json-file + +services: + + ui: + image: "${SP_DOCKER_REGISTRY}/ui:${SP_VERSION}" + ports: + - "80:80" + depends_on: + - couchdb + - activemq + - consul + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + # Mandatory external services + activemq: + image: fogsyio/activemq:5.15.9 + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + consul: + image: fogsyio/consul:1.9.6 + environment: + - "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}" + - "CONSUL_BIND_INTERFACE=eth0" + - "CONSUL_HTTP_ADDR=0.0.0.0" + entrypoint: + - consul + - agent + - -server + - -bootstrap-expect=1 + - -data-dir=/consul/data + - -node=consul-one + - -bind={{ GetInterfaceIP "eth0" }} + - -client=0.0.0.0 + - -enable-script-checks=true + - -ui + volumes: + - consul:/consul/data + logging: *default-logging + restart: unless-stopped + networks: + spnet: + ipv4_address: ${SP_CONSUL_CONTAINER_IP} + + couchdb: + image: couchdb:2.3.1 + volumes: + - couchdb:/opt/couchdb/data + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + kafka: + image: fogsyio/kafka:2.2.0 + hostname: kafka + depends_on: + - zookeeper + environment: + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://:9092 + KAFKA_LISTENERS: PLAINTEXT://:9092 + KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT + KAFKA_ADVERTISED_HOST_NAME: kafka + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_MESSAGE_MAX_BYTES: 5000012 + KAFKA_FETCH_MESSAGE_MAX_BYTES: 5000012 + KAFKA_REPLICA_FETCH_MAX_BYTES: 10000000 + volumes: + - kafka:/kafka + - /var/run/docker.sock:/var/run/docker.sock + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + zookeeper: + image: fogsyio/zookeeper:3.4.13 + volumes: + - zookeeper:/opt/zookeeper-3.4.13 + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + influxdb: + image: fogsyio/influxdb:1.7 + environment: + - INFLUXDB_DATA_ENGINE=tsm1 + - INFLUXDB_REPORTING_DISABLED=false + - INFLUXDB_ADMIN_ENABLED=true + volumes: + - influxdb:/var/lib/influxdb + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + # Lite version pipeline elements + extensions-all-jvm: + image: "${SP_DOCKER_REGISTRY}/extensions-all-jvm:${SP_VERSION}" + depends_on: + - consul + volumes: + - files:/spImages + logging: *default-logging + restart: unless-stopped + networks: + spnet: + + maven-archetype-jvm-extensions: + image: maven-archetype-jvm-extensions + #build: + # context: ./automated-test + # dockerfile: Dockerfile + logging: *default-logging + networks: + spnet: + + +volumes: + consul: + connect: + couchdb: + kafka: + zookeeper: + influxdb: + files: + + +networks: + spnet: + driver: bridge + ipam: + config: + - subnet: ${SP_SUBNET} diff --git a/ui/cypress/tests/experimental/testJvmArchetype/testArchetype.sh b/ui/cypress/tests/experimental/testJvmArchetype/testArchetype.sh new file mode 100755 index 0000000..82ea8bc --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/testArchetype.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +mvn archetype:generate -DarchetypeGroupId=org.apache.streampipes \ + -DarchetypeArtifactId=streampipes-archetype-extensions-jvm -DarchetypeVersion=0.69.0-SNAPSHOT \ + -DgroupId=org.streampipes.test -DartifactId=automated-test -DclassNamePrefix=AutomatedTest -DpackageName=test -DinteractiveMode=false + +cd automated-test +mvn clean package + +cd .. +docker-compose build +docker-compose up -d +sleep 30 + +cd backend +docker-compose up -d +sleep 30 + +cd ../../../../../ +ls +npx cypress run --spec 'cypress/tests/experimental/testJvmArchetype/testJvmArchetype.ts' +ls +cd cypress/tests/experimental/testJvmArchetype/backend/ +docker-compose down -v + +cd .. +docker-compose down -v + +rm -r automated-test diff --git a/ui/cypress/tests/experimental/testJvmArchetype/testJvmArchetype.ts b/ui/cypress/tests/experimental/testJvmArchetype/testJvmArchetype.ts new file mode 100644 index 0000000..8f0c6d6 --- /dev/null +++ b/ui/cypress/tests/experimental/testJvmArchetype/testJvmArchetype.ts @@ -0,0 +1,63 @@ +/* + * 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. + * + */ + +import { ConnectUtils } from '../../../support/utils/ConnectUtils'; +import { PipelineUtils } from '../../../support/utils/PipelineUtils'; +import { PipelineElementBuilder } from '../../../support/builder/PipelineElementBuilder'; +import { PipelineBuilder } from '../../../support/builder/PipelineBuilder'; +import { DashboardUtils } from '../../../support/utils/DashboardUtils'; + +const adapterName = 'simulator'; + + +describe('Prepare StreamPipes for archetype test', () => { + beforeEach('Setup Test', () => { + cy.initStreamPipesTest(); + ConnectUtils.addMachineDataSimulator(adapterName); + }); + + it('Perform Test', () => { + const pipelineName = 'ValidateArchetypePipeline'; + + const pipelineInput = PipelineBuilder.create(pipelineName) + .addSource(adapterName) + .addProcessingElement( + PipelineElementBuilder.create('automatedtestprocessor') + .addInput('input', 'example-key', 'newField') + .build()) + .addSink( + PipelineElementBuilder.create('dashboard_sink') + .addInput('input', 'visualization-name', 'Demo') + .build()) + .build(); + + PipelineUtils.testPipeline(pipelineInput); + + DashboardUtils.goToDashboard(); + + // Add new dashboard + const dashboardName = 'testDashboard'; + DashboardUtils.addAndEditDashboard(dashboardName); + + DashboardUtils.addWidget(pipelineName, 'raw'); + + // Validate that data is coming (at least 3 events) + DashboardUtils.validateRawWidgetEvents(3); + }); +}); +
