Skip to content

Commit

Permalink
Add integration test for getting the system resources of the node
Browse files Browse the repository at this point in the history
Adds an integration test that verifies if the system resources of the
node can be get successfully.

Signed-off-by: Joonyoung Shim <[email protected]>
  • Loading branch information
dofmind committed Oct 6, 2023
1 parent 3e6ddb1 commit fc130ec
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/tests/tier0/system-resources-get/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
summary: Test if the system resources of the node can be get successfully
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

import unittest

from bluechi.api import Node


class TestGetSystemResources(unittest.TestCase):

def test_get_system_resources(self):
node_foo = Node("node-foo")
system_resources = node_foo.get_system_resources()

assert len(system_resources) == 4
assert system_resources[0] > 0
assert system_resources[1] > 0
assert system_resources[2] > 0
assert system_resources[3] > 0


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

import os
import pytest
from typing import Dict

from bluechi_test.test import BluechiTest
from bluechi_test.container import BluechiControllerContainer, BluechiNodeContainer
from bluechi_test.config import BluechiControllerConfig, BluechiNodeConfig


def exec(ctrl: BluechiControllerContainer, nodes: Dict[str, BluechiNodeContainer]):
result, output = ctrl.run_python(os.path.join("python", "get_system_resources.py"))
if result != 0:
raise Exception(output)


@pytest.mark.timeout(40)
def test_system_resources_get(
bluechi_test: BluechiTest,
bluechi_ctrl_default_config: BluechiControllerConfig,
bluechi_node_default_config: BluechiNodeConfig):

bluechi_node_default_config.node_name = "node-foo"
bluechi_ctrl_default_config.allowed_node_names = [bluechi_node_default_config.node_name]

bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config)
bluechi_test.add_bluechi_node_config(bluechi_node_default_config)

bluechi_test.run(exec)

0 comments on commit fc130ec

Please sign in to comment.