-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding image tests for memory monitoring
- Loading branch information
1 parent
ed6b88e
commit 8f89e86
Showing
11 changed files
with
232 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"memory": { | ||
"metricsConfigs": { | ||
"memory/bytes_used": { | ||
"displayName": "memory/bytes_used" | ||
} | ||
} | ||
}, | ||
"invokeInterval": "60s" | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
launcher/image/test/scripts/test_launcher_workload_discover_signatures.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
source util/read_serial.sh | ||
|
||
# This test requires the workload to run and printing | ||
# corresponding messages to the serial console. | ||
SERIAL_OUTPUT=$(read_serial $1 $2) | ||
print_serial=false | ||
|
||
if echo $SERIAL_OUTPUT | grep -q 'Found container image signatures' | ||
then | ||
echo "- container image signatures found" | ||
else | ||
echo "FAILED: container image signatures not found" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_serial=true | ||
fi | ||
|
||
if $print_serial; then | ||
echo $SERIAL_OUTPUT | ||
fi |
21 changes: 21 additions & 0 deletions
21
launcher/image/test/scripts/test_memory_monitoring_enabled.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
source util/read_serial.sh | ||
|
||
# This test requires the workload to run and printing | ||
# corresponding messages to the serial console. | ||
SERIAL_OUTPUT=$(read_serial $1 $2) | ||
print_serial=false | ||
|
||
if echo $SERIAL_OUTPUT | grep -q 'node-problem-detector.service successfully started' | ||
then | ||
echo "- memory monitoring enabled" | ||
else | ||
echo "FAILED: memory monitoring disabled" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_serial=true | ||
fi | ||
|
||
if $print_serial; then | ||
echo $SERIAL_OUTPUT | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
substitutions: | ||
'_IMAGE_NAME': '' | ||
'_IMAGE_PROJECT': '' | ||
'_CLEANUP': 'true' | ||
'_VM_NAME_PREFIX': 'discover-signatures' | ||
'_ZONE': 'us-west1-a' | ||
'_WORKLOAD_IMAGE': 'us-west1-docker.pkg.dev/confidential-space-images-dev/cs-integ-test-images/basic-test:latest' | ||
'_SIGNATURE_REPO': 'us-docker.pkg.dev/confidential-space-images-dev/cs-cosign-tests/hardened' | ||
|
||
steps: | ||
- name: 'gcr.io/projectsigstore/cosign:v2.2.0' | ||
id: SignContainer | ||
entrypoint: 'sh' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: | ||
- -c | ||
- | | ||
# Unpadded base64 encoding on the CloudKMS public key | ||
pub=$(cosign public-key --key gcpkms://projects/confidential-space-images-dev/locations/global/keyRings/cosign-test/cryptoKeys/ecdsa/cryptoKeyVersions/1 | openssl base64) | ||
pub=$(echo $pub | tr -d '[:space:]' | sed 's/[=]*$//') | ||
# Use cosign sign | ||
export COSIGN_REPOSITORY=${_SIGNATURE_REPO} | ||
cosign sign --key gcpkms://projects/confidential-space-images-dev/locations/global/keyRings/cosign-test/cryptoKeys/ecdsa/cryptoKeyVersions/1 ${_WORKLOAD_IMAGE} -a dev.cosignproject.cosign/sigalg=ECDSA_P256_SHA256 -a dev.cosignproject.cosign/pub=$pub | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CreateVM | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['create_vm.sh','-i', '${_IMAGE_NAME}', | ||
'-p', '${_IMAGE_PROJECT}', | ||
'-m', 'tee-image-reference=${_WORKLOAD_IMAGE},tee-container-log-redirect=true,tee-signed-image-repos=${_SIGNATURE_REPO},tee-env-ALLOWED_OVERRIDE=overridden,tee-cmd=["newCmd"]', | ||
'-n', '${_VM_NAME_PREFIX}-${BUILD_ID}', | ||
'-z', '${_ZONE}', | ||
] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: BasicDiscoverSignaturesTest | ||
entrypoint: 'bash' | ||
args: ['scripts/test_launcher_workload_discover_signatures.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}'] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CleanUp | ||
entrypoint: 'bash' | ||
env: | ||
- 'CLEANUP=$_CLEANUP' | ||
args: ['cleanup.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}'] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: DeleteContainerSignatures | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
entrypoint: 'bash' | ||
args: | ||
- -c | ||
- | | ||
echo "Deleting container signatures..." | ||
digest=$(gcloud artifacts docker images describe ${_WORKLOAD_IMAGE} --format 'value(image_summary.digest)') | ||
tag=${digest/":"/"-"}.sig | ||
# Delete container signature by its tag | ||
gcloud artifacts docker images delete -q ${_SIGNATURE_REPO}:${tag} | ||
# Must come after cleanup. | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CheckFailure | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['check_failure.sh'] | ||
|
||
options: | ||
pool: | ||
name: 'projects/confidential-space-images-dev/locations/us-west1/workerPools/cs-image-build-vpc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
substitutions: | ||
'_IMAGE_NAME': '' | ||
'_IMAGE_PROJECT': '' | ||
'_CLEANUP': 'true' | ||
'_VM_NAME_PREFIX': 'memory-monitoring' | ||
'_ZONE': 'us-east1-b' | ||
'_WORKLOAD_IMAGE': 'us-west1-docker.pkg.dev/confidential-space-images-dev/cs-integ-test-images/memorymonitoring:latest' | ||
|
||
steps: | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CreateVM | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['create_vm.sh','-i', '${_IMAGE_NAME}', | ||
'-p', '${_IMAGE_PROJECT}', | ||
'-m', 'tee-image-reference=${_WORKLOAD_IMAGE},tee-container-log-redirect=true,tee-env-ALLOWED_OVERRIDE=overridden,tee-cmd=["newCmd"],tee-monitoring-memory-enable=true', | ||
'-n', '${_VM_NAME_PREFIX}-${BUILD_ID}', | ||
'-z', '${_ZONE}', | ||
] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CheckMemoryMonitoringEnabled | ||
entrypoint: 'bash' | ||
args: ['scripts/test_memory_monitoring_enabled.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}'] | ||
|
||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CleanUp | ||
entrypoint: 'bash' | ||
env: | ||
- 'CLEANUP=$_CLEANUP' | ||
args: ['cleanup.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}'] | ||
# Must come after cleanup. | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CheckFailure | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['check_failure.sh'] | ||
|
||
options: | ||
pool: | ||
name: 'projects/confidential-space-images-dev/locations/us-west1/workerPools/cs-image-build-vpc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# From current directory: | ||
# GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main ../basic | ||
# gcloud builds submit --tag us-west1-docker.pkg.dev/confidential-space-images-dev/cs-integ-test-images/memorymonitoring:latest --project confidential-space-images-dev | ||
FROM alpine | ||
|
||
COPY main / | ||
|
||
ENV env_bar="val_bar" | ||
|
||
LABEL "tee.launch_policy.monitoring_memory_allow"="always" | ||
|
||
ENTRYPOINT ["/main"] | ||
|
||
CMD ["arg_foo"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters