Skip to content

Commit

Permalink
script fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
markdboyd committed Jun 13, 2022
1 parent af2ddf1 commit 290ceee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
11 changes: 5 additions & 6 deletions ci/init-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

set -euo pipefail
shopt -s inherit_errexit || true

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

function cleanup() {
[[ -n "${ssh_pid:-}" ]] && kill ${ssh_pid}
rm ${cookie_jar}
[[ -n "${ssh_pid:-}" ]] && kill "${ssh_pid}"
}
trap cleanup exit

cf api ${CF_API_URL}
cf api "${CF_API_URL}"
cf auth
cf t -o ${CF_ORGANIZATION} -s ${CF_SPACE}
cf t -o "${CF_ORGANIZATION}" -s "${CF_SPACE}"

echo "Creating SSH tunnel"
cf ssh -L 9200:odfe-test.apps.internal:9200 -L 5601:kbn-test.apps.internal:5601 kibana -N &
Expand All @@ -21,4 +20,4 @@ ssh_pid=$!
echo "Waiting for tunnel to come up ..."
sleep 10

./seed-es-data.sh
bash "${dir}/seed-es-data.sh"
23 changes: 14 additions & 9 deletions ci/seed-es-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
set -euo pipefail
shopt -s inherit_errexit || true

function cleanup() {
rm "${cookie_jar}"
}
trap cleanup exit

cookie_jar=$(mktemp)

# we have to create index and component templates
# to work around the baked-in stream templates
echo "creating component template"
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X PUT \
-H "content-type: application/json" \
https://localhost:9200/_component_template/ct_apps \
Expand Down Expand Up @@ -39,7 +44,7 @@ curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
}' | jq

echo "Creating index template"
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X PUT \
-H "content-type: application/json" \
https://localhost:9200/_index_template/it_apps \
Expand All @@ -50,7 +55,7 @@ curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
}' | jq

echo "Creating index"
curl --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X PUT \
-H "content-type: application/json" \
https://localhost:9200/logs-app-now \
Expand Down Expand Up @@ -116,7 +121,7 @@ echo "creating test document 1/5"
# It doesn't seem to make the docs available otherwise
# We could probably just do this on the last doc we index, but doing
# it on all of them makes it easier to modify the script
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X POST \
-H "content-type: application/json" \
https://localhost:9200/logs-app-now/_doc?refresh=true \
Expand All @@ -132,7 +137,7 @@ curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
# user 2 should be able to see this log
# user 3 should be able to see this log
echo "creating test document 2/5"
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X POST \
-H "content-type: application/json" \
https://localhost:9200/logs-app-now/_doc?refresh=true \
Expand All @@ -146,7 +151,7 @@ curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \

# none of the users should be able to see this log
echo "creating test document 3/5"
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X POST \
-H "content-type: application/json" \
https://localhost:9200/logs-app-now/_doc?refresh=true \
Expand All @@ -159,7 +164,7 @@ curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
# user 2 should not be able to see it
# user 3 should be able to see this log
echo "creating test document 4/5"
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X POST \
-H "content-type: application/json" \
https://localhost:9200/logs-app-now/_doc?refresh=true \
Expand All @@ -173,7 +178,7 @@ curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
# user 2 should be able to see this log
# user 3 should be able to see this log
echo "creating test document 5/5"
curl --fail --silent --show-error -u ${ES_USER}:${ES_PASSWORD} -k \
curl --fail --silent --show-error -u "${ES_USER}":"${ES_PASSWORD}" -k \
-X POST \
-H "content-type: application/json" \
https://localhost:9200/logs-app-now/_doc?refresh=true \
Expand Down Expand Up @@ -204,7 +209,7 @@ curl --fail --silent --show-error --cookie-jar ${cookie_jar} -b ${cookie_jar} \
-H 'x-forwarded-for: 127.0.0.1' \
-H "kbn-version: 7.10.0" \
http://localhost:5601/api/v1/multitenancy/tenant \
-d '{"tenant":"","username":"'${ES_USER}'"}'
-d '{"tenant":"","username":"'"${ES_USER}"'"}'

echo "Creating index pattern"
curl --fail --silent --show-error --cookie-jar ${cookie_jar} -b ${cookie_jar} \
Expand Down

0 comments on commit 290ceee

Please sign in to comment.