Merge pull request #79500 from BenTheElder/node-run-tests

fix shellcheck failures in test/e2e_node/conformance/run_test.sh
This commit is contained in:
Kubernetes Prow Robot 2019-06-28 08:05:51 -07:00 committed by GitHub
commit ce9d4a947e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 24 deletions

View File

@ -21,5 +21,4 @@
./test/cmd/diff.sh
./test/cmd/discovery.sh
./test/cmd/legacy-script.sh
./test/e2e_node/conformance/run_test.sh
./test/images/image-util.sh

View File

@ -67,12 +67,12 @@ KUBELET_BIN=${KUBELET_BIN:-"kubelet"}
# KUBELET is the kubelet binary path. If it is not specified, assume kubelet is
# in PATH.
KUBELET=${KUBELET:-"`which $KUBELET_BIN`"}
KUBELET=${KUBELET:-"$(which "$KUBELET_BIN")"}
# LOG_DIR is the absolute path of the directory where the test will collect all
# logs to. By default, use the current directory.
LOG_DIR=${LOG_DIR:-`pwd`}
mkdir -p $LOG_DIR
LOG_DIR=${LOG_DIR:-$(pwd)}
mkdir -p "$LOG_DIR"
# NETWORK_PLUGIN is the network plugin used by kubelet. Do not use network
# plugin by default.
@ -92,7 +92,8 @@ KUBELET_KUBECONFIG=${KUBELET_KUBECONFIG:-"/var/lib/kubelet/kubeconfig"}
function create-kubelet-kubeconfig() {
local api_addr="${1}"
local dest="${2}"
local dest_dir="$(dirname "${dest}")"
local dest_dir
dest_dir="$(dirname "${dest}")"
mkdir -p "${dest_dir}" &>/dev/null || sudo mkdir -p "${dest_dir}"
sudo=$(test -w "${dest_dir}" || echo "sudo -E")
cat <<EOF | ${sudo} tee "${dest}" > /dev/null
@ -114,10 +115,12 @@ EOF
kubelet_log=kubelet.log
start_kubelet() {
echo "Creating kubelet.kubeconfig"
create-kubelet-kubeconfig "http://localhost:8080" $KUBELET_KUBECONFIG
create-kubelet-kubeconfig "http://localhost:8080" "${KUBELET_KUBECONFIG}"
echo "Starting kubelet..."
sudo -b $KUBELET $@ &>$LOG_DIR/$kubelet_log
if [ $? -ne 0 ]; then
# we want to run this command as root but log the file to a normal user file
# (so disable SC2024)
# shellcheck disable=SC2024
if ! sudo -b "${KUBELET}" "$@" &>"${LOG_DIR}/${kubelet_log}"; then
echo "Failed to start kubelet"
exit 1
fi
@ -130,8 +133,7 @@ wait_kubelet() {
local maxRetry=10
local cur=1
while [ $cur -le $maxRetry ]; do
curl -s $healthCheckURL > /dev/null
if [ $? -eq 0 ]; then
if curl -s $healthCheckURL > /dev/null; then
echo "Kubelet is ready"
break
fi
@ -148,8 +150,7 @@ wait_kubelet() {
# kill_kubelet kills kubelet.
kill_kubelet() {
echo "Stopping kubelet..."
sudo pkill $KUBELET_BIN
if [ $? -ne 0 ]; then
if ! sudo pkill "${KUBELET_BIN}"; then
echo "Failed to stop kubelet."
exit 1
fi
@ -158,13 +159,13 @@ kill_kubelet() {
# run_test runs the node test container.
run_test() {
env=""
if [ ! -z "$FOCUS" ]; then
if [ -n "$FOCUS" ]; then
env="$env -e FOCUS=\"$FOCUS\""
fi
if [ ! -z "$SKIP" ]; then
if [ -n "$SKIP" ]; then
env="$env -e SKIP=\"$SKIP\""
fi
if [ ! -z "$TEST_ARGS" ]; then
if [ -n "$TEST_ARGS" ]; then
env="$env -e TEST_ARGS=\"$TEST_ARGS\""
fi
# The test assumes that inside the container:
@ -177,31 +178,31 @@ run_test() {
# Check whether kubelet is running. If kubelet is running, tell the user to stop
# it before running the test.
pid=`pidof $KUBELET_BIN`
if [ ! -z $pid ]; then
pid=$(pidof "${KUBELET_BIN}")
if [ -n "$pid" ]; then
echo "Kubelet is running (pid=$pid), please stop it before running the test."
exit 1
fi
volume_stats_agg_period=10s
serialize_image_pulls=false
config_dir=`mktemp -d`
config_dir=$(mktemp -d)
file_check_frequency=10s
pod_cidr=10.100.0.0/24
log_level=4
start_kubelet --kubeconfig ${KUBELET_KUBECONFIG} \
start_kubelet --kubeconfig "${KUBELET_KUBECONFIG}" \
--volume-stats-agg-period $volume_stats_agg_period \
--serialize-image-pulls=$serialize_image_pulls \
--pod-manifest-path $config_dir \
--pod-manifest-path "${config_dir}" \
--file-check-frequency $file_check_frequency \
--pod-cidr=$pod_cidr \
--runtime-cgroups=/docker-daemon \
--kubelet-cgroups=/kubelet \
--system-cgroups=/system \
--cgroup-root=/ \
--network-plugin=$NETWORK_PLUGIN \
--cni-conf-dir=$CNI_CONF_DIR \
--cni-bin-dir=$CNI_BIN_DIR \
"--network-plugin=${NETWORK_PLUGIN}" \
"--cni-conf-dir=${CNI_CONF_DIR}" \
"--cni-bin-dir=${CNI_BIN_DIR}" \
--v=$log_level \
--logtostderr
@ -212,4 +213,4 @@ run_test
kill_kubelet
# Clean up the kubelet config directory
sudo rm -rf $config_dir
sudo rm -rf "${config_dir}"