Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPP E2E tests #959

Merged
merged 56 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
440c250
Initially adding ocpp integration tests into seperate testing directo…
Pietfried Nov 7, 2024
c672c2d
Install everest-testing with Python3_EXECUTABLE to respect venv
hikinggrass Nov 8, 2024
ebeeff2
Use a proper temporary directory in signed firmware downloader for si…
hikinggrass Nov 8, 2024
c4d48a5
Merge remote-tracking branch 'origin/main' into feature/ocpp-integrat…
hikinggrass Nov 11, 2024
be0da67
Update everest-utils rev to use update everest-testing
hikinggrass Nov 11, 2024
19a39f7
WIP OCPP Tests in ci
hikinggrass Nov 11, 2024
5d81f88
Depend on ci job
hikinggrass Nov 11, 2024
96b770e
Add missing run_ocpp_tests script
hikinggrass Nov 11, 2024
c251c54
Move ocpp-tests job to its own workflow depending on the build workflow
hikinggrass Nov 11, 2024
657b0a7
Get buildkit tag from earlier step
hikinggrass Nov 11, 2024
6342aa6
Move ocpp-tests job back to build_and_test workflow temporarily
hikinggrass Nov 11, 2024
7be00a8
ocpp-tests needs ci job
hikinggrass Nov 11, 2024
22c716f
Fix docker image tag input
hikinggrass Nov 11, 2024
dd409e7
Properly get tag from output
hikinggrass Nov 11, 2024
31db428
Prefix tag
hikinggrass Nov 11, 2024
9841b66
Copy scripts
hikinggrass Nov 12, 2024
b1a1580
Always download wheels
hikinggrass Nov 12, 2024
2f993d5
Added README for ocpp tests and changed directory to be specified to …
Pietfried Nov 12, 2024
025857d
Merge branch 'main' into feature/ocpp-integration-tests
Pietfried Nov 12, 2024
a7a45f7
Install requirements for ocpp integration tests
hikinggrass Nov 12, 2024
dd8f38e
Fix runs-on
hikinggrass Nov 12, 2024
2a82c2f
Fix unused imports
Pietfried Nov 12, 2024
0301363
Ran black formatter
Pietfried Nov 12, 2024
bf9b6cc
Add create_ocpp_tests_image script
hikinggrass Nov 12, 2024
3eefd2b
Install iso15118 wheel
hikinggrass Nov 12, 2024
251ce15
Fixed some codacy remarks
Pietfried Nov 12, 2024
8ef308b
Fixed path to OCPP 1.6 and 2.0.1 testsets
hikinggrass Nov 12, 2024
547cab9
Pin websockets to 13.1
hikinggrass Nov 12, 2024
307540e
Fix some codacy issues
Pietfried Nov 12, 2024
fc9b597
Fix some codacy issues
Pietfried Nov 12, 2024
a294248
Pin some more dependencies
hikinggrass Nov 12, 2024
8ea0a36
Run ocpp tests in parallel
hikinggrass Nov 12, 2024
15ad26e
Upload ocpp test result as artiface and render result
hikinggrass Nov 12, 2024
b790fcf
Merge remote-tracking branch 'origin/main' into feature/ocpp-integrat…
hikinggrass Nov 12, 2024
4a94dd6
Specify xdist max worker restart and an overall 300s timeout for ocpp…
hikinggrass Nov 12, 2024
9e6ee63
Add log output for how many ocpp tets run in parallel
hikinggrass Nov 12, 2024
ae6295a
Continue with ocpp tests result processing if run_ocpp_tests fails
hikinggrass Nov 12, 2024
caea306
Rename results for ocpp-tests to not clash with artifacts from integr…
hikinggrass Nov 12, 2024
f0b4d49
Fix conflict of artifact name
hikinggrass Nov 12, 2024
55b3597
copy configs in ocpp tests image
hikinggrass Nov 12, 2024
dc2bb38
temporarily change into everest-aux to install certs and configs
hikinggrass Nov 12, 2024
c351560
try to disable unused-import lint for block
hikinggrass Nov 13, 2024
343a550
fix codacy issues missing call import
Pietfried Nov 14, 2024
c7fc75f
Merge branch 'main' into feature/ocpp-integration-tests
Pietfried Nov 14, 2024
339258a
quotes around EXT_MOUNT to try an silence globbing warning
hikinggrass Nov 14, 2024
fc0a6b7
Move testcase description to top of function
hikinggrass Nov 14, 2024
9f7f021
Address codacy warnings
hikinggrass Nov 14, 2024
2b1a45f
Remove ocpp_tests workflow
hikinggrass Nov 14, 2024
752d281
Merge remote-tracking branch 'origin/main' into feature/ocpp-integrat…
hikinggrass Nov 14, 2024
1f5ed0b
codacy fixes
hikinggrass Nov 14, 2024
63fcdca
attempt at fixing codacy markdown issues
hikinggrass Nov 14, 2024
98ae4b4
attempt to fix codacy issues
hikinggrass Nov 15, 2024
be2190a
codacy fix
hikinggrass Nov 15, 2024
f804a48
Updated test README
Pietfried Nov 19, 2024
3121548
Bump everest-utils to 0.4.3
hikinggrass Nov 25, 2024
42d0b54
Merge branch 'main' into feature/ocpp-integration-tests
Pietfried Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .ci/build-kit/scripts/create_ocpp_tests_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

rsync -a "$EXT_MOUNT/source/tests" ./
retVal=$?

if [ $retVal -ne 0 ]; then
echo "Failed to copy tests"
exit $retVal
fi

pip install --break-system-packages \
"$EXT_MOUNT"/wheels/everestpy-*.whl \
"$EXT_MOUNT"/wheels/everest_testing-*.whl \
"$EXT_MOUNT"/wheels/iso15118-*.whl \
pytest-html
retVal=$?

if [ $retVal -ne 0 ]; then
echo "Failed to pip-install"
exit $retVal
fi

pip install --break-system-packages -r tests/ocpp_tests/requirements.txt

$(cd ./tests/ocpp_tests/test_sets/everest-aux/ && ./install_certs.sh "$EXT_MOUNT/dist" && ./install_configs.sh "$EXT_MOUNT/dist")
25 changes: 25 additions & 0 deletions .ci/e2e/scripts/run_ocpp_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

cd tests

PARALLEL_TESTS=$(nproc)

echo "Running $PARALLEL_TESTS ocpp tests in parallel"

pytest \
-rA \
-d --tx "$PARALLEL_TESTS"*popen//python=python3 \
--max-worker-restart=0 \
--timeout=300 \
--junitxml="$EXT_MOUNT/ocpp-tests-result.xml" \
--html="$EXT_MOUNT/ocpp-tests-report.html" \
--self-contained-html \
ocpp_tests/test_sets/ocpp16/*.py \
ocpp_tests/test_sets/ocpp201/*.py \
--everest-prefix "$EXT_MOUNT/dist"
retVal=$?

if [ $retVal -ne 0 ]; then
echo "OCPP tests failed with return code $retVal"
exit $retVal
fi
88 changes: 88 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,91 @@ jobs:
do_not_run_coverage_badge_creation: true
run_install_wheels: true
run_integration_tests: true
ocpp-tests:
name: OCPP Tests
needs:
- ci
runs-on: ${{ inputs.runner || 'ubuntu-22.04' }}
steps:
- name: Download dist dir
uses: actions/download-artifact@v4.1.8
with:
name: dist
- name: Extract dist.tar.gz
run: |
tar -xzf ${{ github.workspace }}/dist.tar.gz -C ${{ github.workspace }}
- name: Download wheels
# if: ${{ inputs.run_install_wheels == 'true' }}
uses: actions/download-artifact@v4.1.8
with:
name: wheels
path: wheels
- name: Checkout repository
uses: actions/checkout@v4.2.2
with:
path: source
- name: Setup run scripts
run: |
mkdir scripts
rsync -a source/.ci/build-kit/scripts/ scripts
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.BUILD_KIT_IMAGE_NAME }}
- name: Set output tag
id: buildkit_tag
shell: python3 {0}
run: |
import os
tags = "${{ steps.meta.outputs.tags }}".split(",")
if len(tags) == 0:
print("No tags found!❌")
exit(1)
tag = f"local/build-kit-everest-core:{tags[0]}"
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"tag={tag}\n")
print(f"Set tag={tag}")
- name: Download build-kit image
uses: actions/download-artifact@v4
with:
name: build-kit
- name: Load build-kit image
run: |
docker load -i build-kit.tar
docker image tag ${{ steps.buildkit_tag.outputs.tag }} build-kit
- name: Create integration-image
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name integration-container \
build-kit run-script create_ocpp_tests_image
docker commit integration-container integration-image
- name: Run OCPP tests
id: run_ocpp_tests
continue-on-error: true
run: |
docker compose \
-f source/.ci/e2e/docker-compose.yaml \
run \
e2e-test-server \
run-script run_ocpp_tests
- name: Upload result and report as artifact
continue-on-error: true
if: ${{ steps.run_ocpp_tests.outcome == 'success' || steps.run_ocpp_tests.outcome == 'failure' }}
uses: actions/upload-artifact@v4.4.3
with:
if-no-files-found: error
name: ocpp-tests-report
path: |
ocpp-tests-result.xml
ocpp-tests-report.html
- name: Render OCPP tests result
if: ${{ steps.run_ocpp_tests.outcome == 'success' || steps.run_ocpp_tests.outcome == 'failure' }}
uses: pmeier/pytest-results-action@v0.7.1
with:
path: ocpp-tests-result.xml
summary: True
display-options: fEX
fail-on-empty: True
title: Test results
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ add_custom_target(install_everest_testing
if [ -z "${CPM_PACKAGE_everest-utils_SOURCE_DIR}" ] \;
then echo "Could not determine location of everest-utils, please install everest-testing manually!" \;
else echo "Found everest-utils at ${CPM_PACKAGE_everest-utils_SOURCE_DIR}" \;
${PYTHON_EXECUTABLE} -m pip install "${CPM_PACKAGE_everest-utils_SOURCE_DIR}/everest-testing" \;
${Python3_EXECUTABLE} -m pip install -e "${CPM_PACKAGE_everest-utils_SOURCE_DIR}/everest-testing" \;
fi\;
DEPENDS
everestpy_pip_install_dist
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ext-mbedtls:
# everest-testing and ev-dev-tools
everest-utils:
git: https://github.com/EVerest/everest-utils.git
git_tag: v0.4.2
git_tag: 9c7a4928251f47ffb7f8197f6cba8596fd15d242
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to point to released version of everest-utils not a commit on a branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# unit testing
gtest:
Expand Down
14 changes: 7 additions & 7 deletions modules/System/signed_firmware_downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. "${1}"

mkdir /tmp/signature_validation
SIGNATURE_VALIDATION_DIR=$(mktemp -d /tmp/signature_validation_XXXXX)
sleep 2
echo "$DOWNLOADING"

Expand All @@ -12,11 +12,11 @@ curl_exit_code=$?
sleep 2
if [[ $curl_exit_code -eq 0 ]]; then
echo "$DOWNLOADED"
echo -e "${4}" >/tmp/signature_validation/firmware_signature.base64
echo -e "${5}" >/tmp/signature_validation/firmware_cert.pem
openssl x509 -pubkey -noout -in /tmp/signature_validation/firmware_cert.pem >/tmp/signature_validation/pubkey.pem
openssl base64 -d -in /tmp/signature_validation/firmware_signature.base64 -out /tmp/signature_validation/firmware_signature.sha256
r=$(openssl dgst -sha256 -verify /tmp/signature_validation/pubkey.pem -signature /tmp/signature_validation/firmware_signature.sha256 "${3}")
echo -e "${4}" >"$SIGNATURE_VALIDATION_DIR/firmware_signature.base64"
echo -e "${5}" >"$SIGNATURE_VALIDATION_DIR/firmware_cert.pem"
openssl x509 -pubkey -noout -in "$SIGNATURE_VALIDATION_DIR/firmware_cert.pem" >"$SIGNATURE_VALIDATION_DIR/pubkey.pem"
openssl base64 -d -in "$SIGNATURE_VALIDATION_DIR/firmware_signature.base64" -out "$SIGNATURE_VALIDATION_DIR/firmware_signature.sha256"
r=$(openssl dgst -sha256 -verify "$SIGNATURE_VALIDATION_DIR/pubkey.pem" -signature "$SIGNATURE_VALIDATION_DIR/firmware_signature.sha256" "${3}")

if [ "$r" = "Verified OK" ]; then
echo "$SIGNATURE_VERIFIED"
Expand All @@ -27,4 +27,4 @@ else
echo "$DOWNLOAD_FAILED"
fi

rm -rf /tmp/signature_validation
rm -rf "$SIGNATURE_VALIDATION_DIR"
10 changes: 10 additions & 0 deletions tests/ocpp_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build
__pycache__
*.egg-info
.pytest_cache
.venv
results.xml
result.xml
report.html
**/.DS_Store
**/.idea
61 changes: 61 additions & 0 deletions tests/ocpp_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# OCPP Integration Tests

Check notice on line 1 in tests/ocpp_tests/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/README.md#L1

Expected: [None]; Actual: # OCPP Integration Tests

This directory contains some test tooling and integration tests
for OCPP1.6 and OCPP2.0.1.

## Requirements

In order to run the integration tests, you need to have everest-core compiled
and installed on your system.

Make sure to also install the python requirements
for running the test cases using

```bash
python3 -m pip install -r requirements.txt
```

## Run the tests

You can run the integration tests using the convenience scripts
provided in this directory e.g.

```bash
./run-testing.sh
```

This command runs all test cases in parallel.
The time for running the test cases depends on your system.
It usually takes a couple of minutes.
You can check out the test results by opening the generated `results.html`.

You can choose to run the tests sequentially and/or only run subsets
for OCPP1.6 or OCPP2.0.1 using any of the other run scripts.

Alternatively, you can run individual test sets or test cases using

```bash
python3 -m pytest test_sets/ocpp201/remote_control.py \
--everest-prefix <path-to-everest-core-installation-directory> \
-k 'test_F01_F02_F03'
```

e.g.

```bash
python3 -m pytest test_sets/ocpp201/remote_control.py \
--everest-prefix ~/checkout/everest-core/build/dist \
-k 'test_F01_F02_F03'
```

This runs test case `test_F01_F02_F03`
specified in `test_sets/ocpp201/remote_control.py`.

If you run the test cases individually,
make sure to have all required certificates and configs
for the test cases installed using the
convenience scripts inside [test_sets/everest/aux](test_sets/everest-aux/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me where this everest-aux directory is. It is not in test_sets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is in tests/ocpp_tests/test_sets/everest-aux . The path was wrong ;)


```bash
./install_certs <path-to-everest-core-installation-directory>
./install_configs <path-to-everest-core-installation-directory>
Loading
Loading