Skip to content

Commit f0022d8

Browse files
authored
Merge pull request kubernetes#76744 from xichengliudui/fixshellcheckfailures-25
Fix shellcheck failures on test-e2e-node.sh and test-integration.sh
2 parents 64a0441 + 7a39c99 commit f0022d8

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

hack/.shellcheck_failures

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
./hack/make-rules/clean.sh
3636
./hack/make-rules/helpers/cache_go_dirs.sh
3737
./hack/make-rules/make-help.sh
38-
./hack/make-rules/test-e2e-node.sh
39-
./hack/make-rules/test-integration.sh
4038
./hack/make-rules/test.sh
4139
./hack/make-rules/update.sh
4240
./hack/make-rules/verify.sh

hack/make-rules/test-e2e-node.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
17+
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
1818
source "${KUBE_ROOT}/hack/lib/init.sh"
1919

2020
focus=${FOCUS:-""}
@@ -26,7 +26,7 @@ skip=${SKIP-"\[Flaky\]|\[Slow\]|\[Serial\]"}
2626
# Currently, parallelism only affects when REMOTE=true. For local test,
2727
# ginkgo default parallelism (cores - 1) is used.
2828
parallelism=${PARALLELISM:-8}
29-
artifacts=${ARTIFACTS:-"/tmp/_artifacts/`date +%y%m%dT%H%M%S`"}
29+
artifacts="${ARTIFACTS:-"/tmp/_artifacts/$(date +%y%m%dT%H%M%S)"}"
3030
remote=${REMOTE:-"false"}
3131
runtime=${RUNTIME:-"docker"}
3232
container_runtime_endpoint=${CONTAINER_RUNTIME_ENDPOINT:-""}
@@ -38,7 +38,7 @@ extra_envs=${EXTRA_ENVS:-}
3838

3939
# Parse the flags to pass to ginkgo
4040
ginkgoflags=""
41-
if [[ ${parallelism} > 1 ]]; then
41+
if [[ ${parallelism} -gt 1 ]]; then
4242
ginkgoflags="${ginkgoflags} -nodes=${parallelism} "
4343
fi
4444

@@ -57,21 +57,21 @@ fi
5757
# Setup the directory to copy test artifacts (logs, junit.xml, etc) from remote host to local host
5858
if [ ! -d "${artifacts}" ]; then
5959
echo "Creating artifacts directory at ${artifacts}"
60-
mkdir -p ${artifacts}
60+
mkdir -p "${artifacts}"
6161
fi
6262
echo "Test artifacts will be written to ${artifacts}"
6363

6464
if [[ ${runtime} == "remote" ]] ; then
65-
if [[ ! -z ${container_runtime_endpoint} ]] ; then
65+
if [[ -n ${container_runtime_endpoint} ]] ; then
6666
test_args="--container-runtime-endpoint=${container_runtime_endpoint} ${test_args}"
6767
fi
68-
if [[ ! -z ${image_service_endpoint} ]] ; then
68+
if [[ -n ${image_service_endpoint} ]] ; then
6969
test_args="--image-service-endpoint=${image_service_endpoint} ${test_args}"
7070
fi
7171
fi
7272

7373

74-
if [ ${remote} = true ] ; then
74+
if [ "${remote}" = true ] ; then
7575
# The following options are only valid in remote run.
7676
images=${IMAGES:-""}
7777
hosts=${HOSTS:-""}
@@ -85,8 +85,8 @@ if [ ${remote} = true ] ; then
8585
gubernator=${GUBERNATOR:-"false"}
8686
image_config_file=${IMAGE_CONFIG_FILE:-""}
8787
if [[ ${hosts} == "" && ${images} == "" && ${image_config_file} == "" ]]; then
88-
image_project=${IMAGE_PROJECT:-"cos-cloud"}
89-
gci_image=$(gcloud compute images list --project ${image_project} \
88+
image_project="${IMAGE_PROJECT:-"cos-cloud"}"
89+
gci_image=$(gcloud compute images list --project "${image_project}" \
9090
--no-standard-images --filter="name ~ 'cos-beta.*'" --format="table[no-heading](name)")
9191
images=${gci_image}
9292
metadata="user-data<${KUBE_ROOT}/test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
@@ -116,7 +116,7 @@ if [ ${remote} = true ] ; then
116116
IFS=',' read -ra IM <<< "${images}"
117117
images=""
118118
for i in "${IM[@]}"; do
119-
if [[ $(gcloud compute instances list "${instance_prefix}-${i}" | grep ${i}) ]]; then
119+
if gcloud compute instances list "${instance_prefix}-${i}" | grep "${i}"; then
120120
if [[ "${hosts}" != "" ]]; then
121121
hosts="${hosts},"
122122
fi

hack/make-rules/test-integration.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
21+
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
2222
source "${KUBE_ROOT}/hack/lib/init.sh"
2323
# Lists of API Versions of each groups that should be tested, groups are
2424
# separated by comma, lists are separated by semicolon. e.g.,
@@ -40,7 +40,7 @@ KUBE_TEST_VMODULE=${KUBE_TEST_VMODULE:-"garbagecollector*=6,graph_builder*=6"}
4040

4141
kube::test::find_integration_test_dirs() {
4242
(
43-
cd ${KUBE_ROOT}
43+
cd "${KUBE_ROOT}"
4444
find test/integration/ -name '*_test.go' -print0 \
4545
| xargs -0n1 dirname | sed "s|^|${KUBE_GO_PACKAGE}/|" \
4646
| LC_ALL=C sort -u
@@ -67,7 +67,10 @@ runTests() {
6767
kube::etcd::start
6868
kube::log::status "Running integration test cases"
6969

70-
KUBE_RACE="-race"
70+
# export KUBE_RACE
71+
#
72+
# Enable the Go race detector.
73+
export KUBE_RACE="-race"
7174
make -C "${KUBE_ROOT}" test \
7275
WHAT="${WHAT:-$(kube::test::find_integration_test_dirs | paste -sd' ' -)}" \
7376
GOFLAGS="${GOFLAGS:-}" \
@@ -94,7 +97,7 @@ checkEtcdOnPath
9497
trap cleanup EXIT
9598

9699
# Convert the CSV to an array of API versions to test
97-
IFS=';' read -a apiVersions <<< "${KUBE_TEST_API_VERSIONS}"
100+
IFS=';' read -ra apiVersions <<< "${KUBE_TEST_API_VERSIONS}"
98101
for apiVersion in "${apiVersions[@]}"; do
99102
runTests "${apiVersion}"
100103
done

0 commit comments

Comments
 (0)