Skip to content

Commit

Permalink
Support features from EVerest/everest-framework#96 (#76)
Browse files Browse the repository at this point in the history
* Support features from EVerest/everest-framework#96

Signed-off-by: aw <aw@pionix.de>

* Adapt EverestTestController to new probe module handling

Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>

* Bump version of everest-testing

Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>

---------

Signed-off-by: aw <aw@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Co-authored-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
  • Loading branch information
a-w50 and hikinggrass authored Aug 29, 2023
1 parent c3b9b0a commit 2ac62fd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion everest-testing/src/everest/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="0.1.3"
__version__="0.1.4"
52 changes: 26 additions & 26 deletions everest-testing/src/everest/testing/core_utils/everest_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import subprocess
from pathlib import Path
import tempfile
from typing import List, TypedDict, Optional
from typing import List, Optional
import uuid
import yaml
import selectors
Expand All @@ -19,10 +19,13 @@
STARTUP_TIMEOUT = 30


class TestControlModuleConnection(TypedDict):
evse_manager_id: str
car_simulator_id: str
ocpp_id: str
class Requirement:
def __init__(self, module_id: str, implementation_id: str):
self.module_id = module_id
self.implementation_id = implementation_id


Connections = dict[str, List[Requirement]]


class StatusFifoListener:
Expand Down Expand Up @@ -122,7 +125,7 @@ def __init__(self, prefix_path: Path, config_path: Path = None) -> None:
self.everest_running = False
self.all_modules_started_event = threading.Event()

def start(self, standalone_module: Optional[str] = None, modules_to_test: List[TestControlModuleConnection] = None):
def start(self, standalone_module: Optional[str] = None, test_connections: Connections = None):
"""Starts everest-core in a subprocess
Args:
Expand All @@ -135,7 +138,7 @@ def start(self, standalone_module: Optional[str] = None, modules_to_test: List[T
logging.info(f'config: {self.everest_config_path}')

# FIXME (aw): clean up passing of modules_to_test
self.test_control_modules = modules_to_test
self.test_connections = test_connections if test_connections != None else {}
self.create_testing_user_config()

status_fifo_path = self.temp_dir / "status.fifo"
Expand Down Expand Up @@ -201,24 +204,21 @@ def create_testing_user_config(self):
"""Creates a user-config file to include the PyTestControlModule in the current SIL simulation.
If a user-config already exists, it will be re-named
"""

if len(self.test_connections) == 0:
# nothing to do here
return

file = self.everest_core_user_config_path / self.everest_config_path.name
logging.info(f"temp everest user-config: {file.resolve()}")
if self.test_control_modules:
logging.info(f"Adding test control module(s) to user-config: {self.test_control_modules}")
user_config = {"active_modules": {}}
connections = {"connector_1": [], "test_control": [], "ocpp": []}
for test_control_module in self.test_control_modules:
connections["connector_1"].append(
{"implementation_id": "evse", "module_id": test_control_module["evse_manager_id"]})
connections["test_control"].append(
{"implementation_id": "main", "module_id": test_control_module["car_simulator_id"]})
if test_control_module["ocpp_id"]:
connections["ocpp"].append(
{"implementation_id": "main", "module_id": test_control_module["ocpp_id"]})

user_config["active_modules"]["probe_module"] = {
"config_module": {"device": "auto"},
"connections": connections,
"module": "PyProbeModule"}

file.write_text(yaml.dump(user_config))

# FIXME (aw): we need some agreement, if the module id of the probe module should be fixed or not
logging.info(f'Adding test control module(s) to user-config: {self.test_control_modules}')
user_config = {'active_modules': {
'probe': {
'connections': self.test_connections,
'module': 'ProbeModule'
}
}}

file.write_text(yaml.dump(user_config))
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import datetime

from everest.testing.ocpp_utils.controller.test_controller_interface import TestController
from everest.testing.core_utils.everest_core import EverestCore, TestControlModuleConnection
from everest.testing.core_utils.everest_core import EverestCore

logging.basicConfig(level=logging.DEBUG)

Expand Down Expand Up @@ -111,12 +111,8 @@ def start(self, central_system_port=None, standalone_module=None):
f"temp ocpp user config: {self.temp_ocpp_user_config_file.name}")
logging.info(f"temp ocpp certs path: {self.temp_ocpp_certs_dir.name}")

modules_to_test = None
if standalone_module == 'probe_module':
modules_to_test = [TestControlModuleConnection(
evse_manager_id="connector_1", car_simulator_id="car_simulator", ocpp_id="ocpp")]
self.everest_core.start(
standalone_module=standalone_module, modules_to_test=modules_to_test)
standalone_module=standalone_module)
self.mqtt_external_prefix = self.everest_core.mqtt_external_prefix

mqtt_server_uri = os.environ.get("MQTT_SERVER_ADDRESS", "127.0.0.1")
Expand Down

0 comments on commit 2ac62fd

Please sign in to comment.