Skip to content

Commit 3166fb7

Browse files
authored
Fix issue 484: fail to create sink connector if issue wrong DB password #484 (#485)
* add user/pass validation in setup script * add user/pass validation in setup script * fix script kafka bug * fix script return to exit code
1 parent bfdc54c commit 3166fb7

File tree

5 files changed

+81
-43
lines changed

5 files changed

+81
-43
lines changed

workshops/txeventq-kafka/cloud-setup/cmd/txeventq-add-topic

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ TXEVENTQ_SUBSCRIBER=${TXEVENTQ_TOPIC}_SUBS
4848
# DB Connection Setup
4949
export TNS_ADMIN=$LAB_HOME/wallet
5050

51+
# Validate User/Password
52+
user_is_valid=$(sqlplus -S /nolog <<!
53+
connect $LAB_DB_USER/"$ORACLE_DB_PASSWORD"@$LAB_DB_SVC
54+
!
55+
)
56+
57+
if [[ "$user_is_valid" == *"ORA-01017"* ]]; then
58+
echo "ERROR: invalid username/password."
59+
exit 2
60+
fi
61+
5162
# Add TxEventQ Topic
5263
VAR=$(sqlplus -S /nolog <<!
5364
connect $LAB_DB_USER/"$ORACLE_DB_PASSWORD"@$LAB_DB_SVC
@@ -58,6 +69,7 @@ VAR=$(sqlplus -S /nolog <<!
5869
!
5970
)
6071

72+
6173
if [[ "$VAR" == *"PL/SQL procedure successfully"* ]]; then
6274
echo "Created topic ${TXEVENTQ_TOPIC}"
6375
state_set TXEVENTQ_TOPIC_NAME "${TXEVENTQ_TOPIC}"

workshops/txeventq-kafka/cloud-setup/cmd/txeventq-dequeue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ TXEVENTQ_SUBSCRIBER=${TXEVENTQ_TOPIC}_SUBS
4040
# DB Connection Setup
4141
export TNS_ADMIN=$LAB_HOME/wallet
4242

43+
# Validate User/Password
44+
user_is_valid=$(sqlplus -S /nolog <<!
45+
connect $LAB_DB_USER/"$ORACLE_DB_PASSWORD"@$LAB_DB_SVC
46+
!
47+
)
48+
49+
if [[ "$user_is_valid" == *"ORA-01017"* ]]; then
50+
echo "ERROR: invalid username/password."
51+
exit 2
52+
fi
53+
4354
# DEQUEUE TxEventQ Message
4455
sqlplus -S /nolog <<!
4556
connect $LAB_DB_USER/"$ORACLE_DB_PASSWORD"@$LAB_DB_SVC

workshops/txeventq-kafka/cloud-setup/confluent-kafka/kafka-setup.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ while ! state_done KAFKA_SETUP; do
3838
cd "$LAB_HOME"/cloud-setup/confluent-kafka
3939
./docker-compose up --no-start
4040

41-
cd "$LAB_HOME"
42-
state_set_done KAFKA_SETUP
43-
done
44-
45-
if state_get KAFKA_SETUP; then
4641
echo "$(date): Create Containers Network"
4742
LAB_KAFKA_NETWORK="$(state_get RUN_NAME)_net"
4843
docker network create "${LAB_KAFKA_NETWORK}"
4944
state_set LAB_KAFKA_NETWORK "$LAB_KAFKA_NETWORK"
50-
fi
45+
46+
cd "$LAB_HOME"
47+
state_set_done KAFKA_SETUP
48+
done
49+
50+
#if state_get KAFKA_SETUP; then
51+
# echo "$(date): Create Containers Network"
52+
# LAB_KAFKA_NETWORK="$(state_get RUN_NAME)_net"
53+
# docker network create "${LAB_KAFKA_NETWORK}"
54+
# state_set LAB_KAFKA_NETWORK "$LAB_KAFKA_NETWORK"
55+
#fi
5156

5257

workshops/txeventq-kafka/cloud-setup/utils/main-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ while ! state_done SETUP_VERIFIED; do
301301
if test "$NOT_DONE" -gt 0; then
302302
# echo "Log files are located in $LAB_LOG"
303303
bgs=$bg_not_done
304-
echo -ne r"\033[2K\r$bgs still running "
304+
echo -ne r"\033[2K\r$bgs still executing... \n"
305305
sleep 10
306306
else
307307
state_set_done SETUP_VERIFIED

workshops/txeventq-kafka/kafka-connect-txeventq/setup-kafka2txeventq-connect.sh

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,71 @@ set -e
77

88
CONF_FILE="${LAB_HOME}"/kafka-connect-txeventq/kafka2txeventq-connect-configuration.json
99

10-
# Collect the DB password
11-
read -s -r -p "Please enter Oracle DB Password: " ORACLE_DB_PASSWORD
12-
#seq -f "*" -s '' -t '\n' "${#ORACLE_DB_PASSWORD}"
13-
14-
# Collect the Kafka Topic to be consumed by Connect
15-
# read -r -p "Please enter Kafka Topic: " KAFKA_TOPIC
16-
17-
# Collect the KAFKA Topic (Source)
18-
if state_get KAFKA_TOPIC_NAME; then
19-
KAFKA_TOPIC="$(state_get KAFKA_TOPIC_NAME)"
20-
21-
# Set the KAFKA TOPIC produced by Connect sync
22-
sed -i 's/LAB_KAFKA_TOPIC/'"${KAFKA_TOPIC}"'/g' "$CONF_FILE"
10+
# Collect Oracle Database Service
11+
if state_done LAB_DB_NAME; then
12+
LAB_DB_SVC="$(state_get LAB_DB_NAME)_tp"
2313
else
24-
echo "ERROR: KAFKA Topic is missing!"
25-
exit
14+
echo "ERROR: Oracle DB Service is missing!"
15+
exit 2
2616
fi
2717

28-
2918
# Collect the DB USER
30-
if state_get LAB_DB_USER; then
19+
if state_done LAB_DB_USER; then
3120
LAB_DB_USER="$(state_get LAB_DB_USER)"
32-
33-
# Set the Oracle Database User used by Connect Sync
34-
sed -i 's/LAB_DB_USER/'"${LAB_DB_USER}"'/g' "$CONF_FILE"
3521
else
3622
echo "ERROR: Oracle DB user is missing!"
37-
exit
38-
fi
39-
40-
# Collect Oracle Database Service
41-
if state_get LAB_DB_NAME; then
42-
LAB_DB_SVC="$(state_get LAB_DB_NAME)_tp"
43-
44-
# Set the Oracle Database URL used by Connect Sync
45-
sed -i 's/LAB_DB_SVC/'"${LAB_DB_SVC}"'/g' "$CONF_FILE"
46-
else
47-
echo "ERROR: Oracle DB Service is missing!"
48-
exit
23+
exit 2
4924
fi
5025

5126
# Collect the Oracle TxEventQ Topic (Destination)
5227
if state_get TXEVENTQ_TOPIC_NAME; then
5328
TXEVENTQ_TOPIC="$(state_get TXEVENTQ_TOPIC_NAME)"
54-
55-
# Set the Oracle TxEventQ TOPIC produced by Connect sync
56-
sed -i 's/LAB_TXEVENTQ_TOPIC/'"${TXEVENTQ_TOPIC}"'/g' "$CONF_FILE"
5729
else
5830
echo "ERROR: Oracle TxEventQ Topic is missing!"
59-
exit
31+
exit 2
32+
fi
33+
34+
# Collect the KAFKA Topic (Source)
35+
if state_get KAFKA_TOPIC_NAME; then
36+
KAFKA_TOPIC="$(state_get KAFKA_TOPIC_NAME)"
37+
else
38+
echo "ERROR: KAFKA Topic is missing!"
39+
exit 2
40+
fi
41+
42+
# Collect the DB password
43+
read -s -r -p "Please enter Oracle DB Password: " ORACLE_DB_PASSWORD
44+
echo "***********"
45+
46+
# DB Connection Setup
47+
export TNS_ADMIN=$LAB_HOME/wallet
48+
49+
# Validate User/Password
50+
user_is_valid=$(sqlplus -S /nolog <<!
51+
connect $LAB_DB_USER/"$ORACLE_DB_PASSWORD"@$LAB_DB_SVC
52+
!
53+
)
54+
55+
if [[ "$user_is_valid" == *"ORA-01017"* ]]; then
56+
echo "ERROR: invalid username/password."
57+
exit 2
6058
fi
6159

60+
# Set the KAFKA TOPIC produced by Connect sync
61+
sed -i 's/LAB_KAFKA_TOPIC/'"${KAFKA_TOPIC}"'/g' "$CONF_FILE"
62+
63+
# Set the Oracle Database User used by Connect Sync
64+
sed -i 's/LAB_DB_USER/'"${LAB_DB_USER}"'/g' "$CONF_FILE"
65+
6266
# Setup the Oracle DB User Password
6367
sed -i 's/LAB_DB_PASSWORD/'"${ORACLE_DB_PASSWORD}"'/g' "$CONF_FILE"
6468

69+
# Set the Oracle Database URL used by Connect Sync
70+
sed -i 's/LAB_DB_SVC/'"${LAB_DB_SVC}"'/g' "$CONF_FILE"
71+
72+
# Set the Oracle TxEventQ TOPIC produced by Connect sync
73+
sed -i 's/LAB_TXEVENTQ_TOPIC/'"${TXEVENTQ_TOPIC}"'/g' "$CONF_FILE"
74+
6575
# Configure the Kafka Connect Sync with Oracle Database
6676
curl -S -s -o /dev/null \
6777
-i -X PUT -H "Accept:application/json" \

0 commit comments

Comments
 (0)