Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
25c81f3c
Unverified
Commit
25c81f3c
authored
Oct 14, 2019
by
Erik Wilson
Committed by
GitHub
Oct 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #898 from erikwilson/update-sonobuoy-builds
Clean up sonobuoy testing
parents
264347a4
8beb368b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
86 deletions
+48
-86
sonobuoy
scripts/sonobuoy
+28
-51
sonobuoy-e2e-tests
scripts/sonobuoy-e2e-tests
+20
-35
No files found.
scripts/sonobuoy
View file @
25c81f3c
...
...
@@ -98,56 +98,42 @@ export -f dump-container-logs
# ---
sonobuoy-destruct
()
{
mkdir
-p
${
LOGS
}
sonobuoy logs
>
${
LOGS
}
/
$i
-sonobuoy
.log 2>&1
sonobuoy delete
--wait
}
export
-f
sonobuoy-destruct
# ---
sonobuoy-test
()
{
timeout
--foreground
30m sonobuoy run
\
--config
scripts/sonobuoy-config.json
\
--plugin-env
=
e2e.E2E_USE_GO_RUNNER
=
true
\
--wait
\
"
${
@
}
"
if
sonobuoy status |
grep
"failed"
;
then
sonobuoy-destruct
return
1
retrieve-sonobuoy-logs
()
{
if
sonobuoy status |
grep
-q
-E
" +e2e +complete +passed +"
;
then
status
=
passed
exit_code
=
0
else
status
=
failed
exit_code
=
1
fi
rm
-rf
${
E2E
}
mkdir
-p
${
E2E
}
sonobuoy retrieve
${
E2E
}
tar
x
-z
-f
${
E2E
}
/
*
_sonobuoy_
*
.tar.gz
-C
${
E2E
}
${
E2E_LOG
}
if
[
!
-s
${
RESULTS
}
]
;
then
sonobuoy-destruct
return
1
fi
tail
-20
${
RESULTS
}
if
[
-n
"
${
E2E_LOG_OUTPUT
}
"
]
;
then
cp
${
RESULTS
}
$(
sed
-e
"s/-STATUS-/-
${
status
}
-/g"
<<<
"
${
E2E_LOG_OUTPUT
}
"
)
fi
awk
'/^Summarizing .* Failures:$/,0'
${
RESULTS
}
return
${
exit_code
}
}
export
-f
sonobuoy-test
export
-f
retrieve-sonobuoy-logs
# ---
sonobuoy-retry-test
()
{
SECONDS
=
0
LIMIT
=
300
for
i
in
$(
seq
1 3
)
;
do
sonobuoy-test
"
${
@
}
"
&&
return
echo
"*** Failed Sonobuoy try #
${
i
}
on port
${
K3S_PORT
}
at
${
SECONDS
}
seconds ***"
if
[
"
$SECONDS
"
-gt
"
$LIMIT
"
]
;
then
echo
"Stopping sonobuoy re-try after
${
SECONDS
}
seconds (limit
${
LIMIT
}
s)"
break
fi
done
return
1
sonobuoy-test
()
{
time
sonobuoy run
\
--config
=
scripts/sonobuoy-config.json
\
--plugin-env
=
e2e.E2E_USE_GO_RUNNER
=
true
\
--wait
=
30
\
"
${
@
}
"
&
SONOBUOY_PID
=
$!
wait
$SONOBUOY_PID
retrieve-sonobuoy-logs
}
export
-f
sonobuoy-
retry-
test
export
-f
sonobuoy-test
# ---
...
...
@@ -155,6 +141,8 @@ cleanup() {
exit_status
=
$?
set
+e
echo
"Cleaning up"
trap
- EXIT
[
-n
"
$SONOBUOY_PID
"
]
&&
kill
$SONOBUOY_PID
2>/dev/null
if
[
"
${
exit_status
}
"
-ne
"0"
]
;
then
dump-container-logs
fi
...
...
@@ -172,7 +160,6 @@ LOGS=$(pwd)/logs/$$
E2E
=
"
${
OUTPUT
}
/e2e"
E2E_LOG
=
"plugins/e2e/results/global/e2e.log"
RESULTS
=
"
${
E2E
}
/
${
E2E_LOG
}
"
mkdir
-p
${
OUTPUT
}
SECRET
=
random-
$((
100000
+
RANDOM
%
999999
))
export
K3S_AGENT
=
sonobuoy-k3s-agent-
${
K3S_PORT
}
...
...
@@ -180,6 +167,8 @@ export K3S_SERVER=sonobuoy-k3s-server-${K3S_PORT}
export
CONTAINERS
=
"
${
K3S_SERVER
}
${
K3S_AGENT
}
"
export
KUBECONFIG
=
${
OUTPUT
}
/kubeconfig.yaml
mkdir
-p
${
OUTPUT
}
# ---
docker run
-d
--name
${
K3S_SERVER
}
--privileged
\
...
...
@@ -207,16 +196,4 @@ timeout --foreground 1m bash -c wait-for-nodes
timeout
--foreground
1m bash
-c
wait-for-services
echo
"Starting sonobuoy tests"
sonobuoy-retry-test
"
${
@
}
"
# ---
exit_code
=
0
status
=
$(
tail
-5
${
RESULTS
}
|
grep
'^SUCCESS!.*| 0 Failed |'
>
/dev/null
&&
echo
passed
||
echo
failed
)
[
"
${
status
}
"
=
"failed"
]
&&
exit_code
=
1
if
[
-n
"
${
E2E_LOG_OUTPUT
}
"
]
;
then
cp
${
RESULTS
}
$(
echo
${
E2E_LOG_OUTPUT
}
|
sed
-e
"s/-STATUS-/-
${
status
}
-/g"
)
fi
exit
${
exit_code
}
sonobuoy-test
"
${
@
}
"
scripts/sonobuoy-e2e-tests
View file @
25c81f3c
...
...
@@ -17,6 +17,23 @@ mkdir -p ${OUTPUT}
pids
=()
output
=()
cleanup
()
{
exit_status
=
$?
set
+e
trap
- EXIT INT
kill
${
pids
[@]
}
2>/dev/null
wait
set
+x
echo
-n
"Tests "
if
[
"
${
exit_status
}
"
-eq
"0"
]
;
then
echo
"passed"
else
echo
"failed"
fi
exit
${
exit_status
}
}
trap
cleanup EXIT INT
run-sonobuoy
()
{
output+
=(
${
log_output
}
)
E2E_LOG_OUTPUT
=
${
log_output
}
./scripts/sonobuoy
${
@
}
&
...
...
@@ -31,40 +48,8 @@ sleep 60
log_output
=
${
OUTPUT
}
/e2e-STATUS-
${
ARCH
}
-serial
.log
\
run-sonobuoy
--e2e-focus
=
'\[Serial\].*\[Conformance\]'
show-logs
()
{
for
pid
in
"
${
pids
[@]
}
"
;
do
logdir
=
$(
pwd
)
/logs/
${
pid
}
if
[
!
-d
$logdir
]
;
then
continue
fi
echo
echo
"#- Begin: logs for sonobuoy run pid
${
pid
}
"
for
log
in
$(
pwd
)
/logs/
${
pid
}
/
*
;
do
if
[
-f
${
log
}
]
;
then
echo
echo
"#- Start:
${
log
}
"
cat
${
log
}
echo
"#- End:
${
log
}
"
echo
fi
done
echo
"#- Finish: logs for sonobuoy run pid
${
pid
}
"
echo
done
}
cleanup
()
{
exit_status
=
$?
set
+e +x
wait
echo
"Finished the tests!"
if
[
"
${
exit_status
}
"
-ne
"0"
]
;
then
show-logs
fi
exit
${
exit_status
}
}
trap
cleanup EXIT
exit_code
=
0
for
pid
in
"
${
pids
[@]
}
"
;
do
wait
$pid
||
exit
$?
wait
$pid
||
exit
_code
=
$?
done
exit
${
exit_code
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment