-
Notifications
You must be signed in to change notification settings - Fork 60
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
CI: Improve e2e tests reliability #343
Changes from 3 commits
b72f8f1
db80d13
62d67be
5d4895d
2d78020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,9 +164,9 @@ uninstall_ccruntime() { | |
popd >/dev/null | ||
|
||
# Wait and ensure ccruntime pods are gone | ||
# | ||
local cmd="! sudo -E kubectl get pods -n $op_ns |" | ||
cmd+="grep -q -e cc-operator-daemon-install" | ||
# (ensure failing kubectl keeps iterating) | ||
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. Good catch! |
||
local cmd="_OUT=\$(sudo -E kubectl get pods -n '$op_ns')" | ||
cmd+=" && ! echo \$_OUT | grep -q -e cc-operator-daemon-install" | ||
cmd+=" -e cc-operator-pre-install-daemon" | ||
if ! wait_for_process 720 30 "$cmd"; then | ||
echo "ERROR: there are ccruntime pods still running" | ||
|
@@ -242,10 +242,9 @@ uninstall_operator() { | |
popd >/dev/null | ||
|
||
# Wait and ensure the controller pod is gone | ||
# | ||
local pod="cc-operator-controller-manager" | ||
local cmd="! kubectl get pods -n $op_ns |" | ||
cmd+="grep -q $pod" | ||
# (ensure failing kubectl keeps iterating) | ||
local cmd="_OUT=\$(sudo -E kubectl get pods -n '$op_ns')" | ||
cmd+="&& ! echo \$_OUT | grep -q -e cc-operator-controller-manager" | ||
if ! wait_for_process 180 30 "$cmd"; then | ||
echo "ERROR: the controller manager is still running" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ step_start_cluster=0 | |
step_install_operator=0 | ||
runtimeclass="" | ||
undo="false" | ||
timeout="false" | ||
|
||
usage() { | ||
cat <<-EOF | ||
|
@@ -29,36 +30,47 @@ usage() { | |
the tests. Defaults to "kata-qemu". | ||
-u: undo the installation and configuration before exiting. Useful for | ||
baremetal machine were it needs to do clean up for the next tests. | ||
-t: enable default timeout for each operation (useful for CI) | ||
EOF | ||
} | ||
|
||
parse_args() { | ||
while getopts "hr:u" opt; do | ||
while getopts "hr:ut" opt; do | ||
case $opt in | ||
h) usage && exit 0;; | ||
r) runtimeclass="$OPTARG";; | ||
u) undo="true";; | ||
t) timeout="true";; | ||
*) usage && exit 1;; | ||
esac | ||
done | ||
} | ||
|
||
run() { | ||
duration=$1; shift | ||
if [ "$timeout" == "true" ]; then | ||
timeout $duration "$@" | ||
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. What if it prints a friendly message (e.g. "Run timed out after XX") when it timed out? i.e. when 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. That can open a can of worms as the script itself can return 124 so we'd have to add a logic to get the actual time (I mean we could use the $SECONDS so it's not that extensive but still) and then report "Run probably timed out after XXXs" when the timeout seems correct. Do you want me to add it or are we going to rely on log timestamps only? 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. Hmm... we better leave as is. If we start seeing too many timeouts and it proves to be confusing then we may change it. |
||
else | ||
"$@" | ||
fi | ||
} | ||
|
||
undo_changes() { | ||
pushd "$script_dir" >/dev/null | ||
# Do not try to undo steps that did not execute. | ||
if [ $step_install_operator -eq 1 ]; then | ||
echo "INFO: Uninstall the operator" | ||
sudo -E PATH="$PATH" bash -c './operator.sh uninstall' || true | ||
run 10m sudo -E PATH="$PATH" bash -c './operator.sh uninstall' || true | ||
fi | ||
|
||
if [ $step_start_cluster -eq 1 ]; then | ||
echo "INFO: Shutdown the cluster" | ||
sudo -E PATH="$PATH" bash -c './cluster/down.sh' || true | ||
run 5m sudo -E PATH="$PATH" bash -c './cluster/down.sh' || true | ||
fi | ||
|
||
if [ $step_bootstrap_env -eq 1 ]; then | ||
echo "INFO: Undo the bootstrap" | ||
ansible-playbook -i localhost, -c local --tags undo ansible/main.yml || true | ||
run 5m ansible-playbook -i localhost, -c local --tags undo ansible/main.yml || true | ||
fi | ||
popd >/dev/null | ||
} | ||
|
@@ -87,19 +99,19 @@ main() { | |
pushd "$script_dir" >/dev/null | ||
echo "INFO: Bootstrap the local machine" | ||
step_bootstrap_env=1 | ||
ansible-playbook -i localhost, -c local --tags untagged ansible/main.yml | ||
run 10m ansible-playbook -i localhost, -c local --tags untagged ansible/main.yml | ||
|
||
echo "INFO: Bring up the test cluster" | ||
step_start_cluster=1 | ||
sudo -E PATH="$PATH" bash -c './cluster/up.sh' | ||
run 10m sudo -E PATH="$PATH" bash -c './cluster/up.sh' | ||
export KUBECONFIG=/etc/kubernetes/admin.conf | ||
|
||
echo "INFO: Build and install the operator" | ||
step_install_operator=1 | ||
sudo -E PATH="$PATH" bash -c './operator.sh' | ||
run 20m sudo -E PATH="$PATH" bash -c './operator.sh' | ||
|
||
echo "INFO: Run tests" | ||
cmd="sudo -E PATH=\"$PATH\" bash -c " | ||
cmd="run 20m sudo -E PATH=\"$PATH\" bash -c " | ||
if [ -z "$runtimeclass" ]; then | ||
cmd+="'./tests_runner.sh'" | ||
else | ||
|
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.
Yeah, it makes sense to have the timeout in the script because we don't map this steps to github job's steps, otherwise the timeouts could be set on the github workflows. This scenario might change when we address #309 .