diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000000..5b2912bd838 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,13 @@ +# GXF github workflows +## build.yml +Responsible for building docker containers as artifacts and running cucumber tests. + +### Run build.yml for testing +To run build.yml for testing you need to add a label to your PR containing the text cucumber_testing. You can add a label by opening your PR in the github interface and clicking labels in the right side bar according to https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/managing-labels. +Afterwards you can remove the label again. + +### Error logs on cucumber test timeout +If cucumber tests time out error logs are generated and uploaded as artifacts. + +## Editing properties for devops +If you need to edit the configuration for OPS purposes, this can be done in the gxf-gitops repository under platform/config.yaml -- global properties. \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1ca902b75b..7429d39f5df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: ./mvnw -T1C -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=gxf -Dsonar.projectKey=OSGP_open-smart-grid-platform ${{ steps.maven_options.outputs.maven_options }} - name: Staging war and jar files - run: mkdir staging && find . -path ./staging -prune -o \( -name gxf -o -name cucumber-*-test-jar-with-dependencies.jar -o -name *simulator*.war \) -exec cp -prv --parents '{}' staging/ \; + run: mkdir staging && find . -path ./staging -prune -o \( -name gxf -o -name cucumber-*-test-jar-with-dependencies.jar -o -name *simulator*.war -o -name *osgp-secret* -o -name *dlms-device-simulator-starter*.jar \) -exec cp -prv --parents '{}' staging/ \; if: contains(github.ref, 'release') || contains(github.ref, 'development') || contains(github.event.pull_request.labels.*.name, 'build_containers') || contains(github.event.pull_request.labels.*.name, 'cucumber_testing') - uses: actions/upload-artifact@v4 if: contains(github.ref, 'release') || contains(github.ref, 'development') || contains(github.event.pull_request.labels.*.name, 'build_containers') || contains(github.event.pull_request.labels.*.name, 'cucumber_testing') @@ -91,6 +91,16 @@ jobs: context: ./osgp/platform/osgp-adapter-ws-smartmetering/ - image: ghcr.io/osgp/osgp-adapter-ws-tariffswitching context: ./osgp/platform/osgp-adapter-ws-tariffswitching/ + - image: ghcr.io/osgp/osgp-secret-management + context: ./osgp/platform/osgp-secret-management + - image: ghcr.io/osgp/osgp-throttling-service + context: ./osgp/platform/osgp-throttling-service + - image: ghcr.io/osgp/osgp-protocol-adapter-dlms + context: ./osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms + - image: ghcr.io/osgp/osgp-simulator-dlms-triggered + context: ./osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered + - image: ghcr.io/osgp/dlms-device-simulator-starter + context: ./osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/simulator/dlms-device-simulator-starter - image: ghcr.io/osgp/osgp-protocol-adapter-iec60870 context: ./osgp/protocol-adapter-iec60870/osgp-protocol-adapter-iec60870 - image: ghcr.io/osgp/osgp-protocol-simulator-iec60870 @@ -164,21 +174,58 @@ jobs: permissions: checks: write strategy: + fail-fast: false matrix: - values_file: [ci/common-values.yaml, ci/publiclighting-values.yaml] + values_file: [ci/common-values.yaml, ci/publiclighting-values.yaml, ci/smartmetering-values.yaml] steps: - name: Checkout gxf-gitops uses: actions/checkout@v4 with: repository: 'OSGP/gxf-gitops' + ref: 'feature/FDP-3056-smhe-cucumber-containers' + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Setup k3d cluster run: bash setup.sh - name: Create gxf platform - run: ./charts/gxf-platform/template-apply.sh --imageTag $(echo -e "${{ needs.docker.outputs.tags }}" | head -n 1 | cut -d':' -f2) + run: ./charts/gxf-platform/template-apply.sh --imageTag $(echo -e "${{ needs.docker.outputs.tags }}" | head -n 1 | cut -d':' -f2) --valuesFile ${{ matrix.values_file }} - name: Create and run gxf cucumber tests run: ./charts/gxf-cucumber-tests/template-apply.sh --imageTag $(echo -e "${{ needs.docker.outputs.tags }}" | head -n 1 | cut -d':' -f2) --valuesFile ${{ matrix.values_file }} - name: Wait for jobs to finish - run: kubectl wait --for=condition=complete --all jobs --timeout=30m + id: cucumber_job + continue-on-error: true + run: | + if ! kubectl wait --for=condition=complete --all jobs --timeout=30m; then + echo "::error::Kubectl timed out..." + echo "status=ERROR" >> $GITHUB_OUTPUT + valuesfile=$(basename ${{ matrix.values_file }} .yaml) + echo "logname=${valuesfile%%-*}" >> $GITHUB_OUTPUT + kubectl get events --all-namespaces --sort-by='.metadata.creationTimestamp' &> kube_events.log + for pod in $(kubectl get pod --field-selector=status.phase==Running -o name); do + echo "::debug:: Created logs for pod $pod" + kubectl logs $pod --all-containers=true &> $(basename $pod).log + done + kubectl get pods &> kube_status.log + exit 1 + fi; + echo "status=SUCCES" >> $GITHUB_OUTPUT + - name: Upload error logs + uses: actions/upload-artifact@v4 + with: + name: kube_${{ steps.cucumber_job.outputs.logname }}_error_logs + path: ./*.log + if-no-files-found: ignore + overwrite: true + - name: Fail on error + run: | + if [ ${{ steps.cucumber_job.outputs.status }} = "ERROR" ]; + then + exit 1; + fi - name: Run maven cucumber reporting run: mvn -f charts/gxf-cucumber-tests/pom.xml verify - name: Annotate cucumber report to github action diff --git a/osgp/platform/osgp-secret-management/Dockerfile b/osgp/platform/osgp-secret-management/Dockerfile new file mode 100644 index 00000000000..90c9f41234c --- /dev/null +++ b/osgp/platform/osgp-secret-management/Dockerfile @@ -0,0 +1,20 @@ +FROM tomcat:10.1-jre17-temurin-noble + +RUN rm -rf /usr/local/tomcat/webapps.dist + +# Enable the use of system environment variables in Tomcat configuration files. +RUN echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" >> /usr/local/tomcat/conf/catalina.properties + +RUN mkdir -p /var/log/osp && \ + rm -rf /usr/local/tomcat/webapps/* && \ + chmod 755 /usr/local/tomcat/webapps /var/log/osp && \ + mkdir -p /usr/local/tomcat/webapps/probe/ && \ + touch /usr/local/tomcat/webapps/probe/probe.txt + +WORKDIR /opt/app + +COPY target/osgp-secret-management-*exec.jar osgp-secret-management-exec.jar + +ENV SERVER_PORT=8443 + +CMD java -Djava.security.properties=/opt/app/java.security --module-path /opt/nfast/java/classes -jar osgp-secret-management-exec.jar diff --git a/osgp/platform/osgp-throttling-service/Dockerfile b/osgp/platform/osgp-throttling-service/Dockerfile new file mode 100644 index 00000000000..43126cd629a --- /dev/null +++ b/osgp/platform/osgp-throttling-service/Dockerfile @@ -0,0 +1,14 @@ +FROM tomcat:10.1-jre17-temurin-noble + +RUN rm -rf /usr/local/tomcat/webapps.dist + +# Enable the use of system environment variables in Tomcat configuration files. +RUN echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" >> /usr/local/tomcat/conf/catalina.properties + +RUN mkdir -p /var/log/osp && \ + rm -rf /usr/local/tomcat/webapps/* && \ + chmod 755 /usr/local/tomcat/webapps /var/log/osp && \ + mkdir -p /usr/local/tomcat/webapps/probe/ && \ + touch /usr/local/tomcat/webapps/probe/probe.txt + +COPY target/gxf /usr/local/tomcat/webapps/ diff --git a/osgp/platform/osgp-throttling-service/pom.xml b/osgp/platform/osgp-throttling-service/pom.xml index 5ac4e7a0a1c..9ee6e6bb6a9 100644 --- a/osgp/platform/osgp-throttling-service/pom.xml +++ b/osgp/platform/osgp-throttling-service/pom.xml @@ -39,6 +39,7 @@ SPDX-License-Identifier: Apache-2.0 maven-war-plugin ${maven.war.plugin.version} + ${project.build.directory}/gxf/${project.artifactId} true diff --git a/osgp/platform/osgp-throttling-service/src/main/resources/osgp-throttling-service.properties b/osgp/platform/osgp-throttling-service/src/main/resources/osgp-throttling-service.properties index 7db3feb61d4..b3e20a8e9f1 100644 --- a/osgp/platform/osgp-throttling-service/src/main/resources/osgp-throttling-service.properties +++ b/osgp/platform/osgp-throttling-service/src/main/resources/osgp-throttling-service.properties @@ -1,6 +1,6 @@ # Datasource Configuration spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/osgp_throttling +spring.datasource.url=jdbc:postgresql://localhost:5432/osgp_throttling spring.datasource.username=osp_admin spring.datasource.password=1234 # JPA / Hibernate Configuration diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/Dockerfile b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/Dockerfile new file mode 100644 index 00000000000..df76f68320f --- /dev/null +++ b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/Dockerfile @@ -0,0 +1,16 @@ +FROM tomcat:10.1-jre17-temurin-noble + +RUN rm -rf /usr/local/tomcat/webapps.dist + +# Enable the use of system environment variables in Tomcat configuration files. +RUN echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" >> /usr/local/tomcat/conf/catalina.properties + +RUN mkdir -p /var/log/osp && \ + rm -rf /usr/local/tomcat/webapps/* && \ + chmod 755 /usr/local/tomcat/webapps /var/log/osp && \ + mkdir -p /usr/local/tomcat/webapps/probe/ && \ + touch /usr/local/tomcat/webapps/probe/probe.txt + +RUN apt-get update && apt-get install iputils-ping -y && rm -rf /var/lib/apt/lists/* + +COPY target/gxf /usr/local/tomcat/webapps/ diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml index 1ec916f8dfc..9e57cb25290 100644 --- a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml +++ b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml @@ -39,6 +39,7 @@ SPDX-License-Identifier: Apache-2.0 maven-war-plugin ${maven.war.plugin.version} + ${project.build.directory}/gxf/${project.artifactId} true false diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/Dockerfile b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/Dockerfile new file mode 100644 index 00000000000..97adbab802b --- /dev/null +++ b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/Dockerfile @@ -0,0 +1,16 @@ +FROM tomcat:10.1-jre17-temurin-noble + +RUN rm -rf /usr/local/tomcat/webapps.dist + +# Enable the use of system environment variables in Tomcat configuration files. +RUN echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" >> /usr/local/tomcat/conf/catalina.properties + +RUN mkdir -p /var/log/osp && \ + rm -rf /usr/local/tomcat/webapps/* && \ + chmod 755 /usr/local/tomcat/webapps /var/log/osp && \ + mkdir -p /usr/local/tomcat/webapps/probe/ && \ + touch /usr/local/tomcat/webapps/probe/probe.txt + +COPY context.xml /usr/local/tomcat/conf + +COPY target/gxf /usr/local/tomcat/webapps/ diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/context.xml b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/context.xml new file mode 100644 index 00000000000..d6b425d0384 --- /dev/null +++ b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/context.xml @@ -0,0 +1,39 @@ + + + + + + + WEB-INF/web.xml + + + + + + + + + + + + + + \ No newline at end of file diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/pom.xml b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/pom.xml index bc518b3e753..c4e32bde065 100644 --- a/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/pom.xml +++ b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/osgp-simulator-dlms-triggered/pom.xml @@ -57,6 +57,8 @@ SPDX-License-Identifier: Apache-2.0 maven-war-plugin ${maven.war.plugin.version} + ${project.build.directory}/gxf/${project.artifactId} + true false gif diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/simulator/dlms-device-simulator-starter/Dockerfile b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/simulator/dlms-device-simulator-starter/Dockerfile new file mode 100644 index 00000000000..3bbd96fcd20 --- /dev/null +++ b/osgp/protocol-adapter-dlms/osgp-protocol-simulator-dlms/simulator/dlms-device-simulator-starter/Dockerfile @@ -0,0 +1,7 @@ +FROM amazoncorretto:17-alpine-jdk + +RUN apk add --update coreutils tzdata && rm -rf /var/cache/apk/* + +COPY target/dlms-device-simulator-starter*.jar /app/dlms-device-simulator-starter.jar + +ENTRYPOINT ["java", "-jar", "/app/dlms-device-simulator-starter.jar", "/config/simulators.json", "start"]