Skip to content

Commit a873a6b

Browse files
committed
fix(tests): Increase attestation timeout and update Makefile
The `test_attestation` test may time out while waiting for SSH access, as VM boot can exceed the previous 300s limit. Increase the maximum wait time to 600s to prevent this. Also, update the `integration-tests` target in the Makefile to add the `crds-rs` dependency and ensure the namespace is created before applying the manifests. And fix the race condition in the tests. Signed-off-by: Yalan Zhang <[email protected]>
1 parent 7238e18 commit a873a6b

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ endif
134134
$(YQ) '.spec.publicTrusteeAddr = "$(TRUSTEE_ADDR):8080"' \
135135
-i $(DEPLOY_PATH)/trusted_execution_cluster_cr.yaml
136136
$(YQ) '.namespace = "$(NAMESPACE)"' -i config/rbac/kustomization.yaml
137+
$(KUBECTL) create namespace $(NAMESPACE) || true
137138
$(KUBECTL) apply -f $(DEPLOY_PATH)/operator.yaml
138139
$(KUBECTL) apply -f config/crd
139140
$(KUBECTL) apply -k config/rbac
@@ -171,7 +172,7 @@ test: crds-rs
171172
test-release: crds-rs
172173
cargo test --workspace --bins --release
173174

174-
integration-tests: generate trusted-cluster-gen
175+
integration-tests: generate trusted-cluster-gen crds-rs
175176
RUST_LOG=info cargo test --test trusted_execution_cluster --test attestation \
176177
--features virtualization -- --no-capture --test-threads=1
177178

test_utils/src/virt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ pub async fn create_kubevirt_vm(
193193
},
194194
"resources": {
195195
"requests": {
196+
"cpu": "2",
196197
"memory": "4096M"
197198
}
198199
}

tests/attestation.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl SingleAttestationContext {
4848
test_ctx.info(format!("VM {} is Running", vm_name));
4949

5050
test_ctx.info(format!("Waiting for SSH access to VM {}", vm_name));
51-
virt::wait_for_vm_ssh_ready(namespace, vm_name, &key_path, 300).await?;
51+
virt::wait_for_vm_ssh_ready(namespace, vm_name, &key_path, 600).await?;
5252
test_ctx.info("SSH access is ready");
5353

5454
Ok(Self {
@@ -148,8 +148,8 @@ async fn test_parallel_vm_attestation() -> anyhow::Result<()> {
148148
// Wait for SSH access on both VMs in parallel
149149
test_ctx.info("Waiting for SSH access on both VMs");
150150
let (ssh1_ready, ssh2_ready) = tokio::join!(
151-
virt::wait_for_vm_ssh_ready(namespace, vm1_name, &key_path1, 300),
152-
virt::wait_for_vm_ssh_ready(namespace, vm2_name, &key_path2, 300)
151+
virt::wait_for_vm_ssh_ready(namespace, vm1_name, &key_path1, 900),
152+
virt::wait_for_vm_ssh_ready(namespace, vm2_name, &key_path2, 900)
153153
);
154154

155155
ssh1_ready?;
@@ -258,6 +258,7 @@ async fn test_vm_reboot_delete_machine() -> anyhow::Result<()> {
258258
let list = machines.list(&Default::default()).await?;
259259
let name = list.items[0].metadata.name.as_ref().unwrap();
260260
machines.delete(name, &Default::default()).await?;
261+
wait_for_resource_deleted(&machines, name, 120, 5).await?;
261262

262263
test_ctx.info("Performing reboot, expecting missing resource");
263264
let _reboot_result = virt::virtctl_ssh_exec(

tests/trusted_execution_cluster.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ async fn test_image_pcrs_configmap_updates() -> anyhow::Result<()> {
6262

6363
if let Some(data) = &cm.data {
6464
if let Some(image_pcrs_json) = data.get("image-pcrs.json") {
65-
if !image_pcrs_json.is_empty() {
66-
return Ok(());
65+
if let Ok(image_pcrs) = serde_json::from_str::<ImagePcrs>(image_pcrs_json) {
66+
if !image_pcrs.0.is_empty() {
67+
return Ok(());
68+
}
6769
}
6870
}
6971
}

0 commit comments

Comments
 (0)