-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add create-pyxis-image test for oci artifacts (#644)
This ensures the --platform flag is passed to oras properly Signed-off-by: Johnny Bieren <[email protected]>
- Loading branch information
1 parent
75d9063
commit bebe15c
Showing
2 changed files
with
131 additions
and
2 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
126 changes: 126 additions & 0 deletions
126
tasks/create-pyxis-image/tests/test-create-pyxis-image-oci-artifact.yaml
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,126 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: test-create-pyxis-image-oci-artifact | ||
spec: | ||
description: | | ||
Run the create-pyxis-image task with a single oci artifact in the snapshot. | ||
This test ensures the ORAS_ARGS are passed properly. | ||
workspaces: | ||
- name: tests-workspace | ||
tasks: | ||
- name: setup | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
taskSpec: | ||
workspaces: | ||
- name: data | ||
steps: | ||
- name: setup-values | ||
image: quay.io/konflux-ci/release-service-utils:65d8db844c008e7736ec8dff307868525279484d | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
cat > "$(workspaces.data.path)"/snapshot.json << EOF | ||
{ | ||
"application": "myapp", | ||
"components": [ | ||
{ | ||
"name": "comp", | ||
"containerImage": "source@sha256:mydigest", | ||
"repository": "registry.io/oci-artifact", | ||
"tags": [ | ||
"testtag" | ||
] | ||
} | ||
] | ||
} | ||
EOF | ||
- name: run-task | ||
taskRef: | ||
name: create-pyxis-image | ||
params: | ||
- name: pyxisSecret | ||
value: test-create-pyxis-image-cert | ||
- name: server | ||
value: stage | ||
- name: snapshotPath | ||
value: snapshot.json | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
runAfter: | ||
- setup | ||
- name: check-result | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
taskSpec: | ||
workspaces: | ||
- name: data | ||
steps: | ||
- name: check-result | ||
image: quay.io/konflux-ci/release-service-utils:65d8db844c008e7736ec8dff307868525279484d | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
if [ "$(wc -l < "$(workspaces.data.path)"/mock_create_container_image.txt)" != 1 ]; then | ||
echo Error: create_container_image was expected to be called 1 time. Actual calls: | ||
cat "$(workspaces.data.path)/mock_create_container_image.txt" | ||
exit 1 | ||
fi | ||
if [ -f "$(workspaces.data.path)"/mock_cleanup_tags.txt ]; then | ||
echo Error: cleanup_tags was not expected to be called. Actual calls: | ||
cat "$(workspaces.data.path)/mock_cleanup_tags.txt" | ||
exit 1 | ||
fi | ||
if ! grep -- "--tags testtag" < "$(workspaces.data.path)"/mock_create_container_image.txt 2> /dev/null | ||
then | ||
echo Error: create_container_image call was expected to include "--tags testtag". Actual call: | ||
cat "$(workspaces.data.path)/mock_create_container_image.txt" | ||
exit 1 | ||
fi | ||
if ! grep -- "--rh-push false" < "$(workspaces.data.path)"/mock_create_container_image.txt 2> /dev/null | ||
then | ||
echo Error: create_container_image call was expected to include "--rh-push false". Actual call: | ||
cat "$(workspaces.data.path)/mock_create_container_image.txt" | ||
exit 1 | ||
fi | ||
if [ "$(wc -l < "$(workspaces.data.path)"/mock_skopeo.txt)" != 1 ]; then | ||
echo Error: skopeo was expected to be called 1 time. Actual calls: | ||
cat "$(workspaces.data.path)/mock_skopeo.txt" | ||
exit 1 | ||
fi | ||
if [ "$(wc -l < "$(workspaces.data.path)"/mock_oras.txt)" != 3 ]; then | ||
echo Error: oras was expected to be called 3 times. Actual calls: | ||
cat "$(workspaces.data.path)/mock_oras.txt" | ||
exit 1 | ||
fi | ||
if ! grep -- "--platform linux/amd64" < "$(workspaces.data.path)"/mock_oras.txt 2> /dev/null | ||
then | ||
echo Error: oras call was expected to include "--platform linux/amd64". Actual call: | ||
cat "$(workspaces.data.path)/mock_oras.txt" | ||
exit 1 | ||
fi | ||
[ "$(head -n 1 < "$(workspaces.data.path)"/mock_skopeo.txt)" \ | ||
= "inspect --raw docker://registry.io/oci-artifact@sha256:mydigest" ] | ||
if [ "$(wc -l < "$(workspaces.data.path)"/mock_select-oci-auth.txt)" != 2 ]; then | ||
echo Error: select-oci-with was expected to be called 2 times. Actual calls: | ||
cat "$(workspaces.data.path)/mock_select-oci-auth.txt" | ||
exit 1 | ||
fi | ||
runAfter: | ||
- run-task |