Skip to content

Commit

Permalink
Resolve shellcheck errors across repo
Browse files Browse the repository at this point in the history
Signed-off-by: Jose A. Rivera <[email protected]>
  • Loading branch information
jarrpa committed Aug 22, 2017
1 parent ef3b22c commit f6dd7a7
Show file tree
Hide file tree
Showing 24 changed files with 98 additions and 98 deletions.
10 changes: 5 additions & 5 deletions tests/complex/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ create_vagrant() {
}

start_vagrant() {
cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1
vagrant up --no-provision || end_test -e "Error starting vagrant environment"
}

stop_vagrant() {
cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1
vagrant halt || end_test -e "Error halting vagrant environment"
}

destroy_vagrant() {
cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1
vagrant destroy || end_test -e "Error destroying vagrant environment"
}

ssh_config() {
cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1
vagrant ssh-config > "${SSH_CONFIG}" || end_test -e "Error creating ssh-config"
}

Expand All @@ -115,9 +115,9 @@ rollback_vagrant() {
}

copy_deploy() {
cd ${VAGRANT_DIR}
local node=${1:-master}

cd "${VAGRANT_DIR}" || exit 1
scp -qr -F "${SSH_CONFIG}" "${DEPLOY_DIR}" "${node}:" || end_test -e "SCP deploy to ${node} failed"
scp -qr -F "${SSH_CONFIG}" "${TOPOLOGY_FILE}" "${node}:deploy/topology.json" || end_test -e "SCP topology to ${node} failed"
}
Expand Down
3 changes: 2 additions & 1 deletion tests/complex/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

TEST_DIR="$(realpath $(dirname $0))"
# shellcheck disable=SC2034
TESTNAME=""
TEST_DIR="$(realpath "$(dirname "${0}")")"

source "${TEST_DIR}/lib.sh"

Expand Down
2 changes: 1 addition & 1 deletion tests/complex/test-dynamic-provisioning.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TEST_DIR="$(realpath $(dirname $0))"
TEST_DIR="$(realpath "$(dirname "${0}")")"
DOCKER_IMAGE="gcr.io/google_containers/nginx-slim:0.8"

source "${TEST_DIR}/lib.sh"
Expand Down
2 changes: 1 addition & 1 deletion tests/complex/test-gk-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TEST_DIR="$(realpath $(dirname $0))"
TEST_DIR="$(realpath "$(dirname "${0}")")"

source "${TEST_DIR}/lib.sh"

Expand Down
16 changes: 8 additions & 8 deletions tests/complex/test-inside-dynamic-provisioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ kubectl exec "${APP}" -- /bin/bash -c "echo \"${CONTENT}\" > /usr/share/nginx/ht


echo "verifying we get back our content from the app"
OUTPUT="$(curl http://${appIP})"
OUTPUT="$(curl "http://${appIP}")"

if [[ "${OUTPUT}" != "${CONTENT}" ]]; then
echo "ERROR: did not get expected output from nginx pod"
Expand All @@ -116,17 +116,17 @@ fi

echo "verifying the content is actually stored on gluster"
mountinfo=$(kubectl exec "${APP}" -- /bin/bash -c "cat /proc/mounts | grep nginx" | awk '{print $1}')
volname=$(echo -n ${mountinfo} | cut -d: -f2)
glusterip=$(echo -n ${mountinfo} |cut -d: -f1)
glusterpod=$(kubectl get pods -o wide | grep ${glusterip} | awk '{print $1}')
volname=$(echo -n "${mountinfo}" | cut -d: -f2)
glusterip=$(echo -n "${mountinfo}" |cut -d: -f1)
glusterpod=$(kubectl get pods -o wide | grep "${glusterip}" | awk '{print $1}')

brickinfopath="/var/lib/glusterd/vols/${volname}/bricks"
brickinfofile=$(kubectl exec "${glusterpod}" -- /bin/bash -c "ls -1 ${brickinfopath} | head -n 1")
brickpath=$(kubectl exec ${glusterpod} -- /bin/bash -c "cat ${brickinfopath}/${brickinfofile} | grep real_path | cut -d= -f2")
brickhost=$(kubectl exec ${glusterpod} -- /bin/bash -c "cat ${brickinfopath}/${brickinfofile} | grep hostname | cut -d= -f2")
brickpod=$(kubectl get pods -o wide | grep ${brickhost} | awk '{print $1}')
brickpath=$(kubectl exec "${glusterpod}" -- /bin/bash -c "cat ${brickinfopath}/${brickinfofile} | grep real_path | cut -d= -f2")
brickhost=$(kubectl exec "${glusterpod}" -- /bin/bash -c "cat ${brickinfopath}/${brickinfofile} | grep hostname | cut -d= -f2")
brickpod=$(kubectl get pods -o wide | grep "${brickhost}" | awk '{print $1}')

BRICK_CONTENT=$(kubectl exec ${brickpod} -- /bin/bash -c "cat ${brickpath}/index.html")
BRICK_CONTENT=$(kubectl exec "${brickpod}" -- /bin/bash -c "cat ${brickpath}/index.html")
if [[ "${BRICK_CONTENT}" != "${CONTENT}" ]]; then
echo "ERROR: did not get expected content from brick"
exit 1
Expand Down
5 changes: 4 additions & 1 deletion tests/complex/test-inside-gk-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
cd ~/deploy


./gk-deploy -y -g -n default ./topology.json
cd ~/deploy || exit 1

# shellcheck disable=SC2086
./gk-deploy -v -y -g -n default

if [[ $? -ne 0 ]]; then
echo "ERROR: gk-deploy failed"
Expand Down
2 changes: 1 addition & 1 deletion tests/complex/test-setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TEST_DIR="$(realpath $(dirname $0))"
TEST_DIR="$(realpath "$(dirname "${0}")")"

source "${TEST_DIR}/lib.sh"

Expand Down
2 changes: 1 addition & 1 deletion tests/complex/test-teardown.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TEST_DIR="$(realpath $(dirname $0))"
TEST_DIR="$(realpath "$(dirname "${0}")")"

source "${TEST_DIR}/lib.sh"

Expand Down
2 changes: 1 addition & 1 deletion tests/simple/gk-deploy/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

SCRIPT_DIR=$(cd $(dirname $0); pwd)
SCRIPT_DIR="$(realpath "$(dirname "${0}")")"

echo "running tests in ${SCRIPT_DIR}"

Expand Down
9 changes: 5 additions & 4 deletions tests/simple/gk-deploy/test_gk_deploy_basic.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
SCRIPT_DIR="$(realpath "$(dirname "${0}")")"
STUBS_DIR="${SCRIPT_DIR}/stubs"
TESTS_DIR="${SCRIPT_DIR}/.."
INC_DIR="${TESTS_DIR}/common"
Expand Down Expand Up @@ -56,7 +56,7 @@ test_cli_unknown () {
local cli="${1}"
local expected_out="Unknown CLI '${cli}'."

OUT=$(${GK_DEPLOY} -y -c ${cli} ${TOPOLOGY})
OUT=$("${GK_DEPLOY}" -y -c "${cli}" "${TOPOLOGY}")
local rc=$?

if [[ "x${rc}" == "x0" ]]; then
Expand Down Expand Up @@ -96,7 +96,8 @@ Namespace 'invalid' not found."
args="${args} -c ${cli}"
fi

OUT=$(${GK_DEPLOY} ${args} ${TOPOLOGY})
# shellcheck disable=SC2086
OUT=$("${GK_DEPLOY}" ${args} "${TOPOLOGY}")
local rc=$?

echo "cmd: '${GK_DEPLOY} ${args} ${TOPOLOGY}'"
Expand Down Expand Up @@ -160,4 +161,4 @@ testit "test namespace invalid unknown-cli" \
test_namespace_invalid unknown-cli \
|| ((failed++))

testok $0 ${failed}
testok "${0}" "${failed}"
6 changes: 3 additions & 3 deletions tests/simple/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

SCRIPT_DIR=$(cd $(dirname $0); pwd)
SCRIPT_DIR="$(realpath "$(dirname "${0}")")"

for testdir in ${SCRIPT_DIR}/*; do
if [[ ! -d ${testdir} ]]; then
Expand All @@ -11,9 +11,9 @@ for testdir in ${SCRIPT_DIR}/*; do
continue
fi

pushd ${testdir}
pushd "${testdir}"
./run.sh
rc=$?
rc=${?}
popd

if [[ ${rc} -ne 0 ]]; then
Expand Down
4 changes: 2 additions & 2 deletions tests/simple/yaml/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

SCRIPT_DIR=$(cd $(dirname $0); pwd)
SCRIPT_DIR="$(realpath "$(dirname "${0}")")"

echo "running tests in ${SCRIPT_DIR}"

for test in ${SCRIPT_DIR}/test_*.sh ; do
$test
${test}
done
18 changes: 9 additions & 9 deletions tests/simple/yaml/test_syntax.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
SCRIPT_DIR="$(realpath "$(dirname "${0}")")"
TESTS_DIR="${SCRIPT_DIR}/.."
INC_DIR="${TESTS_DIR}/common"
BASE_DIR="${SCRIPT_DIR}/../../.."
Expand All @@ -12,11 +12,11 @@ source "${INC_DIR}/subunit.sh"

check_yaml () {
local yaml=${1}
yamllint -f parsable -d relaxed ${yaml}
yamllint -f parsable -d relaxed "${yaml}"
}

check_invalid_yaml () {
check_yaml ${1}
check_yaml "${1}"
if [[ "x$?" == "x0" ]]; then
echo "ERROR: parsing invalid yaml succeeded"
return 1
Expand All @@ -32,14 +32,14 @@ if ! which yamllint >/dev/null 2>&1 ; then
subunit_skip_test "yaml syntax tests" <<< "yamllint not found"
else
testit "check invalid yaml" \
check_invalid_yaml ${FAULTY_YAML} \
check_invalid_yaml "${FAULTY_YAML}" \
|| ((failed++))

for yaml in $(find ${DEPLOY_DIR} -name "*.yaml") ; do
testit "check $(basename ${yaml})" \
check_yaml ${yaml} \
while read -r yaml; do
testit "check $(basename "${yaml}")" \
check_yaml "${yaml}" \
|| ((failed++))
done
done <<< "$(find "${DEPLOY_DIR}" -name "*.yaml")"
fi

testok $0 ${failed}
testok "${0}" "${failed}"
8 changes: 4 additions & 4 deletions vagrant/demo/demo-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

DEMO_DIR="$(cd $(dirname $0) ; pwd)"
DEMO_DIR="$(realpath "$(dirname "${0}")")"
VAGRANT_DIR="${DEMO_DIR}/.."

. ${DEMO_DIR}/util.sh
. "${DEMO_DIR}/util.sh"

cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1

desc "show machines"
run "vagrant status"

desc "running demo on master..."
run ""

${DEMO_DIR}/demo-inside-wrapper.sh ${DEMO_DIR}/demo-inside-deploy.sh
"${DEMO_DIR}/demo-inside-wrapper.sh" "${DEMO_DIR}/demo-inside-deploy.sh"
6 changes: 3 additions & 3 deletions vagrant/demo/demo-dynamic-provisioning.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

DEMO_DIR="$(cd $(dirname $0) ; pwd)"
DEMO_DIR="$(realpath "$(dirname "${0}")")"
VAGRANT_DIR="${DEMO_DIR}/.."

cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1

${DEMO_DIR}/demo-inside-wrapper.sh ${DEMO_DIR}/demo-inside-dynamic-provisioning.sh
"${DEMO_DIR}/demo-inside-wrapper.sh" "${DEMO_DIR}/demo-inside-dynamic-provisioning.sh"
2 changes: 1 addition & 1 deletion vagrant/demo/demo-inside-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ run "kubectl get nodes"
desc "show pods"
run "kubectl get pods"

cd deploy
cd deploy || exit 1

desc "look at topology"
run "vim topology.json"
Expand Down
18 changes: 9 additions & 9 deletions vagrant/demo/demo-inside-dynamic-provisioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ run "curl http://$appIP"
run "kubectl exec myapp -- /bin/bash -c \"cat /proc/mounts | grep nginx\""

mountinfo=$(kubectl exec myapp -- /bin/bash -c "cat /proc/mounts | grep nginx" | awk '{print $1}')
volname=$(echo -n $mountinfo | cut -d: -f2)
glusterip=$(echo -n $mountinfo |cut -d: -f1)
glusterpod=$(kubectl get pods -o wide | grep $glusterip | awk '{print $1}')
volname=$(echo -n "${mountinfo}" | cut -d: -f2)
glusterip=$(echo -n "${mountinfo}" |cut -d: -f1)
glusterpod=$(kubectl get pods -o wide | grep "${glusterip}" | awk '{print $1}')

brickinfopath="/var/lib/glusterd/vols/$volname/bricks"
brickinfofile=$(kubectl exec $glusterpod -- /bin/bash -c "ls -1 $brickinfopath | head -n 1")
brickpath=$(kubectl exec $glusterpod -- /bin/bash -c "cat $brickinfopath/$brickinfofile | grep real_path | cut -d= -f2")
brickhost=$(kubectl exec $glusterpod -- /bin/bash -c "cat $brickinfopath/$brickinfofile | grep hostname | cut -d= -f2")
brickpod=$(kubectl get pods -o wide | grep $brickhost | awk '{print $1}')
brickinfopath="/var/lib/glusterd/vols/${volname}/bricks"
brickinfofile=$(kubectl exec "${glusterpod}" -- /bin/bash -c "ls -1 ${brickinfopath} | head -n 1")
brickpath=$(kubectl exec "${glusterpod}" -- /bin/bash -c "cat ${brickinfopath}/${brickinfofile} | grep real_path | cut -d= -f2")
brickhost=$(kubectl exec "${glusterpod}" -- /bin/bash -c "cat ${brickinfopath}/${brickinfofile} | grep hostname | cut -d= -f2")
brickpod=$(kubectl get pods -o wide | grep "${brickhost}" | awk '{print $1}')

run "kubectl exec $brickpod -- /bin/bash -c \"cat $brickpath/index.html\""
run "kubectl exec ${brickpod} -- /bin/bash -c \"cat ${brickpath}/index.html\""

desc "demo-dynamic-provisioning: done"
10 changes: 5 additions & 5 deletions vagrant/demo/demo-inside-test-heketi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
desc "show kubernetes nodes"
run "kubectl get nodes,pods"

cd deploy
cd deploy || exit 1

HEKETI_CLI_SERVER=$(kubectl get svc/heketi --template 'http://{{.spec.clusterIP}}:{{(index .spec.ports 0).port}}')
export HEKETI_CLI_SERVER

desc "test heketi with curl"
run "kubectl get svc/heketi --template 'http://{{.spec.clusterIP}}:{{(index .spec.ports 0).port}}' ; echo"
echo HEKETI_CLI_SERVER: $HEKETI_CLI_SERVER
run "curl $HEKETI_CLI_SERVER/hello ; echo"
echo "HEKETI_CLI_SERVER: ${HEKETI_CLI_SERVER}"
run "curl ${HEKETI_CLI_SERVER}/hello ; echo"

desc "test heketi-cli"
run "heketi-cli cluster list"
Expand All @@ -26,10 +26,10 @@ desc "create a volume"
run "heketi-cli volume create --size=2 | tee volume-create.out"
volumeId=$(grep "Volume Id" volume-create.out | awk '{print $3}')
run "heketi-cli volume list"
run "heketi-cli volume info $volumeId"
run "heketi-cli volume info ${volumeId}"

desc "delete the volume again"
run "heketi-cli volume delete $volumeId"
run "heketi-cli volume delete ${volumeId}"
run "heketi-cli volume list"

desc "demo-test-heketi: done"
10 changes: 5 additions & 5 deletions vagrant/demo/demo-inside-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

DEMO_DIR="$(cd $(dirname $0) ; pwd)"
DEMO_DIR="$(realpath "$(dirname "${0}")")"
VAGRANT_DIR="${DEMO_DIR}/.."
SSH_CONFIG=${DEMO_DIR}/ssh-config

cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1

DEMO=$1

vagrant ssh-config > ${SSH_CONFIG}
vagrant ssh-config > "${SSH_CONFIG}"

scp -F ${SSH_CONFIG} ${DEMO_DIR}/util.sh $DEMO master: >/dev/null 2>&1
ssh -t -F ${SSH_CONFIG} master ./$(basename $DEMO)
scp -F "${SSH_CONFIG}" "${DEMO_DIR}/util.sh" "${DEMO}" master: >/dev/null 2>&1
ssh -t -F "${SSH_CONFIG}" master "./$(basename "${DEMO}")"
14 changes: 7 additions & 7 deletions vagrant/demo/demo-prepare.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash

DEMO_DIR="$(cd $(dirname $0) ; pwd)"
DEMO_DIR="$(realpath "$(dirname "${0}")")"
VAGRANT_DIR="${DEMO_DIR}/.."
DEPLOY_DIR="${VAGRANT_DIR}/../deploy"
SSH_CONFIG=${DEMO_DIR}/ssh-config
SSH_CONFIG="${DEMO_DIR}/ssh-config"

cd ${VAGRANT_DIR}
cd "${VAGRANT_DIR}" || exit 1

vagrant up
./up.sh

vagrant ssh-config > ${SSH_CONFIG}
vagrant ssh-config > "${SSH_CONFIG}"

scp -r -F "${SSH_CONFIG}" "${DEPLOY_DIR}" master:

for NODE in node0 node1 node2 ; do
ssh -t -F ${SSH_CONFIG} $NODE "sudo docker pull gcr.io/google_containers/nginx-slim:0.8"
ssh -t -F "${SSH_CONFIG}" "${NODE}" "sudo docker pull gcr.io/google_containers/nginx-slim:0.8"
done

${DEMO_DIR}/demo-inside-wrapper.sh ${DEMO_DIR}/demo-inside-prepare.sh
"${DEMO_DIR}/demo-inside-wrapper.sh" "${DEMO_DIR}/demo-inside-prepare.sh"
Loading

0 comments on commit f6dd7a7

Please sign in to comment.