-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An integration test is to verify if default configuration of controller disables periodic heartbeat of the controller, and the other is to verify if the node gets disconnected when did not receive heartbeat since threshold from node. Signed-off-by: Joonyoung Shim <[email protected]>
- Loading branch information
Showing
7 changed files
with
139 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
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,3 @@ | ||
summary: Test if default configuration of controller disables periodic heartbeat of | ||
the controller | ||
id: a04517f6-8be1-468b-8dc0-f9674690f73f |
27 changes: 27 additions & 0 deletions
27
tests/tests/tier0/bluechi-heartbeat-disabled/python/is_node_connected.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,27 @@ | ||
# | ||
# Copyright Contributors to the Eclipse BlueChi project | ||
# | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import time | ||
import unittest | ||
|
||
from bluechi.api import Node | ||
|
||
|
||
class TestNodeIsConnected(unittest.TestCase): | ||
def test_node_is_connected(self): | ||
n = Node("node-foo") | ||
assert n.status == "online" | ||
|
||
timestamp = n.last_seen_timestamp | ||
|
||
# verify that the node remains connected and LastSeenTimespamp is not | ||
# updated after more than NodeHeartbeatThreshold seconds have elapsed | ||
time.sleep(10) | ||
assert n.status == "online" | ||
assert n.last_seen_timestamp == timestamp | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
36 changes: 36 additions & 0 deletions
36
tests/tests/tier0/bluechi-heartbeat-disabled/test_bluechi_heartbeat_disabled.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,36 @@ | ||
# | ||
# Copyright Contributors to the Eclipse BlueChi project | ||
# | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import os | ||
from typing import Dict | ||
|
||
from bluechi_test.config import BluechiAgentConfig, BluechiControllerConfig | ||
from bluechi_test.machine import BluechiAgentMachine, BluechiControllerMachine | ||
from bluechi_test.test import BluechiTest | ||
|
||
node_foo_name = "node-foo" | ||
|
||
|
||
def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]): | ||
result, output = ctrl.run_python(os.path.join("python", "is_node_connected.py")) | ||
if result != 0: | ||
raise Exception(output) | ||
|
||
|
||
def test_bluechi_heartbeat_disabled( | ||
bluechi_test: BluechiTest, | ||
bluechi_ctrl_default_config: BluechiControllerConfig, | ||
bluechi_node_default_config: BluechiAgentConfig, | ||
): | ||
|
||
bluechi_ctrl_default_config.allowed_node_names = [node_foo_name] | ||
|
||
bluechi_node_default_config.node_name = node_foo_name | ||
bluechi_node_default_config.heartbeat_interval = "0" | ||
|
||
bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config) | ||
bluechi_test.add_bluechi_agent_config(bluechi_node_default_config) | ||
|
||
bluechi_test.run(exec) |
3 changes: 3 additions & 0 deletions
3
tests/tests/tier0/bluechi-heartbeat-node-disconnected/main.fmf
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,3 @@ | ||
summary: Test if the node gets disconnected when did not receive heartbeat since | ||
threshold from node | ||
id: 0b087ba3-25fc-46b0-9c01-31bc2edf5209 |
27 changes: 27 additions & 0 deletions
27
tests/tests/tier0/bluechi-heartbeat-node-disconnected/python/is_node_disconnected.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,27 @@ | ||
# | ||
# Copyright Contributors to the Eclipse BlueChi project | ||
# | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import time | ||
import unittest | ||
|
||
from bluechi.api import Node | ||
|
||
|
||
class TestNodeIsDisconnected(unittest.TestCase): | ||
def test_node_is_disconnected(self): | ||
n = Node("node-foo") | ||
assert n.status == "online" | ||
|
||
timestamp = n.last_seen_timestamp | ||
|
||
# verify that the node is disconnected and LastSeenTimespamp is not | ||
# updated after more than NodeHeartbeatThreshold seconds have elapsed | ||
time.sleep(10) | ||
assert n.status == "offline" | ||
assert n.last_seen_timestamp == timestamp | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
37 changes: 37 additions & 0 deletions
37
...sts/tier0/bluechi-heartbeat-node-disconnected/test_bluechi_heartbeat_node_disconnected.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,37 @@ | ||
# | ||
# Copyright Contributors to the Eclipse BlueChi project | ||
# | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import os | ||
from typing import Dict | ||
|
||
from bluechi_test.config import BluechiAgentConfig, BluechiControllerConfig | ||
from bluechi_test.machine import BluechiAgentMachine, BluechiControllerMachine | ||
from bluechi_test.test import BluechiTest | ||
|
||
node_foo_name = "node-foo" | ||
|
||
|
||
def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]): | ||
result, output = ctrl.run_python(os.path.join("python", "is_node_disconnected.py")) | ||
if result != 0: | ||
raise Exception(output) | ||
|
||
|
||
def test_bluechi_heartbeat_node_disconnected( | ||
bluechi_test: BluechiTest, | ||
bluechi_ctrl_default_config: BluechiControllerConfig, | ||
bluechi_node_default_config: BluechiAgentConfig, | ||
): | ||
|
||
bluechi_ctrl_default_config.allowed_node_names = [node_foo_name] | ||
bluechi_ctrl_default_config.heartbeat_interval = "2000" | ||
|
||
bluechi_node_default_config.node_name = node_foo_name | ||
bluechi_node_default_config.heartbeat_interval = "0" | ||
|
||
bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config) | ||
bluechi_test.add_bluechi_agent_config(bluechi_node_default_config) | ||
|
||
bluechi_test.run(exec) |