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