Skip to content

Commit 55b75dc

Browse files
committed
Add interactive mode to demo.sh and test folder
1 parent f7f0465 commit 55b75dc

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,4 @@ JAEGER_GRPC_PORT=4317
177177
PROMETHEUS_PORT=9090
178178
PROMETHEUS_HOST=prometheus
179179
PROMETHEUS_ADDR=${PROMETHEUS_HOST}:${PROMETHEUS_PORT}
180+
BASHUNIT_BOOTSTRAP=test/elastic/bootstrap.sh

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ test/tracetesting/tracetesting-vars.yaml
5353
*.apk
5454

5555
!src/currency/build
56+
57+
#Bash unit
58+
lib/

demo.sh

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,39 @@ elasticsearch_endpoint=""
3333
elasticsearch_api_key=""
3434

3535
usage() {
36-
echo "Usage: $0 [cloud-hosted|serverless] [docker|k8s] | destroy [docker|k8s]"
36+
echo "Run the script with no arguments. This will start an interactive prompt that will guide you through the setup of the Elastic OpenTelemetry Demo."
37+
echo
38+
echo "To destroy the demo, run: $0 destroy [docker|k8s]"
39+
echo " - pass 'docker' or 'k8s' to destroy only that platform"
40+
echo " - omit the platform to destroy both docker and k8s resources"
3741
exit 1
3842
}
3943

4044
parse_args() {
4145
if [ $# -eq 0 ]; then
42-
usage
46+
47+
while true; do
48+
echo
49+
printf "❓ Which Elasticsearch deployment type do you want to send the data into? [serverless/cloud-hosted]? "
50+
read -r deployment_type
51+
deployment_type=${deployment_type}
52+
case "$deployment_type" in
53+
cloud-hosted|serverless) break ;;
54+
*) echo "Please enter 'cloud-hosted' or 'serverless'." ;;
55+
esac
56+
done
57+
58+
while true; do
59+
echo
60+
printf "❓ In which environment the demo should be deployed? [docker/k8s]?"
61+
read -r platform
62+
platform=${platform}
63+
case "$platform" in
64+
docker|k8s) break ;;
65+
*) echo "Please enter 'docker' or 'k8s'." ;;
66+
esac
67+
done
68+
return
4369
fi
4470

4571
if [ "$1" = "destroy" ]; then
@@ -49,11 +75,7 @@ parse_args() {
4975
fi
5076
return
5177
fi
52-
53-
deployment_type="$1"
54-
if [ $# -ge 2 ]; then
55-
platform="$2"
56-
fi
78+
usage
5779
}
5880

5981
update_env_var() {
@@ -190,12 +212,12 @@ destroy_k8s() {
190212
}
191213

192214
main() {
193-
parse_args "$@"
194-
195215
echo '----------------------------------------------------'
196216
echo '🚀 OpenTelemetry Demo with Elastic Observability'
197217
echo '----------------------------------------------------'
198218

219+
parse_args "$@"
220+
199221
if [ "$destroy" = "true" ]; then
200222
if [ -z "$platform" ]; then
201223
echo "⌛️ Destroying Docker and Kubernetes resources..."
@@ -222,14 +244,7 @@ main() {
222244
usage
223245
fi
224246

225-
if [ "$deployment_type" != "cloud-hosted" ] && [ "$deployment_type" != "serverless" ]; then
226-
usage
227-
fi
228-
229-
if [ "$platform" != "docker" ] && [ "$platform" != "k8s" ]; then
230-
usage
231-
fi
232-
247+
echo
233248
echo "⌛️ Starting OTel Demo + EDOT on '$platform' → Elastic ($deployment_type)..."
234249
echo
235250
if [ "$platform" = "docker" ]; then

test/elastic/bootstrap.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
# Place your common test setup here

test/elastic/example_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
function test_bashunit_is_installed() {
4+
assert_same "bashunit is installed" "bashunit is installed"
5+
}

0 commit comments

Comments
 (0)