← Back to Pull requests

test/e2e: new abstraction to run CoCo tests with pre-installed KBS #3365

Open
wainersm opened this pull request with 300 lines diff across 8 files
View on GitHub
wainersm wainersm commented on Oct 02, 2026 22:18 UTC
Author

Extend the infrastructure to run the CoCo tests against cluster with a pre-installed KBS.

This introduces a KbsManager abstraction so one can implement back-ends tailored with different methods to deploy and and manage KBS. It implements the interface to:

current framework-deployed KBS (managed via kbs-client)
trustee-operator (managed via k8s resources)

Added a test for signed image as a proof of concept.

----

The short-story: I'm working to run cloud-api-adaptor's tests in our downstream CI. In our environment the KBS is installed by our operator (a fork of confidential-containers/trustee-operator) where any operations (e.g. change the resources policy) should be carried out via k8s resources (e.g. edit the kbsConfig configmap), hence, unlike the current implementation we cannot use the kbs-client for that purpose. Hence, the new abstraction is made to accommodate our needs as well as the current implementation.

I'm sending a new test that I used as a proof of concept. I know that this test is incomplete (misses the negative-cases, for example) and that @stevenhorsman has also one implementation of the same signed image tests. My intention is to reuse @stevenhorsman 's work as much as possible here.

I tested the changes with the new test in my CI but I could not verify (yet) it breaks others. Also I don't know caa's CI current status, so no idea if it can catch problems that might be introduced. I plan to work on all of that, to ensure upstream tests don't break.

However, before spend further time on the remaining work, I wanted to have an initial feedback on the overall thing.

Diff: 300 lines (+280 / -20) across 8 files Reviewer: mkulke Review duration: 13502m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.47) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 300 lines diff across 8 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.90 · 5 substantive comment(s)
0.90
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.341
Real PR Conversation Timeline
7 items
mkulke mkulke commented on Oct 03, 2026 09:08 UTC
Reviewer

are we sure we want to couple trustee-operator (kbs_operator_manager) to this repo?

I think it makes sense to have an option to use a KBS that has been provisioned outside of the test framework, but both trustee-operator and CAA are downstream consumers of trustee, and it feels a bit odd to actively manage operator-isms like populating secrets/configmaps here.

That said, I think an abstraction (I guess that's kbs_manager?) that enables a downstream extensions to support other means of kbs deployments is a great idea, it would also enable us to use a mock-kbs without all the state and admin headache in tests.

wainersm wainersm commented on Oct 05, 2026 21:38 UTC
Author

Hi @magowan ,

are we sure we want to couple trustee-operator (kbs_operator_manager) to this repo?

> I think it makes sense to have an option to use a KBS that has been provisioned outside of the test framework, but both trustee-operator and CAA are downstream consumers of trustee, and it feels a bit odd to actively manage operator-isms like populating secrets/configmaps here.

Good point. I added kbs_operator_manager because I will need it for my downstream CI and to account for TestTrusteeOperatorKeyReleaseForSpecificKey that was introduced in commit c15a519d5. But I can:

remove kbs_operator_manager entirely, then I carry a downstream implementation
get rid of TestTrusteeOperatorKeyReleaseForSpecificKey and ensure TestKbsKeyRelease works with any implementation of kbs_manager

Makes sense?

That said, I think an abstraction (I guess that's kbs_manager?) that enables a downstream extensions to support other means of kbs deployments is a great idea, it would also enable us to use a mock-kbs without all the state and admin headache in tests.

Good to hear that.

Never thought about mock-kbs...looks like a good idea, although in my case (downstream) I would prefer testing with a real kbs.

mkulke mkulke commented on Oct 06, 2026 06:09 UTC
Contributor

Good point. I added kbs_operator_manager because I will need it for my downstream CI and to account for TestTrusteeOperatorKeyReleaseForSpecificKey that was introduced in commit c15a519. But I can:

> remove kbs_operator_manager entirely, then I carry a downstream implementation

> get rid of TestTrusteeOperatorKeyReleaseForSpecificKey and ensure TestKbsKeyRelease works with any implementation of kbs_manager

>

Makes sense?

yup sounds good

wainersm wainersm commented on Oct 07, 2026 21:26 UTC
Author

Hi @mkulke ,

this new version I removed the trustee-operator implementation and added a mechanism (2nd commit) to carry it downstream; it should work just like the provision abstraction. I didn't drop TestTrusteeOperatorKeyReleaseForSpecificKey yet because it will require a more changes (not much) and I don't want to mix up now, so I prefer to send in a follow up PR.

I didn't fully test the v2 yet, should be doing it soon. Nevertheless, let me know if it is acceptable.

mkulke mkulke commented on code on Oct 08, 2026 07:24 UTC
Code Review
src/cloud-api-adaptor/test/e2e/common.go:1
@@ -95,6 +96,11 @@ url = '{{ .KBSURL }}'
 {{- if .KBSCert }}
 kbs_cert = """{{ .KBSCert }}"""
 {{- end }}
+{{- if .ImagePolicyURI }}
+
+[image]

I think this is based on (unmerged) #3333

mkulke mkulke commented on code on Oct 08, 2026 07:25 UTC
Code Review
src/cloud-api-adaptor/test/e2e/main_test.go:1
@@ -97,6 +97,17 @@ func TestMain(m *testing.M) {
 		os.Setenv("TEST_KBS", "true")
 	}
 
+	// KBS_MANAGEMENT selects the KbsManager backend. It says how the KBS is
+	// managed, not whether the KBS tests run: that stays with TEST_KBS.
+	kbsManagement := os.Getenv("KBS_MANAGEMENT")

should we merge this with DEPLOY_KBS? so something like KBS_MANAGEMENT=deploy or KBS_DEPLOYMENT=helm|external?

Reviewers
Assignees
wainersm wainersm
Labels
risk: low confidence: 89.4% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.4% (MEDIUM) · Higher = larger blast radius
47.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 89.4% · Lower = rushed or shallow review
89.4%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5% · Safe to merge
5%