Skip to content

Commit

Permalink
added integration test for internal hello method
Browse files Browse the repository at this point in the history
Fixes: #798

Adding an integration test that verifies the internal API
method 'Hello' works as expected.

Signed-off-by: Michael Engel <[email protected]>
  • Loading branch information
engelmi committed Mar 11, 2024
1 parent e1f81fd commit c477498
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/tests/tier0/bluechi-internal-hello/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
summary: Test internal peer dbus hello method on controller
id: eafc86bc-e69c-47a4-9ca9-907f7a6201fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

import unittest

from dasbus.connection import AddressedMessageBus

node = "node-foo"


class TestListenerAddedAsPeer(unittest.TestCase):

def test_call_internal_hello(self):

port = ""
with open("/tmp/port", "r") as f:
port = f.read().strip()
assert port is not None

# connect to controller locally
peer_bus = AddressedMessageBus(f"tcp:host=127.0.0.1,port={port}")
peer_proxy = peer_bus.get_proxy(
service_name="org.eclipse.bluechi",
object_path="/org/freedesktop/DBus",
interface_name="org.freedesktop.DBus"
)
resp = peer_proxy.Hello()
assert resp == ":1.0"


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

import os

from typing import Dict
from bluechi_test.test import BluechiTest
from bluechi_test.machine import BluechiControllerMachine, BluechiAgentMachine
from bluechi_test.config import BluechiControllerConfig

NODE_FOO = "node-foo"


def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]):

# pass port information to machine
ctrl.create_file(os.path.join("/", "tmp"), "port", ctrl.config.port)

result, output = ctrl.run_python(os.path.join("python", "call_internal_hello.py"))
if result != 0:
raise Exception(output)


def test_bluechi_internal_hello(bluechi_test: BluechiTest, bluechi_ctrl_default_config: BluechiControllerConfig):

bluechi_ctrl_default_config.allowed_node_names = [NODE_FOO]
bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config)

bluechi_test.run(exec)

0 comments on commit c477498

Please sign in to comment.