Skip to content

Commit

Permalink
error testing
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <[email protected]>
  • Loading branch information
Doug Davis committed Mar 16, 2021
1 parent 6cb9a7a commit c8e2ac1
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 20 deletions.
3 changes: 2 additions & 1 deletion app-n-job/run
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ ibmcloud ce app create -n anj-app --image ${REGISTRY}/app-n-job
URL=$(ibmcloud ce app get -n anj-app -o url)

# And call it
curl -Ls $URL | tee out
curl -fs $URL | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

if ! grep "Hello from.*app" out > /dev/null ; then
echo "Unexpected output"
Expand Down
3 changes: 2 additions & 1 deletion app2job/run
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ URL=$(ibmcloud ce app get -n a2j-app -o url)
ibmcloud ce job create -n a2j-job --ai=1-${COUNT} --image ${REGISTRY}/a2j-job

# Now, curl the app and see if it creates the job
curl -s ${URL}/a2j-job -X PUT | tee out
curl -fs ${URL}/a2j-job -X PUT | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
jobrun=$(cat out)

while ! ibmcloud ce jobrun get -n ${jobrun} | grep "Succeeded.*${COUNT}" ; do
Expand Down
5 changes: 5 additions & 0 deletions bin/run-all
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ for file in `find . -name run | sort` ; do (

# Run the sample with whatever REGISTRY we're pointing to
./run "$@"
rc=$?
if [[ "$rc" != "0" ]]; then
echo exit: $rc
exit $rc
fi

) done

Expand Down
3 changes: 2 additions & 1 deletion bind-app/run
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ URL=$(ibmcloud ce app get -n ba-app -o url)
ibmcloud ce app bind --name ba-app --service-instance ba-db

# Curl the app to make sure it had the creds
curl -Ls ${URL} | tee out
curl -fs ${URL} | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

if ! grep VCAP_SERVICES out > /dev/null ; then
echo "Missing VCAP_SERVICES in App's env vars"
Expand Down
3 changes: 2 additions & 1 deletion cecli/run
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ibmcloud ce app create -n lister --image $REGISTRY/cecli \
APP=$(ibmcloud ce app get -n lister -o url)

# Call the app - if it works it should return the output of the 'app list' cmd
curl -s $APP/list | tee out
curl -fs $APP/list | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

# Verify we see our App in the output
grep "^lister " out
Expand Down
3 changes: 2 additions & 1 deletion configmaps-env/run
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ ibmcloud ce app create -n cm-app-env --image ${REGISTRY}/ce-config-env \
URL=$(ibmcloud ce app get -n cm-app-env -o url)

# Just force it to log something by hitting it
curl -Ls $URL
curl -fs $URL

# Now check the logs to see if the env vars were set
ibmcloud ce app logs -n cm-app-env | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
grep MY_ out
if ! [[ $(grep MY_ out | wc -l) == "4" ]]; then
echo "Unexpected output"
Expand Down
3 changes: 2 additions & 1 deletion configmaps-vol/run
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ ibmcloud ce app create -n cm-app-vol --image ${REGISTRY}/ce-config-vol \
URL=$(ibmcloud ce app get -n cm-app-vol -o url)

# Just force it to log something by hitting it
curl -Ls $URL
curl -fs $URL

# Now check the logs to see if the env vars were set
ibmcloud ce app logs -n cm-app-vol | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
grep MY_ out
if ! [[ $(grep MY_ out | wc -l) == "4" ]]; then
echo "Unexpected output"
Expand Down
2 changes: 1 addition & 1 deletion cos-event/run
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cat out
echo "=============="
echo "Event stats:"

curl -Ls ${URL}/stats
curl -fs ${URL}/stats

# Clean up
clean
5 changes: 3 additions & 2 deletions hello/run
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ ibmcloud ce app create -n hello --image ${REGISTRY}/hello
URL=$(ibmcloud ce app get -n hello -o url)

# Now call it
curl -Ls $URL
curl -fs $URL | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

if ! [[ "$(curl -Ls $URL)" == "Hello World" ]]; then
if ! [[ "$(cat out)" == "Hello World" ]]; then
echo "Unexpected output"
exit 1
fi
Expand Down
5 changes: 3 additions & 2 deletions helloworld/run
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ ibmcloud ce app create -n helloworld --image ${REGISTRY}/helloworld
URL=$(ibmcloud ce app get -n helloworld -o url)

# Now call it
curl -Ls $URL
curl -fs $URL | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

if ! [[ "$(curl -Ls ${URL} --post301 -d "Hi")" == "Hi" ]]; then
if ! [[ "$(curl -fs ${URL} -d "Hi")" == "Hi" ]]; then
echo "Unexpected output"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion job2app/run
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ibmcloud ce jobrun submit -n j2a-job --ai=1-${COUNT} \
--image ${REGISTRY}/j2a-job --wait

# Check the app to see how many times it was hit
if ! [[ "Count: $((COUNT*10))" == "$(curl -Ls $URL)" ]]; then
if ! [[ "Count: $((COUNT*10))" == "$(curl -fs $URL)" ]]; then
echo "Should be $((COUNT*10))"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion private/run
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ibmcloud ce app create -n frontend --image ${REGISTRY}/priv-front
URL=$(ibmcloud ce app get -n frontend -o url)

# Now call it (stop if curl fails)
curl -f -Ls $URL | tee out
curl -fs $URL | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

# Verify the frontend got the right output from the backend
Expand Down
3 changes: 2 additions & 1 deletion s2i-buildpacks/run
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ ibmcloud ce buildrun submit -n s2i-brun --build s2i-bbuild --wait
# Test the image we just built - deploy an app and 'curl' it
ibmcloud ce app create -n s2i-bapp --image "us.icr.io/${ICR_NS}/app" --rs s2i-bicr
URL=$(ibmcloud ce app get -n s2i-bapp -o url)
curl -Ls "${URL}" | tee out
curl -fs "${URL}" | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

if ! grep "I was built" out > /dev/null ; then
echo "Missing expected outout"
Expand Down
3 changes: 2 additions & 1 deletion s2i-dockerfile/run
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ ibmcloud ce buildrun submit -n s2i-drun --build s2i-dbuild --wait
# Test the image we just built - deploy an app and 'curl' it
ibmcloud ce app create -n s2i-dockerfile --image "us.icr.io/${ICR_NS}/app" --rs s2i-dicr
URL=$(ibmcloud ce app get -n s2i-dockerfile -o url)
curl -Ls "${URL}" | tee out
curl -fs "${URL}" | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]

if ! grep "I was built" out > /dev/null ; then
echo "Missing expected outout"
Expand Down
2 changes: 1 addition & 1 deletion secrets-env/run
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ibmcloud ce app create -n sec-app-env --image ${REGISTRY}/ce-secret-env \
URL=$(ibmcloud ce app get -n sec-app-env -o url)

# Just force it to log something by hitting it
curl -Ls $URL
curl -fs $URL

# Extract the instance name from `ibmcloud ce app get`
name=$(ibmcloud ce app get -n sec-app-env | awk '/sec-app-env.*Running/{ print $1 }')
Expand Down
2 changes: 1 addition & 1 deletion secrets-vol/run
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ibmcloud ce app create -n sec-app-vol --image ${REGISTRY}/ce-secret-vol \
URL=$(ibmcloud ce app get -n sec-app-vol -o url)

# Just force it to log something by hitting it
curl -Ls $URL
curl -fs $URL

# Extract the instance name from `ibmcloud ce app get`
name=$(ibmcloud ce app get -n sec-app-vol | awk '/sec-app-vol.*Running/{ print $1 }')
Expand Down
6 changes: 3 additions & 3 deletions sessions/run
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ ibmcloud ce app create -n session-app -i ${REGISTRY}/sessions -e IP=$IP --cn=5 -
URL=$(ibmcloud ce app get -n session-app -o url)

# Now call the app to make sure it works
curl -Ls $URL
curl -fs $URL

# Now call it 98 more times in parallel. Notice the hostname changes
set +x
for i in `seq 1 98` ; do
curl -Ls $URL &
curl -fs $URL &
done
wait
set -x

# Verify the app was hit 100 times total
if ! [[ "$(curl -Ls $URL)" == "Counter: 100 "* ]]; then
if ! [[ "$(curl -fs $URL)" == "Counter: 100 "* ]]; then
echo "Unexpected output - should have started with 'Counter: 100'"
exit 1
fi
Expand Down

0 comments on commit c8e2ac1

Please sign in to comment.