Skip to content

Commit

Permalink
First work for configurable git-location (#73)
Browse files Browse the repository at this point in the history
* First work for configurable git-location

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Check higher timeout

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Check higher timeout

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Add variables to deploy kanto component

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

---------

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>
  • Loading branch information
dennismeister93 committed May 16, 2024
1 parent 8d8e616 commit b13864a
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 7 deletions.
96 changes: 96 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,36 @@
"type": "string",
"description": "Path to the mocking configuration for the mock service",
"default": "mock.py"
},
{
"name": "mqttBrokerImage",
"type": "string",
"description": "Docker image for mqtt broker",
"default": "eclipse-mosquitto:2.0.14"
},
{
"name": "vehicleDatabrokerImage",
"type": "string",
"description": "Docker image for vehicle databroker",
"default": "ghcr.io/eclipse-kuksa/kuksa-databroker:0.4.4"
},
{
"name": "seatServiceImage",
"type": "string",
"description": "Docker image for seat service",
"default": "ghcr.io/eclipse-kuksa/kuksa-incubation/seat_service:0.4.0"
},
{
"name": "feederCanImage",
"type": "string",
"description": "Docker image for feeder can",
"default": "ghcr.io/eclipse-kuksa/kuksa-can-provider/can-provider:0.4.2"
},
{
"name": "mockServiceImage",
"type": "string",
"description": "Docker image for mock service",
"default": "ghcr.io/eclipse-kuksa/kuksa-mock-provider/mock-provider:0.4.0"
}
]
},
Expand Down Expand Up @@ -117,6 +147,36 @@
"type": "string",
"description": "Path to the mocking configuration for the mock service",
"default": "mock.py"
},
{
"name": "mqttBrokerImage",
"type": "string",
"description": "Docker image for mqtt broker",
"default": "registry.hub.docker.com/library/eclipse-mosquitto:2.0.14"
},
{
"name": "vehicleDatabrokerImage",
"type": "string",
"description": "Docker image for vehicle databroker",
"default": "ghcr.io/eclipse-kuksa/kuksa-databroker:0.4.4"
},
{
"name": "seatServiceImage",
"type": "string",
"description": "Docker image for seat service",
"default": "ghcr.io/eclipse-kuksa/kuksa-incubation/seat_service:0.4.0"
},
{
"name": "feederCanImage",
"type": "string",
"description": "Docker image for feeder can",
"default": "ghcr.io/eclipse-kuksa/kuksa-can-provider/can-provider:0.4.2"
},
{
"name": "mockServiceImage",
"type": "string",
"description": "Docker image for mock service",
"default": "ghcr.io/eclipse-kuksa/kuksa-mock-provider/mock-provider:0.4.0"
}
]
},
Expand Down Expand Up @@ -158,6 +218,36 @@
"type": "string",
"description": "Path to the mocking configuration for the mock service",
"default": "mock.py"
},
{
"name": "mqttBrokerImage",
"type": "string",
"description": "Docker image for mqtt broker",
"default": "registry.hub.docker.com/library/eclipse-mosquitto:2.0.14"
},
{
"name": "vehicleDatabrokerImage",
"type": "string",
"description": "Docker image for vehicle databroker",
"default": "ghcr.io/eclipse-kuksa/kuksa-databroker:0.4.4"
},
{
"name": "seatServiceImage",
"type": "string",
"description": "Docker image for seat service",
"default": "ghcr.io/eclipse-kuksa/kuksa-incubation/seat_service:0.4.0"
},
{
"name": "feederCanImage",
"type": "string",
"description": "Docker image for feeder can",
"default": "ghcr.io/eclipse-kuksa/kuksa-can-provider/can-provider:0.4.2"
},
{
"name": "mockServiceImage",
"type": "string",
"description": "Docker image for mock service",
"default": "ghcr.io/eclipse-kuksa/kuksa-mock-provider/mock-provider:0.4.0"
}
]
},
Expand Down Expand Up @@ -191,6 +281,12 @@
"type": "string",
"description": "Path to the file describing your custom runtime configuration.",
"default": "runtime.json"
},
{
"name": "gitLocation",
"type": "string",
"default": "https://github.com/eclipse-velocitas",
"description": "Git location of used repositories"
}
],
"onPostInit": [
Expand Down
10 changes: 5 additions & 5 deletions runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"config": [
{
"key": "image",
"value": "eclipse-mosquitto:2.0.14"
"value": "${{ mqttBrokerImage }}"
},
{
"key": "port",
Expand Down Expand Up @@ -53,7 +53,7 @@
"config": [
{
"key": "image",
"value": "ghcr.io/eclipse-kuksa/kuksa-databroker:0.4.4"
"value": "${{ vehicleDatabrokerImage }}"
},
{
"key": "port",
Expand Down Expand Up @@ -89,7 +89,7 @@
},
{
"key": "image",
"value": "ghcr.io/eclipse-kuksa/kuksa-incubation/seat_service:0.4.0"
"value": "${{ seatServiceImage }}"
},
{
"key": "port",
Expand Down Expand Up @@ -123,7 +123,7 @@
},
{
"key": "image",
"value": "ghcr.io/eclipse-kuksa/kuksa-can-provider/can-provider:0.4.2"
"value": "${{ feederCanImage }}"
},
{
"key": "env",
Expand Down Expand Up @@ -177,7 +177,7 @@
"config": [
{
"key": "image",
"value": "ghcr.io/eclipse-kuksa/kuksa-mock-provider/mock-provider:0.4.0"
"value": "${{ mockServiceImage }}"
},
{
"key": "env",
Expand Down
23 changes: 23 additions & 0 deletions runtime_kanto/src/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
get_package_path,
get_script_path,
get_workspace_dir,
require_env,
)
from yaspin.core import Yaspin

Expand Down Expand Up @@ -87,6 +88,7 @@ def adapt_feedercan_deployment_file():
encoding="utf-8",
) as f:
data = json.load(f)
data["image"]["name"] = require_env("feederCanImage")
data["mount_points"][0]["source"] = os.path.join(
get_package_path(), "config", "feedercan"
)
Expand All @@ -112,6 +114,7 @@ def adapt_mockservice_deployment_file():
if os.path.isfile(os.path.join(get_workspace_dir(), "mock.py")):
source = os.path.join(get_workspace_dir(), "mock.py")

data["image"]["name"] = require_env("mockServiceImage")
data["mount_points"][0]["source"] = source
f.seek(0)
json.dump(data, f, indent=4)
Expand All @@ -131,11 +134,30 @@ def adapt_databroker_deployment_file():
) as f:
data = json.load(f)
cache = get_cache_data()
data["image"]["name"] = require_env("vehicleDatabrokerImage")
data["mount_points"][0]["source"] = cache["vspec_file_path"]
f.seek(0)
json.dump(data, f, indent=4)


def adapt_mosquitto_deployment_file():
"""Update the databroker config with the correct mount path."""

file_path = os.path.join(get_script_path(), "deployment", "mosquitto.json")
if not os.path.isfile(file_path):
return

with open(
file_path,
"r+",
encoding="utf-8",
) as f:
data = json.load(f)
data["image"]["name"] = require_env("mqttBrokerImage")
f.seek(0)
json.dump(data, f, indent=4)


def undeploy_runtime(spinner: Yaspin, log_output: TextIOWrapper):
"""Undeploy/remove the runtime and display the progress
using the given spinner.
Expand Down Expand Up @@ -207,6 +229,7 @@ def start_kanto(spinner: Yaspin, log_output: TextIOWrapper):
adapt_feedercan_deployment_file()
adapt_mockservice_deployment_file()
adapt_databroker_deployment_file()
adapt_mosquitto_deployment_file()
log_output.write("Starting Kanto runtime\n")
kanto = subprocess.Popen(
[
Expand Down
15 changes: 13 additions & 2 deletions runtime_local/test/test_run_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
# SPDX-License-Identifier: Apache-2.0

import json
import os
import sys

Expand All @@ -24,11 +25,21 @@

@pytest.fixture()
def set_env_vars():
os.environ["runtimeFilePath"] = "./runtime.json"
manifest_file_path = os.path.join(
os.path.dirname(__file__), "..", "..", "manifest.json"
)
manifest_dict = json.load(open(manifest_file_path))
local_runtime_variables = manifest_dict["components"][0]["variables"]
os.environ["VELOCITAS_PACKAGE_DIR"] = "."
os.environ["VELOCITAS_WORKSPACE_DIR"] = "."
os.environ["VELOCITAS_CACHE_DATA"] = '{"vspec_file_path":""}'
os.environ["mockFilePath"] = "mock.py"
os.environ["runtimeFilePath"] = local_runtime_variables[0]["default"]
os.environ["mockFilePath"] = local_runtime_variables[1]["default"]
os.environ["mqttBrokerImage"] = local_runtime_variables[2]["default"]
os.environ["vehicleDatabrokerImage"] = local_runtime_variables[3]["default"]
os.environ["seatServiceImage"] = local_runtime_variables[4]["default"]
os.environ["feederCanImage"] = local_runtime_variables[5]["default"]
os.environ["mockServiceImage"] = local_runtime_variables[6]["default"]


def test_run_service__invalid_service_id__prints_available_services(
Expand Down

0 comments on commit b13864a

Please sign in to comment.