Skip to content

[e2e] new test cases for guest memory overhead#2640

Open
lanfon72 wants to merge 2 commits into
harvester:mainfrom
lanfon72:e2e-new
Open

[e2e] new test cases for guest memory overhead#2640
lanfon72 wants to merge 2 commits into
harvester:mainfrom
lanfon72:e2e-new

Conversation

@lanfon72
Copy link
Copy Markdown
Member

Which issue(s) this PR fixes:

Issue #1497

What this PR does / why we need it:

  • NEW API tests to test memory overhead setting
  • UPDATE test settings (drop v1.1.0 and merge existing)
  • NEW test cases to test memory overhead settings is working on VM

Special notes for your reviewer:

We documented the overhead will be 240Mi, but as I tested, it's not fixed as our documentation.
so test cases implemented to check:

  1. When using default ratio (1.5), the overhead should be >= 240 * 1.5 Mi
  2. When using double ratio (3), the overhead should be around the double value of default ratio

Additional documentation or context

ref to https://docs.harvesterhci.io/v1.6/advanced/index/#additional-guest-memory-overhead-ratio

lanfon72 added 2 commits May 13, 2026 06:50
Signed-off-by: Lanfon Fan <lanfon.fan@suse.com>
Signed-off-by: Lanfon Fan <lanfon.fan@suse.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds automated coverage for Harvester’s additional guest memory overhead ratio setting, including new API-level validation tests and an integration test that checks the setting’s effect on the VM launcher pod’s memory limit. It also updates the “expected settings” list to include newly supported settings.

Changes:

  • Added API tests for additional-guest-memory-overhead-ratio (get/update with valid/invalid values).
  • Added VM integration tests validating memory overhead behavior at default and doubled ratios.
  • Updated the expected settings set to include settings introduced in newer Harvester versions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
harvester_e2e_tests/integrations/test_3_vm_functions.py Adds a fixture and integration tests that measure VM pod memory overhead under different ratio settings.
harvester_e2e_tests/fixtures/api_client.py Updates the expected_settings fixture to include additional settings (including version-introduced ones).
harvester_e2e_tests/apis/test_settings.py Adds API tests for the new overhead ratio setting and adjusts imports accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +210 to +213
code, data = api_client.settings.get()
assert 200 == code, (code, data)

origin_val = data.get('value', "")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

code, data = api_client.settings.get(setting_name)

Comment on lines +2302 to +2304
assert overhead - overhead_ratio['_overhead'] * 2 < 1000, (
"additional-guest-memory-overhead-ratio not working as expected after set to double\n"
f"expected overhead: {overhead_ratio['_overhead']*2}, actual overhead: {overhead}"
Copy link
Copy Markdown
Contributor

@albinsun albinsun May 15, 2026

Choose a reason for hiding this comment

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

Could you help explain why overhead - overhead_ratio['_overhead'] * 2 < 1000?
Is 1000 the approximate value of twice the default overhead (240 * 1.5 * 2) ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

# from previous test case
N = memory + 1.5 ratio
`_overhead` = N - memory
# in this test case
N2 = memory + 3 ratio
`overhead` = N2 - memory

thus, overhead should be double value of _overhead, but consider the floating bytes, I use 1000 (~1KiB) to be the tolerance value.

Coplit's suggestion looks acceptable and more readable, I will run some tests to check whether we need 1MiB or lower.

Comment on lines +2286 to +2305
for i in vmi['metadata']['relationships']:
if i.get('toType') == "pod":
ns, name = i['toId'].split("/")
break
else:
raise AssertionError(
f"Unable to find the pod name of VM {vm_name}\n"
f"VMI info: {vmi}"
)

code, data = api_client.get_pods(name, ns)
assert 200 == code, (code, data)

pod_mem = int(data['spec']['containers'][0]['resources']['limits']['memory'])

overhead = pod_mem - self._mem
assert overhead - overhead_ratio['_overhead'] * 2 < 1000, (
"additional-guest-memory-overhead-ratio not working as expected after set to double\n"
f"expected overhead: {overhead_ratio['_overhead']*2}, actual overhead: {overhead}"
)
Comment thread harvester_e2e_tests/integrations/test_3_vm_functions.py
Comment thread harvester_e2e_tests/fixtures/api_client.py
Comment thread harvester_e2e_tests/apis/test_settings.py
Comment on lines +202 to +203
f"Setting {setting_name} not be updated to default value "
f"when update empty value to it, the updated value: {data['value']}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could update the message to When set empty value to {setting_name}, this setting should be set to the default value.

Comment on lines +202 to +203
f"Setting {setting_name} not be updated to default value "
f"when update empty value to it, the updated value: {data['value']}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could update the message to When set empty value to {setting_name}, this setting should be set to the default value.

assert 200 == code, (
f"Failed to update {setting_name} to value {val} with error: {code}, {data}"
)
sleep(0.1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After update, should check value by get.

code, data = api_client.settings.update(setting_name, {"value": val})
assert 422 == code, (
f"Setting {setting_name} be updated to the invalid value {val}"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check value should still original_value.

Comment on lines +210 to +213
code, data = api_client.settings.get()
assert 200 == code, (code, data)

origin_val = data.get('value', "")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

code, data = api_client.settings.get(setting_name)

@albinsun
Copy link
Copy Markdown
Contributor

btw, please attach the test report for reference.
Thank you.

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.

3 participants