-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added integration test for internal hello method
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
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
31 changes: 31 additions & 0 deletions
31
tests/tests/tier0/bluechi-internal-hello/python/call_internal_hello.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
28 changes: 28 additions & 0 deletions
28
tests/tests/tier0/bluechi-internal-hello/test_bluechi_internal_hello.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |