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 15, 2024
1 parent b482181 commit d56f643
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 @@ -374,37 +374,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 consistent.
"""
# 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 a fingerprint with the helper tool.
fp1 = tmp_path / "fp1.json"
cpu_template_helper.fingerprint_dump(fp1)
fp2 = tmp_path / "fp2.json"
cpu_template_helper.fingerprint_dump(fp2)

# Compare them.
cpu_template_helper.fingerprint_compare(fp1, fp2, None)

0 comments on commit d56f643

Please sign in to comment.