Skip to content

Add component tests for controller logic - #81

Open
lforchini wants to merge 1 commit into
create-comptest-fixturesfrom
test/ctest-controller
Open

lforchini wants to merge 1 commit into
create-comptest-fixturesfrom
test/ctest-controller

Conversation

@lforchini

Copy link
Copy Markdown
Collaborator

Add component tests which ensure the controller enforces configured
limits such as vCPU cap and thread bounds. Also include the fixtures
necessary for these tests.

Signed-off-by: Leonardo Forchini leonardo.forchini@nutanix.com


Stack created with GitHub Stacks CLI • Give Feedback 💬

@lforchini
lforchini added this pull request to stack #83 October 1, 2026 14:37
@lforchini
lforchini force-pushed the test/ctest-controller branch from 8423944 to 5536c47 Compare October 1, 2026 14:48
@lforchini
lforchini removed this pull request from stack #83 October 1, 2026 14:50
@lforchini
lforchini added this pull request to stack #84 October 1, 2026 14:50
@lforchini
lforchini force-pushed the test/ctest-controller branch from 5536c47 to 3b44bfe Compare October 1, 2026 15:00
@lforchini
lforchini force-pushed the test/ctest-controller branch from 3b44bfe to 2c4de8d Compare October 5, 2026 08:10
@lforchini
lforchini removed this pull request from stack #84 October 5, 2026 08:12
@lforchini
lforchini force-pushed the test/ctest-controller branch from 2c4de8d to 229632d Compare October 5, 2026 08:15
@lforchini
lforchini added this pull request to stack #87 October 5, 2026 08:16
@lforchini
lforchini force-pushed the test/ctest-controller branch 2 times, most recently from 1f746b3 to 50086c5 Compare October 5, 2026 08:55
@lforchini
lforchini marked this pull request as ready for review October 5, 2026 08:55
@lforchini
lforchini force-pushed the test/ctest-controller branch from 50086c5 to f78d872 Compare October 5, 2026 09:16
@lforchini
lforchini force-pushed the test/ctest-controller branch from f78d872 to 173188f Compare October 8, 2026 07:30
@lforchini
lforchini removed this pull request from stack #87 October 8, 2026 15:22
@lforchini
lforchini force-pushed the test/ctest-controller branch from 173188f to 8aeacce Compare October 8, 2026 15:23
@lforchini
lforchini added this pull request to stack #88 October 8, 2026 15:23
@lforchini
lforchini removed this pull request from stack #88 October 13, 2026 12:32
@lforchini
lforchini force-pushed the test/ctest-controller branch from 8aeacce to 8174468 Compare October 13, 2026 12:43
@lforchini
lforchini added this pull request to stack #95 October 13, 2026 12:44
@lforchini
lforchini force-pushed the test/ctest-controller branch from 8174468 to ee20f3d Compare October 13, 2026 13:17
@lforchini
lforchini force-pushed the test/ctest-controller branch from ee20f3d to f963834 Compare October 13, 2026 13:29
@lforchini
lforchini force-pushed the test/ctest-controller branch from f963834 to 5a95063 Compare October 13, 2026 14:02
@lforchini
lforchini force-pushed the test/ctest-controller branch from 5a95063 to c10c35a Compare October 13, 2026 14:06
@lforchini
lforchini force-pushed the test/ctest-controller branch from c10c35a to e04d4bd Compare October 14, 2026 11:19
Comment thread tests/component/conftest.py Outdated
path.write_text(json.dumps(payload))


class FakeBackend:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the FakeBackend should be added with the relevant Rust code.

Comment thread tests/component/conftest.py Outdated
self.default_vm = DEFAULT_VM
self.add_vm(DEFAULT_VM)

def add_vm(self, vm_id, **fields):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document functions?

@@ -0,0 +1,180 @@
# SPDX-License-Identifier: BSD-3-Clause

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the tests should come in a separate commit.



def test_actuation_enforces_vcpu_cap(controller, fake_backend, run_threshold, fast_threshold):
"""A managed VM's pool stays within its vCPU count."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally prefer documenting a test more explicitly, e.g. "Test that foo does such and such.", no strong feeling though.

@lforchini
lforchini removed this pull request from stack #95 October 21, 2026 08:27


@pytest.fixture
def run_threshold(controller):

@tmakatos tmakatos Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be called run_controller?

Comment thread tests/component/conftest.py Outdated
CONTROLLER_INTERFACE = "com.nutanix.io_thread_controller1"
POLL_S = 0.2


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document what non-trivial functions do?

Comment thread tests/component/conftest.py Outdated
self.add_vm(DEFAULT_VM)

def add_vm(self, vm_id, **fields):
defaults = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a class instead and abstract the way it's written to disk so that it's more maintanable.

Comment thread tests/component/conftest.py Outdated
path.write_text(json.dumps(payload))


class FakeBackend:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a vague feeling that we might be able to use Python's mock for this, need to think about it.

Comment thread tests/component/conftest.py Outdated
)


class DBusServer:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document a bit what's this about?

Comment thread tests/component/conftest.py Outdated
self._proc.wait(timeout=5)


class MockProc:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread tests/component/conftest.py Outdated


class Controller:
"""Starts ``io-thread-controller`` against the fake backend."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that the real controller it starts?

@lforchini
lforchini added this pull request to stack #152 October 23, 2026 08:22
@lforchini
lforchini force-pushed the test/ctest-controller branch from e04d4bd to 3c8cc6e Compare October 23, 2026 08:24
AI-Generated: Most of it
Signed-off-by: Leonardo Forchini <leonardo.forchini@nutanix.com>
@lforchini
lforchini force-pushed the test/ctest-controller branch from 3c8cc6e to 6d16886 Compare October 23, 2026 08:39
@lforchini
lforchini removed this pull request from stack #152 October 23, 2026 08:44
@lforchini
lforchini added this pull request to stack #157 October 23, 2026 08:45
@lforchini
lforchini removed this pull request from stack #157 October 23, 2026 08:49
@lforchini
lforchini changed the base branch from test/per-test-dbus to create-comptest-fixtures October 23, 2026 08:50
@lforchini
lforchini added this pull request to stack #159 October 23, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants