Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVM: Add boot/reboot tests #3624

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

trungams
Copy link
Member

@trungams trungams commented Feb 3, 2025

  • Tools: add tpm2 tool to support reading PCR values from the TPM
  • Tests: add boot tests for Azure Linux CVM:
    • verify_encrypted_root_partition: sanity check that the root partition on an Azure Linux CVM is encrypted when deployed with DiskWithVMGuestState encryption setting.
    • verify_boot_success_after_component_upgrade: check that a CVM can reboot after a boot component is upgraded.
  • Core: add a new function to directly query package version using distro's package manager, rather than using regex to parse package info output.

@trungams trungams marked this pull request as draft February 3, 2025 03:43
tpm2-tools is used to interact with a TPM device

Signed-off-by: Thien Trung Vuong <[email protected]>
Signed-off-by: Thien Trung Vuong <[email protected]>
@trungams trungams force-pushed the tvuong/azl-cvm-boot-test branch from 39b6e6c to b900463 Compare February 4, 2025 07:46
@trungams trungams marked this pull request as ready for review February 4, 2025 07:58
@trungams
Copy link
Member Author

trungams commented Feb 4, 2025

@LiliDeng @squirrelsc - This PR is ready to review. Could you help me review it when you have time? Thank you.

The query_package addition - if you are not certain about it, I can split it into another PR.

@LiliDeng
Copy link
Collaborator

LiliDeng commented Feb 4, 2025

could you provide the full cvm mariner image name? like this format: microsoftcblmariner azure-linux-3 azure-linux-3-gen2 latest

# - Make sure VM boots up again
reboot_tool = node.tools[Reboot]
reboot_tool.reboot_and_check_panic(log_path)
is_ready, tcp_error_code = wait_tcp_port_ready(
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't need to wait for ready in the test case. When you call next command, LISA will do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean the wait_tcp_port_ready call can be removed? I was mostly following the pattern in smoke_test and a boot test defined in microsoft/testsuites/core/boot.py

component is upgraded.

Steps:
1. On first boot, check current PCR values for PCR4 and PCR7
Copy link
Member

Choose a reason for hiding this comment

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

Add requirements on new environment, if it's needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have defined requirement for this test case below (CvmEnabled, AZURE). Does this suffice?


# - PCR4 should change if any of the boot components is upgraded
# - PCR7 may change if a signing cert is changed
if boot_component_changed:
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to make sure all paths tested in the same test case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this logic already covers what we want to test for CVM booting, at least for Azure Linux. If you're referring to merging the 2 test cases defined in this file, I think it's possible. If that's preferred then I'll update my code

@@ -119,6 +119,12 @@ class KernelInformation:
version_parts: List[str]


@dataclass
class PackageInformation:
Copy link
Member

Choose a reason for hiding this comment

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

Please modify existing get_package_information, make it compatible with any version format.

  1. Create a class called LisaVersionInfo, which inherits from VersionInfo, so all existing cases should continue to pass.
  2. Provide the raw_version field, so it can pass with non-semver.
  3. Rewrite parse_version to return the new class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Also refactored some related functions a bit. I'll need some help to validate that the change doesn't break any existing logic.

lisa/tools/tpm2.py Outdated Show resolved Hide resolved
- cvm_boot: use bootctl to locate root device

Signed-off-by: Thien Trung Vuong <[email protected]>
Signed-off-by: Thien Trung Vuong <[email protected]>
@trungams
Copy link
Member Author

trungams commented Feb 4, 2025

@LiliDeng The image I used to test this change is MicrosoftCBLMariner azure-linux-3 azure-linux-3-cvm latest

security_profile_settings = cast(
SecurityProfileSettings, node.features[SecurityProfile].get_settings()
)
if not security_profile_settings.encrypt_disk:
Copy link
Member Author

Choose a reason for hiding this comment

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

@squirrelsc @LiliDeng Ideally I want to be able to detect this setting earlier and specify it in the requirement above. I tried adding a function to lisa/features/security_profile.py as below:

DiskEncryptionEnabled = partial(
    SecurityProfileSettings,
    encrypt_disk=True
)

and then use it similarly to how CvmEnabled is used. But it doesn't skip this test case if encrypt_disk is set to false in the runbook. Rather, it turns on that value for the running VM. That's why I had to resort to VM runtime check like this. Do you know how I can implement that kind of check to add to simple_requirement?

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