Skip to content

Commit

Permalink
test: Check consecutive fingerprints consistency
Browse files Browse the repository at this point in the history
Previously, only consecutive guest CPU configs were verified.
A fingerprint contains not only guest CPU config but also host
configuration.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
  • Loading branch information
zulinx86 committed Mar 11, 2024
1 parent 3dd692b commit be59e62
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions tests/integration_tests/functional/test_cpu_template_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,37 +370,15 @@ def test_json_static_templates(cpu_template_helper, tmp_path, custom_cpu_templat
cpu_template_helper.template_verify(custom_cpu_template_path)


def test_consecutive_cpu_config_consistency(cpu_template_helper, tmp_path):
def test_consecutive_fingerprint_consistency(cpu_template_helper, tmp_path):
"""
Verify that two dumped guest CPU configs obtained consecutively are
consistent. The dumped guest CPU config should not change without
any environmental changes (firecracker, kernel, microcode updates).
Verify that two fingerprints obtained consecutively are consisttent.
"""
# Dump CPU config with the helper tool.
cpu_config_1 = tmp_path / "cpu_config_1.json"
cpu_template_helper.template_dump(cpu_config_1)
cpu_config_2 = tmp_path / "cpu_config_2.json"
cpu_template_helper.template_dump(cpu_config_2)

# Strip common entries.
cpu_template_helper.template_strip([cpu_config_1, cpu_config_2])

config_1 = json.loads(cpu_config_1.read_text(encoding="utf-8"))
config_2 = json.loads(cpu_config_2.read_text(encoding="utf-8"))

# Check the stripped result is empty.
if PLATFORM == "x86_64":
empty_cpu_config = {
"cpuid_modifiers": [],
"kvm_capabilities": [],
"msr_modifiers": [],
}
elif PLATFORM == "aarch64":
empty_cpu_config = {
"kvm_capabilities": [],
"reg_modifiers": [],
"vcpu_features": [],
}

assert config_1 == empty_cpu_config
assert config_2 == empty_cpu_config
# Dump fingerprints with the helper tool.
fingerprint_1 = tmp_path / "fingerprint_1.json"
cpu_template_helper.fingerprint_dump(fingerprint_1)
fingerprint_2 = tmp_path / "fingerprint_2.json"
cpu_template_helper.fingerprint_dump(fingerprint_2)

# Compare them.
cpu_template_helper.fingerprint_compare(fingerprint_1, fingerprint_2, None)

0 comments on commit be59e62

Please sign in to comment.