Skip to content

Commit

Permalink
Feat mqtt ci test (#552)
Browse files Browse the repository at this point in the history
* refactor: test folder structure

* add integration test for MT SampleServer
  • Loading branch information
Kantiran91 authored Jul 20, 2023
1 parent 7afa11e commit ce38342
Show file tree
Hide file tree
Showing 32 changed files with 2,598 additions and 163 deletions.
3 changes: 2 additions & 1 deletion .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"consoleFull"
],
"ignore": [
"**/__snapshots__/**"
"**/__snapshots__/**",
"**/mqtt_test/schemas/**"
],
"absolute": true
}
319 changes: 165 additions & 154 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,155 +1,166 @@
---
name: Build

on:
push:
pull_request:
branches: [main, development]
merge_group:

jobs:
build-linux:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
# yamllint disable rule:line-length
run: |
#! /bin/bash
LIBCPP_VERSION="$(dpkg -s libstdc++6 | grep Version | awk '{match($0,"[0-9]+.[0-9].[0-9]",a)}END{print a[0]}')" # yamllint disable-line rule:line-length
mkdir -p build
cd build || exit
#shellcheck disable=SC2296
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" \
-DCMAKE_BUILD_TYPE="${{matrix.build_type}}" -DPAHO_WITH_SSL=1 -DBUILD_DEB_PACKAGE:BOOL=1 -DDEB_PACKAGE_LIBCPP_VERSION="$LIBCPP_VERSION"
cmake --build . -j
cd Dashboard-Client-build
make package
# yamllint enable rule:line-length
- name: Run Tests
run: |
#! /bin/bash
cd build/Dashboard-Client-build || exit
ctest -V -C "${{matrix.build_type}}"
- name: Run integration test cacert_test
run: |
#! /bin/bash
cd UmatiDashboardOpcUaClient/Tests/integration_tests/cacert_test
./genCerts.sh
cp "${{ github.workspace }}/build/Dashboard-Client-build/Tests/TestCaCertificate" .
docker-compose up -d
./evaluateTest.sh
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
- name: Upload Debian package
uses: actions/upload-artifact@v3
with:
name: dashboardopcuaclient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}.deb
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/*.deb
build-windows:
strategy:
matrix:
os: [windows-2019, windows-2022]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
shell: pwsh
# yamllint disable rule:line-length
run: |
#shellcheck disable=SC1073,SC1050,SC1141,SC1083,SC1072,SC2296
$matrixarch = "${{matrix.arch}}"
if($matrixarch -eq "386"){$arch="Win32"}
if($matrixarch -eq "amd64"){$arch="x64"}
mkdir -p build
cd build || exit
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH=${{ env.CMAKE_INSTALL_PREFIX }} -A "$arch" -DPAHO_WITH_SSL=1
cmake --build . -j --config ${{matrix.build_type}}
# yamllint enable rule:line-length
- name: Run Tests
shell: pwsh
run: |
cd build/Dashboard-Client-build || exit
ctest -V -C ${{matrix.build_type}}
- name: Download CA Certs
shell: pwsh
run: |
cd ${{ env.CMAKE_INSTALL_PREFIX }}
mkdir -p bin/certs
curl https://curl.se/ca/cacert.pem -o bin/certs/cacert.pem -s
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
docker:
runs-on: ubuntu-22.04
env:
# Check if this is not a pull request and GITHUB_TOKEN is set
# As all env variables are strings, you need to compaire against "== 'true'" (not "== true")
IS_NOT_PR: ${{ !github.head_ref && true }}
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.9.1
- name: PrepareReg Names
# yamllint disable rule:line-length
run: |
#! /bin/bash
#shellcheck disable=SC2296
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV"
# yamllint enable rule:line-length
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.2.0
if: env.IS_NOT_PR == 'true' && ${{ github.actor }} != 'dependabot'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Release
uses: docker/build-push-action@v4.1.1
with:
file: "./UmatiDashboardOpcUaClient/Dockerfile"
context: ./UmatiDashboardOpcUaClient
platforms: linux/amd64
push: ${{env.IS_NOT_PR == 'true'}}
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}
provenance: false
name: Build

on:
push:
pull_request:
branches: [main, development]
merge_group:

jobs:
build-linux:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
# yamllint disable rule:line-length
run: |
#! /bin/bash
LIBCPP_VERSION="$(dpkg -s libstdc++6 | grep Version | awk '{match($0,"[0-9]+.[0-9].[0-9]",a)}END{print a[0]}')" # yamllint disable-line rule:line-length
mkdir -p build
cd build || exit
#shellcheck disable=SC2296
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" \
-DCMAKE_BUILD_TYPE="${{matrix.build_type}}" -DPAHO_WITH_SSL=1 -DBUILD_DEB_PACKAGE:BOOL=1 -DDEB_PACKAGE_LIBCPP_VERSION="$LIBCPP_VERSION"
cmake --build . -j
cd Dashboard-Client-build
make package
# yamllint enable rule:line-length
- name: Run Tests
run: |
#! /bin/bash
cd build/Dashboard-Client-build || exit
ctest -V -C "${{matrix.build_type}}"
- name: Run integration test cacert_test
run: |
#! /bin/bash
cd UmatiDashboardOpcUaClient/Tests/integration/cacert_test || exit
./genCerts.sh
cp "${{ github.workspace }}/build/Dashboard-Client-build/Tests/unit/TestCaCertificate" .
docker-compose up -d
./evaluateTest.sh
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
- name: Upload Debian package
uses: actions/upload-artifact@v3
with:
name: dashboardopcuaclient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}.deb
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/*.deb
build-windows:
strategy:
matrix:
os: [windows-2019, windows-2022]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
shell: pwsh
# yamllint disable rule:line-length
run: |
#shellcheck disable=SC1073,SC1050,SC1141,SC1083,SC1072,SC2296
$matrixarch = "${{matrix.arch}}"
if($matrixarch -eq "386"){$arch="Win32"}
if($matrixarch -eq "amd64"){$arch="x64"}
mkdir -p build
cd build || exit
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH=${{ env.CMAKE_INSTALL_PREFIX }} -A "$arch" -DPAHO_WITH_SSL=1
cmake --build . -j --config ${{matrix.build_type}}
# yamllint enable rule:line-length
- name: Run Tests
shell: pwsh
run: |
cd build/Dashboard-Client-build || exit
ctest -V -C ${{matrix.build_type}}
- name: Download CA Certs
shell: pwsh
run: |
cd ${{ env.CMAKE_INSTALL_PREFIX }}
mkdir -p bin/certs
curl https://curl.se/ca/cacert.pem -o bin/certs/cacert.pem -s
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
docker:
runs-on: ubuntu-22.04
env:
# Check if this is not a pull request and GITHUB_TOKEN is set
# As all env variables are strings, you need to compaire against "== 'true'" (not "== true")
IS_NOT_PR: ${{ !github.head_ref && true }}
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.9.1
- name: PrepareReg Names
# yamllint disable rule:line-length
run: |
#! /bin/bash
#shellcheck disable=SC2296
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV"
# yamllint enable rule:line-length
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.2.0
if: env.IS_NOT_PR == 'true' && ${{ github.actor }} != 'dependabot'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Release
uses: docker/build-push-action@v4.1.1
with:
file: "./UmatiDashboardOpcUaClient/Dockerfile"
context: ./UmatiDashboardOpcUaClient
platforms: linux/amd64
push: ${{env.IS_NOT_PR == 'true'}}
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}
provenance: false
- name: Run integration test mqtt
if: ${{env.IS_NOT_PR == 'true'}}
run : |
#! /bin/bash
python -m pip install --upgrade pip
cd ./UmatiDashboardOpcUaClient/Tests/integration/mqtt_test || exit
pip install -r requirements.txt
docker compose up -d
./waitForContainer.sh
python -m unittest discover test_mqtt_sampleserver
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ add_subdirectory(OpcUaClient)
add_subdirectory(MachineObserver)

message("### opcua_dashboardclient: Adding test directory")
add_subdirectory(Tests)
add_subdirectory(Tests/unit)

message("### opcua_dashboardclient: Adding the executable c++ file")
find_package(Threads)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Follow these instructions to use the client as a testing tool for your implement

For the local instance testing you need to run your own MQTT Broker and a MQTT Client. See [MQTT Doc](doc/MQTT.md) for more information and instructions

[Here](example/ShowcaseDeployment/) is an docker-compose example including a mqtt broker, a umati Sample Server and the gateway. The example contains also the need configuration for the samples.

### Usage for connecting a server to the dashboard

Follow these instructions to use the client for connecting your local OPC UA Server to the umati.app Dashboard: [umati Dashboard Connection](doc/usage_for_dashboard.md)
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ce38342

Please sign in to comment.