Skip to content

Create first integration test#42

Merged
Jakob-Naucke merged 14 commits into
trusted-execution-clusters:mainfrom
alicefr:integration-tests
Nov 13, 2025
Merged

Create first integration test#42
Jakob-Naucke merged 14 commits into
trusted-execution-clusters:mainfrom
alicefr:integration-tests

Conversation

@alicefr
Copy link
Copy Markdown
Contributor

@alicefr alicefr commented Sep 29, 2025

  • Each test suite runs in its own Kubernetes namespace to avoid conflicts.
  • Introduced a common module for managing test namespaces and resources.
  • Added 2 test suite one for verifying the standard management of the resources child of the cocl CR and the second with the VM attestation

@Jakob-Naucke Jakob-Naucke self-requested a review September 29, 2025 14:39
@alicefr alicefr force-pushed the integration-tests branch 4 times, most recently from 1bcaa6b to a812001 Compare September 30, 2025 15:14
Copy link
Copy Markdown
Contributor

@Jakob-Naucke Jakob-Naucke left a comment

Choose a reason for hiding this comment

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

Thanks @alicefr. Couple of small things. Maybe add something to the README?

Comment thread tests/Cargo.toml Outdated
Comment thread tests/confidential_cluster.rs Outdated
Comment thread tests/confidential_cluster.rs Outdated
Comment thread tests/common/mod.rs Outdated
Comment thread tests/common/timer.rs Outdated
@alicefr
Copy link
Copy Markdown
Contributor Author

alicefr commented Oct 1, 2025

@Jakob-Naucke I'm thinking of publishing a new version where we run an integration test in a different namespace, so we don't need to worry to clean up and recover the initial state and they can be run in parallel. We do need to install each time the operator from scratch

@alicefr alicefr force-pushed the integration-tests branch 4 times, most recently from f4853e2 to 601d252 Compare October 6, 2025 07:34
Comment thread operator/src/main.rs Outdated
Comment thread tests/common/mod.rs Outdated
Comment thread tests/common/mod.rs Outdated
Comment thread tests/common/mod.rs Outdated
Comment thread tests/common/mod.rs Outdated
Comment thread tests/confidential_cluster.rs Outdated
Comment thread tests/confidential_cluster.rs Outdated
Comment thread tests/README.md Outdated
Comment thread Cargo.toml Outdated
@alicefr alicefr force-pushed the integration-tests branch from 601d252 to cafef03 Compare October 6, 2025 09:56
Comment thread .github/workflows/rust.yml
@alicefr alicefr force-pushed the integration-tests branch 11 times, most recently from 81dd386 to ff5a9a0 Compare October 10, 2025 06:17
@alicefr alicefr marked this pull request as draft October 14, 2025 12:23
@Jakob-Naucke Jakob-Naucke linked an issue Oct 17, 2025 that may be closed by this pull request
@alicefr alicefr force-pushed the integration-tests branch 2 times, most recently from a93b847 to 600d952 Compare November 5, 2025 15:45
@alicefr alicefr marked this pull request as ready for review November 5, 2025 15:54
Copy link
Copy Markdown
Contributor

@Jakob-Naucke Jakob-Naucke left a comment

Choose a reason for hiding this comment

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

For this review, I tried things out more than I looked at the code. I want to do a separate one but maybe we can iron some things out in this round before delaying the review more.

  • The parallel start of tests also lead to this for me:
INFO: test_parallel_vm_attestation: CRDs and RBAC generated successfully
INFO: test_vm_reboot_attestation: CRDs and RBAC generated successfully
INFO: test_vm_reboot_attestation: Manifests generated successfully
INFO: test_vm_reboot_attestation: Applying CRDs
INFO: test_parallel_vm_attestation: Manifests generated successfully
INFO: test_parallel_vm_attestation: Applying CRDs
INFO: test_attestation: CRDs and RBAC generated successfully
INFO: test_attestation: Manifests generated successfully
INFO: test_attestation: Applying CRDs
INFO: test_parallel_vm_attestation: Preparing RBAC manifests
INFO: test_parallel_vm_attestation: Preparing RBAC kustomization
INFO: test_parallel_vm_attestation: Applying RBAC
Error: Failed to apply CRDs: Error from server (AlreadyExists): error when creating "/tmp/manifests-0f3e99c9-e361-49bf-a2c3-3c9034cb7993/crd/confidential-clusters.io_confidentialclusters.yaml": customresourcedefinitions.apiextensions.k8s.io "confidentialclusters.confidential-clusters.io" already exists

test test_vm_reboot_attestation ... FAILED
  • The test_parallel_vm_attestation also irreproducibly failed once (unknown resource but no particular log from the Trustee pod) and then worked fine afterwards 😬 e: could be that there is some timing issue with the key not being stored in time

Comment thread tests/README.md
Comment thread Makefile Outdated
Comment thread test_utils/src/lib.rs
Comment thread test_utils/src/lib.rs Outdated
Comment thread tests/attestation.rs Outdated
Comment thread tests/README.md
Comment thread test_utils/src/virt.rs
Comment thread scripts/install-kubevirt.sh Outdated
@alicefr alicefr force-pushed the integration-tests branch 2 times, most recently from e1d364c to 5ff7fc4 Compare November 11, 2025 11:05
@alicefr
Copy link
Copy Markdown
Contributor Author

alicefr commented Nov 11, 2025

For this review, I tried things out more than I looked at the code. I want to do a separate one but maybe we can iron some things out in this round before delaying the review more.

  • The parallel start of tests also lead to this for me:
INFO: test_parallel_vm_attestation: CRDs and RBAC generated successfully
INFO: test_vm_reboot_attestation: CRDs and RBAC generated successfully
INFO: test_vm_reboot_attestation: Manifests generated successfully
INFO: test_vm_reboot_attestation: Applying CRDs
INFO: test_parallel_vm_attestation: Manifests generated successfully
INFO: test_parallel_vm_attestation: Applying CRDs
INFO: test_attestation: CRDs and RBAC generated successfully
INFO: test_attestation: Manifests generated successfully
INFO: test_attestation: Applying CRDs
INFO: test_parallel_vm_attestation: Preparing RBAC manifests
INFO: test_parallel_vm_attestation: Preparing RBAC kustomization
INFO: test_parallel_vm_attestation: Applying RBAC
Error: Failed to apply CRDs: Error from server (AlreadyExists): error when creating "/tmp/manifests-0f3e99c9-e361-49bf-a2c3-3c9034cb7993/crd/confidential-clusters.io_confidentialclusters.yaml": customresourcedefinitions.apiextensions.k8s.io "confidentialclusters.confidential-clusters.io" already exists

test test_vm_reboot_attestation ... FAILED

Good catch, this was happening because the cocl CRD isn't namespaced, hence we only need to create once. I add the check to verify if it already exist, not to install it again

@alicefr alicefr requested a review from Jakob-Naucke November 12, 2025 07:55
Comment thread .github/workflows/rust.yml Outdated
Comment thread test_utils/src/lib.rs Outdated
Comment thread test_utils/src/lib.rs Outdated
Comment thread test_utils/src/lib.rs Outdated
Comment thread tests/README.md
Comment thread tests/README.md Outdated
Comment thread test_utils/src/virt.rs Outdated
Only run the unit tests since the integration tests require a cluster to
be created and configured.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Set timeout for the kind cluster and avoid the replace flag for docker

Signed-off-by: Alice Frosi <afrosi@redhat.com>
KubeVirt is using centos stream 9 secure boot variables and our library
compute the ones from fedora. This will be fixed in a follow-up PR.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Signed-off-by: Alice Frosi <afrosi@redhat.com>
Setting -x for the cluster creation for better debuggability on the ci.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Source isn't recognized as command by the github actions.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
KubeVirt doesn't properly work with the default CNI plugin of kind.
Therefore, it requires calico as CNI.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
It possible that the job name has a '-' has 63 character and the name is
invalid.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Signed-off-by: Alice Frosi <afrosi@redhat.com>
Copy link
Copy Markdown
Contributor

@Jakob-Naucke Jakob-Naucke left a comment

Choose a reason for hiding this comment

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

CRD still already exists :(

Comment thread scripts/create-cluster-kind.sh Outdated
Introduction of a new test framework for integration testing:

- Create test_utils crate in workspace root with:
  - TestContext for test lifecycle management
  - Automatic namespace creation/cleanup
  - Operator deployment and manifest generation
  - Helper macros (test_info!, named_test!, setup!)
  - Polling utility for async resource waiting

- Add confidential_cluster integration test that validates:
  - ConfidentialCluster CR creation and reconciliation
  - Image PCRs computation and ConfigMap updates
  - Resource cleanup on CR deletion.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Add support for KubeVirt-based integration testing:

- Add virtualization feature flag to test_utils and tests crates
- Create test_utils/src/virt.rs with KubeVirt helper functions:
  - SSH key generation and injection into ssh-agent
  - Ignition config generation
  - KubeVirt VM creation and lifecycle management
  - SSH command execution via virtctl
  - Encrypted root device verification

- Add attestation integration test that validates:
  - if a VM attests and boots successfully
  - if the attestation can be run in parallel by starting 2 VMs
  - if the attestation properly works for subsequent boots by rebooting
    the VM multiple times

Tests can run with: cargo test --features virtualization

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Signed-off-by: Alice Frosi <afrosi@redhat.com>
Without the installation of the standard CNI, the waiting for the
cluster to be ready times out. This is probably a bug in kind, then
let's create the cluster and wait for the API server to be running.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
We still need to investigate how to correctly parellelize the tests, for
now to get the first tests integrated we decide to run them serially.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Copy link
Copy Markdown
Contributor

@Jakob-Naucke Jakob-Naucke left a comment

Choose a reason for hiding this comment

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

Thank you for your work!

@alicefr
Copy link
Copy Markdown
Contributor Author

alicefr commented Nov 13, 2025

can we merge it?

@Jakob-Naucke Jakob-Naucke merged commit 5bdb137 into trusted-execution-clusters:main Nov 13, 2025
8 checks passed
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.

Invalid name for the compute PCR job

2 participants