Skip to content

Commit

Permalink
azure-e2e-test: Add test for key release in kbs
Browse files Browse the repository at this point in the history
Fixes: #1785
Signed-off-by: Kartik Joshi <[email protected]>
  • Loading branch information
kartikjoshi21 committed Apr 10, 2024
1 parent a2047c5 commit 73fa759
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/azure-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ jobs:
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}


- name: Restore the configuration created before
uses: actions/download-artifact@v3
with:
Expand All @@ -211,6 +212,8 @@ jobs:
az aks get-credentials \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name "${CLUSTER_NAME}"
touch install/overlays/azure/service-principal.env
ssh-keygen -t rsa -b 4096 -f install/overlays/azure/id_rsa -N "" -C [email protected]
make test-e2e
cleanup-resources:
Expand Down
13 changes: 10 additions & 3 deletions src/cloud-api-adaptor/test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

_ "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/azure"
)

/*
func TestDeletePodAzure(t *testing.T) {
t.Parallel()
DoTestDeleteSimplePod(t, testEnv, assert)
Expand All @@ -31,12 +31,19 @@ func TestCreatePodWithConfigMapAzure(t *testing.T) {
DoTestCreatePodWithConfigMap(t, testEnv, assert)
}
func TestCreateNginxDeploymentAzure(t *testing.T) {
t.Parallel()
DoTestNginxDeployment(t, testEnv, assert)
}
*/

func TestCreatePodWithSecretAzure(t *testing.T) {
t.Parallel()
DoTestCreatePodWithSecret(t, testEnv, assert)
}

func TestCreateNginxDeploymentAzure(t *testing.T) {
func TestKbsKeyRelease(t *testing.T) {
t.Parallel()
DoTestNginxDeployment(t, testEnv, assert)
DoTestKbsKeyRelease(t, testEnv, assert)
}
5 changes: 5 additions & 0 deletions src/cloud-api-adaptor/test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

const BUSYBOX_IMAGE = "quay.io/prometheus/busybox:latest"
const BUSYBOX_CURL_IMAGE = "quay.io/curl/curl:latest"
const WAIT_DEPLOYMENT_AVAILABLE_TIMEOUT = time.Second * 180
const DEFAULT_AUTH_SECRET = "auth-json-secret-default"

Expand Down Expand Up @@ -139,6 +140,10 @@ func NewBusyboxPod(namespace string) *corev1.Pod {
return NewBusyboxPodWithName(namespace, "busybox")
}

func NewBusyboxCurlPod(namespace string) *corev1.Pod {
return NewPod(namespace, podName, "busybox-curl", BUSYBOX_CURL_IMAGE, WithCommand([]string{"/bin/sh", "-c", "sleep 3600"}))

Check failure on line 144 in src/cloud-api-adaptor/test/e2e/common.go

View workflow job for this annotation

GitHub Actions / govulncheck

undefined: podName
}

func NewBusyboxPodWithName(namespace, podName string) *corev1.Pod {
return NewPod(namespace, podName, "busybox", BUSYBOX_IMAGE, WithCommand([]string{"/bin/sh", "-c", "sleep 3600"}))
}
Expand Down
23 changes: 23 additions & 0 deletions src/cloud-api-adaptor/test/e2e/common_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,26 @@ func DoTestPodsMTLSCommunication(t *testing.T, e env.Environment, assert CloudAs
NewTestCase(t, e, "TestPodsMTLSCommunication", assert, "Pods communication with mTLS").WithPod(serverPod).WithExtraPods(extraPods).WithConfigMap(configMap).WithService(nginxSvc).WithSecret(serverSecret).WithExtraSecrets(extraSecrets).Run()

}

func DoTestKbsKeyRelease(t *testing.T, e env.Environment, assert CloudAssert) {

log.Info("Do test kbs key release")
pod := NewBusyboxCurlPod(E2eNamespace)
testCommands := []TestCommand{
{
Command: []string{"curl", "http://127.0.0.1:8006/cdh/resource/reponame/workload_key/key.bin"},
ContainerName: pod.Spec.Containers[0].Name,
TestCommandStdoutFn: func(stdout bytes.Buffer) bool {
if strings.Contains(stdout.String(), "This is my cluster name") {
log.Infof("Success to get key.bin %s", stdout.String())
return true
} else {
log.Errorf("Failed to access key.bin: %s", stdout.String())
return false
}
},
},
}

NewTestCase(t, e, "KbsKeyReleasePod", assert, "Kbs key release is successfull").WithPod(pod).WithTestCommands(testCommands).Run()
}
4 changes: 2 additions & 2 deletions src/cloud-api-adaptor/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tools:
git:
guest-components:
url: https://github.com/confidential-containers/guest-components
reference: 277617af60c32661819c1132ffbf3db8dc6e1b9f
reference: 4d7ab88fa81d7bf5664b50bd84e38839e85a023f
kata-containers:
url: https://github.com/kata-containers/kata-containers
reference: d0df91935b8840036c2891b1f93dd8059ebe486a
Expand All @@ -46,4 +46,4 @@ oci:
tag: 3.6
kbs:
registry: ghcr.io/confidential-containers/key-broker-service
tag: v0.8.2
tag: ac59d337bbacc36990f71ced3de2e86619f236d3

0 comments on commit 73fa759

Please sign in to comment.