-
Notifications
You must be signed in to change notification settings - Fork 25
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
[VC-37264] Update E2E test to check for certificate in the API #629
Open
wallrj
wants to merge
1
commit into
master
Choose a base branch
from
more-e2e-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -26,7 +26,6 @@ | |
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
set -o xtrace | ||
|
||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
root_dir=$(cd "${script_dir}/../.." && pwd) | ||
|
@@ -195,7 +194,38 @@ kubectl -n team-1 wait certificate app-0 --for=condition=Ready | |
# Parse logs as JSON using jq to ensure logs are all JSON formatted. | ||
# Disable pipefail to prevent SIGPIPE (141) errors from tee | ||
# See https://unix.stackexchange.com/questions/274120/pipe-fail-141-when-piping-output-into-tee-why | ||
set +o pipefail | ||
kubectl logs deployments/venafi-kubernetes-agent \ | ||
--follow \ | ||
--namespace venafi \ | ||
| timeout 60 jq 'if .msg | test("Data sent successfully") then . | halt_error(0) end' | ||
set -o pipefail | ||
|
||
# Create a unique TLS Secret and wait for it to appear in the Venafi certificate inventory API | ||
commonname="venafi-kubernetes-agent-e2e.$(uuidgen)" | ||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls.key -out /tmp/tls.crt -subj "/CN=$commonname" 2>/dev/null | ||
kubectl create secret tls "$commonname" --cert=/tmp/tls.crt --key=/tmp/tls.key -o yaml --dry-run=client | kubectl apply -f - | ||
|
||
getCertificate() { | ||
jq -n '{ | ||
"expression": { | ||
"field": "subjectCN", | ||
"operator": "MATCH", | ||
"value": $commonname | ||
}, | ||
"ordering": { | ||
"orders": [ | ||
{ "direction": "DESC", "field": "certificatInstanceModificationDate" } | ||
] | ||
}, | ||
"paging": { "pageNumber": 0, "pageSize": 10 } | ||
}' --arg commonname "${commonname}" \ | ||
| curl "https://${VEN_API_HOST}/outagedetection/v1/certificatesearch?excludeSupersededInstances=true&ownershipTree=true" \ | ||
-fsSL \ | ||
-H "tppl-api-key: $VEN_API_KEY" \ | ||
--json @- \ | ||
| jq 'if .count == 0 then . | halt_error(1) end' | ||
} | ||
|
||
# Wait 5 minutes for the certificate to appear. | ||
for ((i=0;;i++)); do if getCertificate; then exit 0; fi; sleep 30; done | timeout -v -- 5m cat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realise that you can pipe into the |
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.
I'd accidentally removed this pipefail trick in #596
and it resulted in the test always exiting with a 141 status.
I've restored it here so that the new shell lines can run after the "Data sent successfully" message.