Skip to content

Commit

Permalink
Merge branch 'main' into feature/PN7160TokenProv-extLib
Browse files Browse the repository at this point in the history
Signed-off-by: cburandt <[email protected]>
  • Loading branch information
cburandt authored Nov 27, 2024
2 parents 6ef9963 + 8828e4b commit a425768
Show file tree
Hide file tree
Showing 181 changed files with 28,461 additions and 525 deletions.
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
91 changes: 91 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,94 @@ 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/[email protected]
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/[email protected]
with:
name: wheels
path: wheels
- name: Checkout repository
uses: actions/[email protected]
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/[email protected]
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/[email protected]
with:
path: ocpp-tests-result.xml
summary: True
display-options: fEX
fail-on-empty: True
title: Test results
- name: Check if OCPP tests failed
if: ${{ steps.run_ocpp_tests.outcome == 'failure' }}
run: exit 1
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,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: 2 additions & 0 deletions config/config-sil-ocpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ active_modules:
config_module:
connector_id: 1
evse_id: "1"
connector_type: "cType2"
session_logging: true
session_logging_xml: false
session_logging_path: /tmp/everest-logs
Expand Down Expand Up @@ -55,6 +56,7 @@ active_modules:
config_module:
connector_id: 2
evse_id: "2"
connector_type: "cType2"
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
Expand Down
3 changes: 3 additions & 0 deletions config/config-sil-ocpp201-pnc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ active_modules:
implementation_id: external_limits
- module_id: evse_manager_2_ocpp_sink
implementation_id: external_limits
reservation:
- module_id: auth
implementation_id: reservation
evse_security:
module: EvseSecurity
config_module:
Expand Down
8 changes: 8 additions & 0 deletions config/config-sil-ocpp201.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ active_modules:
config_module:
connector_id: 1
evse_id: "1"
connector_type: "cType2"
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
Expand Down Expand Up @@ -49,6 +50,7 @@ active_modules:
config_module:
connector_id: 2
evse_id: "2"
connector_type: "cType2"
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
Expand Down Expand Up @@ -142,6 +144,9 @@ active_modules:
implementation_id: external_limits
- module_id: evse_manager_2_ocpp_sink
implementation_id: external_limits
reservation:
- module_id: auth
implementation_id: reservation
persistent_store:
module: PersistentStore
evse_security:
Expand Down Expand Up @@ -169,6 +174,9 @@ active_modules:
implementation_id: evse
- module_id: evse_manager_2
implementation_id: evse
kvs:
- module_id: persistent_store
implementation_id: main
energy_manager:
module: EnergyManager
connections:
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ libevse-security:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: v0.20.0
git_tag: 9836ac4766e99a79555adb15c3001c8704f8b7a7
cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP"
# Josev
Josev:
Expand Down
36 changes: 25 additions & 11 deletions interfaces/reservation.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
description: Interface for reservations
cmds:
reserve_now:
description: Reserves this evse.
description: Reserves an evse.
arguments:
connector_id:
description: >-
The id of the connector to be reserved. A value of 0 means that
the reservation is not for a specific connector
type: integer
reservation:
description: The information about the Reservation to be placed
request:
type: object
$ref: /reservation#/Reservation
description: Requests to make a reservation
result:
description: >-
Returns Accepted if reservation was succesfull or specifies error
code.
Returns Accepted if reservation was succesful or specifies error code.
type: string
$ref: /reservation#/ReservationResult
cancel_reservation:
Expand All @@ -29,4 +23,24 @@ cmds:
Returns true if reservation was cancelled. Returns false if there
was no reservation to cancel.
type: boolean
vars: {}
exists_reservation:
description: >-
Checks if there is a reservation made for the given connector and token. Will also return true if there
is a reservation with this token for evse id 0.
arguments:
request:
type: object
$ref: /reservation#/ReservationCheck
description: >-
The information to send for the check if there is a reservation on the given connector for the given token.
result:
description: >-
Returns an enum which indicates the reservation status of the given id / id token / group id token combination.
type: string
$ref: /reservation#/ReservationCheckStatus
vars:
reservation_update:
description: >-
Update of the reservation.
type: object
$ref: /reservation#/ReservationUpdateStatus
18 changes: 18 additions & 0 deletions lib/staging/ocpp/ocpp_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,22 @@ ocpp::DateTime to_ocpp_datetime_or_now(const std::string& datetime_string) {
}
return ocpp::DateTime();
}

ocpp::ReservationCheckStatus
to_ocpp_reservation_check_status(const types::reservation::ReservationCheckStatus& status) {
switch (status) {
case types::reservation::ReservationCheckStatus::NotReserved:
return ocpp::ReservationCheckStatus::NotReserved;
case types::reservation::ReservationCheckStatus::ReservedForToken:
return ocpp::ReservationCheckStatus::ReservedForToken;
case types::reservation::ReservationCheckStatus::ReservedForOtherToken:
return ocpp::ReservationCheckStatus::ReservedForOtherToken;
case types::reservation::ReservationCheckStatus::ReservedForOtherTokenAndHasParentToken:
return ocpp::ReservationCheckStatus::ReservedForOtherTokenAndHasParentToken;
}

EVLOG_warning << "Could not convert reservation check status. Returning default 'NotReserved.";
return ocpp::ReservationCheckStatus::NotReserved;
}

} // namespace ocpp_conversions
3 changes: 3 additions & 0 deletions lib/staging/ocpp/ocpp_conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <generated/types/display_message.hpp>
#include <generated/types/money.hpp>
#include <generated/types/reservation.hpp>
#include <generated/types/session_cost.hpp>
#include <ocpp/common/types.hpp>
#include <ocpp/v201/ocpp_enums.hpp>
Expand Down Expand Up @@ -49,4 +50,6 @@ types::session_cost::SessionCost create_session_cost(const ocpp::RunningCost& ru
/// current datetime
ocpp::DateTime to_ocpp_datetime_or_now(const std::string& datetime_string);

ocpp::ReservationCheckStatus to_ocpp_reservation_check_status(const types::reservation::ReservationCheckStatus& status);

}; // namespace ocpp_conversions
Loading

0 comments on commit a425768

Please sign in to comment.