Skip to content
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

Wl/webhook test #182

Merged
merged 86 commits into from
Aug 9, 2019
Merged
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
3ec3f78
Added testing for webhook using KIND
willfairwinds Jul 30, 2019
53c7662
fixed branching error
willfairwinds Jul 31, 2019
f6e5b08
Merge branch 'master' into wl/webhook-test
willfairwinds Jul 31, 2019
11ac419
Merge branch 'master' into wl/webhook-test
willfairwinds Jul 31, 2019
13f1dad
added tests to CircleCI
willfairwinds Jul 31, 2019
d2ec9d8
added tests to CircleCI
willfairwinds Jul 31, 2019
e7c5fe1
Merge branch 'wl/webhook-test' of https://github.com/FairwindsOps/pol…
willfairwinds Jul 31, 2019
2f9cd73
attempt to stop failing circleci test
willfairwinds Jul 31, 2019
6ec2acf
Merge branch 'master' into wl/webhook-test
willfairwinds Jul 31, 2019
693db94
moved location of testing for webhook in CircleCI
willfairwinds Jul 31, 2019
3ef5a36
Merge branch 'wl/webhook-test' of https://github.com/FairwindsOps/pol…
willfairwinds Jul 31, 2019
e9ade0c
debugging
willfairwinds Jul 31, 2019
51220fe
more debugging
willfairwinds Jul 31, 2019
94e4562
.
willfairwinds Jul 31, 2019
2a38840
.
willfairwinds Jul 31, 2019
c46e9b6
added download of webhook to test
willfairwinds Jul 31, 2019
ccac426
..
willfairwinds Jul 31, 2019
5e6c8cf
...
willfairwinds Jul 31, 2019
fb72633
corrected sleep comand
willfairwinds Aug 1, 2019
f276ab5
Merge branch 'master' into wl/webhook-test
willfairwinds Aug 1, 2019
1be38a1
.
willfairwinds Aug 1, 2019
5998e40
.
willfairwinds Aug 1, 2019
9c17287
code working now, clean up
willfairwinds Aug 1, 2019
d87c372
testing smaller sleep times
willfairwinds Aug 1, 2019
be05a76
increased sleep time
willfairwinds Aug 1, 2019
8e692c9
responded to comments on github
willfairwinds Aug 2, 2019
a79ba0d
Merge branch 'master' into wl/webhook-test
willfairwinds Aug 2, 2019
1adb494
.
willfairwinds Aug 2, 2019
497d3c0
Merge branch 'wl/webhook-test' of https://github.com/FairwindsOps/pol…
willfairwinds Aug 2, 2019
7050451
debug
willfairwinds Aug 2, 2019
118d211
more edits
willfairwinds Aug 5, 2019
2b558b9
Merge branch 'master' into wl/webhook-test
willfairwinds Aug 5, 2019
1138857
debugging second test failing.
willfairwinds Aug 5, 2019
aac2b28
Merge branch 'wl/webhook-test' of https://github.com/FairwindsOps/pol…
willfairwinds Aug 5, 2019
ce43ca3
debugging
willfairwinds Aug 5, 2019
acf9d8b
tests doing opposite of what they should be debugging.
willfairwinds Aug 5, 2019
3b29be4
debugging
willfairwinds Aug 5, 2019
39cc0f8
.
willfairwinds Aug 5, 2019
0d302e4
.
willfairwinds Aug 5, 2019
62a27e1
fixing error in installation of webhook.
willfairwinds Aug 5, 2019
9176ab6
.
willfairwinds Aug 5, 2019
977253e
timeout increase
willfairwinds Aug 5, 2019
eccd31c
trying to install webhook
willfairwinds Aug 5, 2019
91b9b45
.
willfairwinds Aug 5, 2019
0fb7626
.
willfairwinds Aug 5, 2019
4163d38
..
willfairwinds Aug 5, 2019
0bc5441
webhook still not i installing properly
willfairwinds Aug 5, 2019
ab31fa6
..
willfairwinds Aug 5, 2019
c510814
..
willfairwinds Aug 5, 2019
d3741f6
add log message
rbren Aug 5, 2019
54e21ff
..
willfairwinds Aug 5, 2019
3cff8d1
changed order of test_k8s, removed set -e
willfairwinds Aug 5, 2019
bef555a
..
willfairwinds Aug 5, 2019
e2f3de5
namespace polaris
willfairwinds Aug 5, 2019
4d75388
.
willfairwinds Aug 5, 2019
c119248
.......
willfairwinds Aug 5, 2019
2374c87
intial testing for new strategy.
willfairwinds Aug 6, 2019
e709a6e
intial testing for new strategy.
willfairwinds Aug 6, 2019
4403614
..
willfairwinds Aug 6, 2019
23d9855
.
willfairwinds Aug 6, 2019
d824e6a
...
willfairwinds Aug 6, 2019
c3c58c8
final edits, working now
willfairwinds Aug 6, 2019
9ed0f3d
fixed files, cleaned up logs, added more detail to webhook starting d…
willfairwinds Aug 6, 2019
86b3ff7
?
willfairwinds Aug 6, 2019
ca9ce22
added test files for other controller types, adding testing for them …
willfairwinds Aug 6, 2019
0ab9425
increased sleep time
willfairwinds Aug 6, 2019
846210c
testing
willfairwinds Aug 6, 2019
85b7278
finally added tests for jobs
willfairwinds Aug 7, 2019
2f97534
changed while loop condition to include webhook.
willfairwinds Aug 7, 2019
ddbad55
.
willfairwinds Aug 7, 2019
ef32265
lskdfsjkl
willfairwinds Aug 7, 2019
583150b
sd
willfairwinds Aug 7, 2019
b950df7
lskfjlskj
willfairwinds Aug 7, 2019
1a8c67d
.
willfairwinds Aug 7, 2019
86670de
final
willfairwinds Aug 7, 2019
8910a3c
added timeout test for dashboard to try to aleviate error
willfairwinds Aug 8, 2019
cd96188
.
willfairwinds Aug 8, 2019
78fa43c
.
willfairwinds Aug 8, 2019
bffb7b5
install the dashboard
willfairwinds Aug 8, 2019
b7e6eb1
...
willfairwinds Aug 8, 2019
aeee3d1
initial test for new kube_dashboard_test
willfairwinds Aug 8, 2019
bcf6c7f
initial test for new kube_dashboard_test
willfairwinds Aug 8, 2019
d6acc0c
?
willfairwinds Aug 8, 2019
cac7311
deleting unused code
willfairwinds Aug 9, 2019
00ab8d4
final change for dashboard test
willfairwinds Aug 9, 2019
caa0b30
final
willfairwinds Aug 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added timeout test for dashboard to try to aleviate error
  • Loading branch information
willfairwinds committed Aug 8, 2019
commit 8910a3c4dda2457b7404a9b3069403067dcdf081
91 changes: 73 additions & 18 deletions test/webhook_test.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,89 @@
#!/bin/bash
endzyme marked this conversation as resolved.
Show resolved Hide resolved
#Testing to ensure that the webhook starts up, allows a correct deployment to pass,
#and prevents a incorrectly formatted deployment.
set -e

#sed is replacing the polaris version with this commit sha so we are testing exactly this verison.
sed -ri "s|'(quay.io/reactiveops/polaris:).+'|'\1${CIRCLE_SHA1}'|" ./deploy/webhook.yaml
willfairwinds marked this conversation as resolved.
Show resolved Hide resolved

rbren marked this conversation as resolved.
Show resolved Hide resolved
# Testing to ensure that the webhook starts up, allows a correct deployment to pass,
# and prevents a incorrectly formatted deployment.
function check_webhook_is_ready() {
# Get the epoch time in one minute from now
local timeout_epoch

# Reset another 2 minutes to wait for webhook
timeout_epoch=$(date -d "+2 minutes" +%s)

# loop until this fails (desired condition is we cannot apply this yaml doc, which means the webhook is working
echo "Waiting for webhook to be ready"
while ! kubectl get pods -n polaris | grep"Webhook.*Running"; do
check_timeout "${timeout_epoch}"
echo -n "."
done

echo "Webhook started!"
}

function check_dashboard_is_ready() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can get rid of this now

local timeout_epoch
timeout_epoch=$(date -d "+2 minutes" +%s)
echo "Waiting for dashboard to be ready"
while ! kubectl get pods -n polaris | grep -E "dashboard.*Running"; do
echo -n "."
done

echo "Dashboard Running!"
}

# Check if timeout is hit and exit if it is
function check_timeout() {
local timeout_epoch="${1}"
if [[ "$(date +%s)" -ge "${timeout_epoch}" ]]; then
echo -e "Timeout hit waiting for readiness: exiting"
grab_logs
clean_up
exit 1
fi

}

# Clean up all your stuff
function clean_up() {
# Clean up files you've installed (helps with local testing)
for filename in test/*yaml; do
# || true to avoid issues when we cannot delete
kubectl delete -f $filename &>/dev/null ||true
done
# Uninstall webhook and webhook config
kubectl delete validatingwebhookconfigurations polaris-webhook --wait=false &>/dev/null
kubectl -n polaris delete deploy -l app=polaris --wait=false &>/dev/null
}

function grab_logs() {
kubectl -n polaris get pods -oyaml -l app=polaris
kubectl -n polaris describe pods -l app=polaris
kubectl -n polaris logs -l app=polaris
}

# Install the webhook
kubectl apply -f ./deploy/webhook.yaml &> /dev/null
timeout=25
#Fix Me: Need a more deterministic way to test for completion of webhook installation.
#The while loop exits when the webhook is installed but not yet effective, so we have to sleep
#before testing it.
while ! kubectl get po -n polaris | grep -E "dashboard.*Running "; do
echo "Waiting for webhook to start..."
if [ $timeout -eq 0 ]; then
echo "Timed out while waiting for webhook to start"
exit 1
fi
timeout=$((timeout-1))
sleep 1
done
sleep 20
echo "Webhook started!"

#Webhook started, setting all tests as passed initially.
# wait for the webhook and dashboard to come online
check_webhook_is_ready
check_dashboard_is_ready
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


# Webhook started, setting all tests as passed initially.
ALL_TESTS_PASSED=1

# Run tests against correctly configured objects
for filename in test/passing_test.*.yaml; do
echo $filename
if ! kubectl apply -f $filename &> /dev/null; then
ALL_TESTS_PASSED=0
echo "Test Failed: Polaris prevented a deployment with no configuration issues."
fi
done

# Run tests against incorrectly configured objects
for filename in test/failing_test.*.yaml; do
echo $filename
if kubectl apply -f $filename &> /dev/null; then
Expand All @@ -39,6 +92,8 @@ for filename in test/failing_test.*.yaml; do
fi
done

clean_up

#Verify that all the tests passed.
if [ $ALL_TESTS_PASSED -eq 1 ]; then
echo "Tests Passed."
Expand Down