Skip to content
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

Fix shellcheck failures on test-e2e-node.sh and test-integration.sh #76744

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions hack/.shellcheck_failures
Expand Up @@ -34,8 +34,6 @@
./hack/make-rules/clean.sh
./hack/make-rules/helpers/cache_go_dirs.sh
./hack/make-rules/make-help.sh
./hack/make-rules/test-e2e-node.sh
./hack/make-rules/test-integration.sh
./hack/make-rules/test.sh
./hack/make-rules/update.sh
./hack/make-rules/verify.sh
Expand Down
20 changes: 10 additions & 10 deletions hack/make-rules/test-e2e-node.sh
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

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

# Parse the flags to pass to ginkgo
ginkgoflags=""
if [[ ${parallelism} > 1 ]]; then
if [[ ${parallelism} -gt 1 ]]; then
ginkgoflags="${ginkgoflags} -nodes=${parallelism} "
fi

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

if [[ ${runtime} == "remote" ]] ; then
if [[ ! -z ${container_runtime_endpoint} ]] ; then
if [[ -n ${container_runtime_endpoint} ]] ; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did it change and what did it fix:

In ./hack/make-rules/test-e2e-node.sh line 65:
  if [[ ! -z ${container_runtime_endpoint} ]] ; then
        ^-- SC2236: Use -n instead of ! -z.
Ref: https://github.com/koalaman/shellcheck/wiki/SC2236

test_args="--container-runtime-endpoint=${container_runtime_endpoint} ${test_args}"
fi
if [[ ! -z ${image_service_endpoint} ]] ; then
if [[ -n ${image_service_endpoint} ]] ; then
test_args="--image-service-endpoint=${image_service_endpoint} ${test_args}"
fi
fi


if [ ${remote} = true ] ; then
if [ "${remote}" = true ] ; then
# The following options are only valid in remote run.
images=${IMAGES:-""}
hosts=${HOSTS:-""}
Expand All @@ -85,8 +85,8 @@ if [ ${remote} = true ] ; then
gubernator=${GUBERNATOR:-"false"}
image_config_file=${IMAGE_CONFIG_FILE:-""}
if [[ ${hosts} == "" && ${images} == "" && ${image_config_file} == "" ]]; then
image_project=${IMAGE_PROJECT:-"cos-cloud"}
gci_image=$(gcloud compute images list --project ${image_project} \
image_project="${IMAGE_PROJECT:-"cos-cloud"}"
gci_image=$(gcloud compute images list --project "${image_project}" \
--no-standard-images --filter="name ~ 'cos-beta.*'" --format="table[no-heading](name)")
images=${gci_image}
metadata="user-data<${KUBE_ROOT}/test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
Expand Down Expand Up @@ -116,7 +116,7 @@ if [ ${remote} = true ] ; then
IFS=',' read -ra IM <<< "${images}"
images=""
for i in "${IM[@]}"; do
if [[ $(gcloud compute instances list "${instance_prefix}-${i}" | grep ${i}) ]]; then
if gcloud compute instances list "${instance_prefix}-${i}" | grep "${i}"; then
if [[ "${hosts}" != "" ]]; then
hosts="${hosts},"
fi
Expand Down
11 changes: 7 additions & 4 deletions hack/make-rules/test-integration.sh
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

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

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

KUBE_RACE="-race"
# export KUBE_RACE
#
# Enable the Go race detector.
export KUBE_RACE="-race"
make -C "${KUBE_ROOT}" test \
WHAT="${WHAT:-$(kube::test::find_integration_test_dirs | paste -sd' ' -)}" \
GOFLAGS="${GOFLAGS:-}" \
Expand All @@ -94,7 +97,7 @@ checkEtcdOnPath
trap cleanup EXIT

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