-
Notifications
You must be signed in to change notification settings - Fork 17
mirror validation should pass with local image only; more testing for mirroring #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
| #!/bin/bash -x | ||
| set -eu | ||
|
|
||
| function guess_runfiles() { | ||
|
|
||
This file contains hidden or 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 hidden or 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,111 @@ | ||
| #!/bin/bash -x | ||
| # | ||
| # This test runs the script passed as the first argument and verifies the image is pushed to the registry | ||
| # | ||
| ${REGISTRY_BIN}& | ||
| registry_pid=$! | ||
| trap "kill -9 $registry_pid" EXIT | ||
|
|
||
| echo verifying image $REMOTE does not exist | ||
| ${CRANE_BIN} validate -v --fast --remote $REMOTE | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image $REMOTE should not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo verifying image $LOCAL does not exist | ||
| ${CRANE_BIN} validate -v --fast --remote $LOCAL | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image $LOCAL should not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| #test should fail before pushing the image (no src, no dst) | ||
| echo verifying mirror image validation fails | ||
| ${IMAGE_MIRROR_VALIDATE_SRC} | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image verification should fail" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo pushing image $SRC_IMAGE | ||
| ${PUSH_IMAGE} | ||
|
|
||
| echo verifying image $REMOTE exists | ||
| ${CRANE_BIN} validate -v --fast --remote $REMOTE | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image $REMOTE should exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo verifying image $LOCAL does not exist | ||
| ${CRANE_BIN} validate -v --fast --remote $LOCAL | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image $LOCAL should not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| #test should succeed with src image only | ||
| echo verifying mirror image validation fails | ||
| ${IMAGE_MIRROR_VALIDATE_SRC} | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image verification should succeed" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo running image mirror | ||
| ${IMAGE_MIRROR} | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image mirroring should succeed" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo verifying image $LOCAL exists | ||
| ${CRANE_BIN} validate -v --fast --remote $LOCAL | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image $LOCAL should exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo verifying image $REMOTE exists | ||
| ${CRANE_BIN} validate -v --fast --remote $REMOTE | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image $REMOTE should exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| #test should succeed with src and dst images | ||
| echo verifying mirror image validation succeeds | ||
| ${IMAGE_MIRROR_VALIDATE_SRC} | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image verification should succeed" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo removing image $REMOTE | ||
| ${CRANE_BIN} delete $REMOTE || exit 1 | ||
|
|
||
| echo verifying image $REMOTE does not exist | ||
| ${CRANE_BIN} validate -v --fast --remote $REMOTE | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image $REMOTE should not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo verifying image $LOCAL exists | ||
| ${CRANE_BIN} validate -v --fast --remote $LOCAL | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image $LOCAL should exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| #test should succeed with dst image only | ||
| echo verifying mirror image validation succeeds | ||
| ${IMAGE_MIRROR_VALIDATE_SRC} | ||
| if [ $? -ne 0 ]; then | ||
| echo "Image verification should succeed" | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
||
| # exit 1 | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,20 @@ | ||
| #!/bin/bash | ||
| echo "Validating image $1" | ||
| $CRANE_BIN validate -v --fast --remote $1 | ||
| REMOTE="{src_image}" | ||
| LOCAL="{dst_image}@{digest}" | ||
| echo "Validating images ${REMOTE} and ${LOCAL}" | ||
| {crane_tool} validate -v --fast --remote ${REMOTE} | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image ${REMOTE} exist" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Image ${REMOTE} does not exist, checking ${LOCAL}" | ||
|
|
||
| {crane_tool} validate -v --fast --remote ${LOCAL} | ||
| if [ $? -eq 0 ]; then | ||
| echo "Image ${LOCAL} exist" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Image ${LOCAL} does not exist" | ||
| exit 1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script starts a background process for
${REGISTRY_BIN}and sets a trap to kill it on exit. However, usingkill -9is generally discouraged because it does not allow the process to clean up. A gentler signal likeTERMshould be used first.Recommendation: Replace
kill -9 $registry_pidwithkill $registry_pidto allow the process to terminate gracefully. If the process does not terminate, then consider usingkill -9as a fallback.