Skip to content

Commit 2ced95f

Browse files
authored
Support for 21c in infra/db/atp and example-21c workshop (#307)
* Reorg code * exec perms * Update setup.env * Update setup.env * fix * Update setup.env * Update setup.env * Update setup.sh * Update setup.sh * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * Update destroy.sh * fixes * fixes * fixes * Update destroy.sh * fixes * fixes * fixes * fixes * fixes * fixes * fixes * Update apply.sh * fixes * fixes * fixes * fixes * fixes * Create db-setup.sh * Update java-builds.sh * Update non-java-builds.sh * fixes * fixes * Update apply.env * fixes * fixes * fixes * fixes * fixes * fixes * fixes * Update main-setup.sh * Create database.tf * Update main-setup.sh * fixes * Update undeploy.sh * fixes * k6 change * use msdataworkshop namespace for ingress * Update apply.sh * fixes * Update source.env * fixes * ll * Update apply.sh * status * fixes * fixes * fixes * fixes * fixes * fixes * Update apply.sh * Update apply.sh * fixes * fixes * Update apply.sh * Update requirements.env * Update requirements.env * Update database.tf * fixes * Test1 * test2 * test3 * test4 * test5 * test6 * test7 * test7a * test8 * test8a * test9 * test10 * test10a * Test10b * test11 * test11 * test11a * test12 * test12 * test13 * test13a * test14 * test14a * test14b * test15 * test16 * test16b * test16c * test16d * Test17 * test18 * test1 * test2 * test3 * test4 * test5 * test6 * test7 * test 8 * test9 * test10 * test11 * test12 * test13 * test14 * test15 * test16 * test17 * test20 * test20a * test20b * test21 * test21a * test21b * test21c * test22 * test23 * test24 * test25 * test25a * test25b * test26 * test27 * test28 * test29 * test30 * test31 * test32 * test33 * test34 * test35 * test36 * test37 * test38 * test39 * test40 * test41 * test42 * Update setup.sh * test43 * test44 * Update source.env * PostReview * SQL File Renaming * vault fixes * Update vault-oci-os-functions.env * Update vault-oci-os-functions.env * Update setup.sh * fixes * Update destroy.sh * inventory-helidon observability fix * Update destroy.sh * sql * Update order-object-scripts.sql * 21c * example * example2 * fix * fix * fix * fix * fix * fix * fix and doc * Update apply.sh * Update setup.sh
1 parent 34b52fa commit 2ced95f

File tree

20 files changed

+855
-139
lines changed

20 files changed

+855
-139
lines changed

common/source.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export MSDD_APPS_CODE="$MSDD_CODE"
1414
export MSDD_WORKSHOP_CODE="$MSDD_CODE/workshops"
1515

1616
source $MSDD_CODE/common/utils/provisioning-functions.env
17-
source $MSDD_CODE/common/utils/deploy-functions.env
17+
source $MSDD_CODE/common/utils/deploy-functions.env
18+
source $MSDD_CODE/common/utils/setup-functions.env

common/utils/setup-functions.env

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
6+
if ! (return 0 2>/dev/null); then
7+
echo "ERROR: Usage 'source setup_functions.env'"
8+
return 1
9+
fi
10+
11+
# Request compartment details and create or validate
12+
# Parameters:
13+
# $1: Run Type: LL or OT (required)
14+
# $2: The tenancy OCID (required)
15+
# $3: Home region (required)
16+
# $4: The description text of the compartment if it is created (required)
17+
#
18+
# Input Environment variables:
19+
# TEST_COMPARTMENT: Compartment name or OCID to use (otional)
20+
# TEST_PARENT_COMPARTMENT_OCID: Parent compartment OCID (optional)
21+
#
22+
# Output Environment variables:
23+
# COMPARTMENT_OCID: Returned compartment OCID
24+
#
25+
function compartment-dialog() {
26+
set -u
27+
COMPARTMENT_OCID='' # Updated in calling shell, not local
28+
local COMP
29+
local PARENT_COMP
30+
local RUN_TYPE="$1"
31+
local TENANCY_OCID="$2"
32+
local HOME_REGION="$3"
33+
local COMP_DESC="$4"
34+
35+
while test -z "$COMPARTMENT_OCID"; do
36+
if test "$RUN_TYPE" == 'LL'; then
37+
# The compartment is already created. Ask for the OCID
38+
read -p "Please enter your OCI compartment's OCID: " COMP
39+
if ! oci iam compartment get --compartment-id "$COMP" 2>&1 >~/comp_ocid_err; then
40+
echo "ERROR: The compartment $COMP does not exist. Please retry."
41+
cat ~/comp_ocid_err
42+
rm ~/comp_ocid_err
43+
continue
44+
else
45+
rm ~/comp_ocid_err
46+
COMPARTMENT_OCID="$COMP"
47+
break
48+
fi
49+
fi
50+
51+
if ! test -z "${TEST_COMPARTMENT-}"; then
52+
COMP="$TEST_COMPARTMENT"
53+
else
54+
echo 'Please enter the OCI compartment where you would like the workshop resources to be created.'
55+
echo 'For an existing compartment, enter the OCID. For a new compartment, enter the name.'
56+
read -p "Please specify the compartment: " COMP
57+
fi
58+
59+
if test -z "$COMP"; then
60+
echo "ERROR: No compartment specified"
61+
continue
62+
fi
63+
64+
if [[ "$COMP" =~ ocid1.* ]]; then
65+
# An existing compartment
66+
if ! oci iam compartment get --compartment-id "$COMP" 2>&1 >~/comp_ocid_err; then
67+
echo "ERROR: The compartment $COMP does not exist. Please retry."
68+
cat ~/comp_ocid_err
69+
rm ~/comp_ocid_err
70+
if ! test -z "${TEST_COMPARTMENT-}"; then
71+
return 1
72+
fi
73+
continue
74+
else
75+
rm ~/comp_ocid_err
76+
COMPARTMENT_OCID="$COMP"
77+
break
78+
fi
79+
fi
80+
81+
# New compartment
82+
if ! test -z "${TEST_PARENT_COMPARTMENT_OCID-}"; then
83+
PARENT_COMP="$TEST_PARENT_COMPARTMENT_OCID"
84+
else
85+
echo 'Please enter the OCID of the compartment in which you would like the new compartment to be created.'
86+
read -p "Please specify the parent compartment OCID (hit return for the root compartment): " PARENT_COMP
87+
if [[ ! "$PARENT_COMP" =~ ocid1.* ]]; then
88+
PARENT_COMP="$TENANCY_OCID"
89+
fi
90+
fi
91+
92+
COMPARTMENT_OCID=`oci iam compartment create --region "$HOME_REGION" --compartment-id "$PARENT_COMP" --name "$COMP" --description "$COMP_DESC" --query 'data.id' --raw-output`
93+
done
94+
95+
# Wait for the compartment to become active
96+
while ! test `oci iam compartment get --compartment-id "$COMPARTMENT_OCID" --query 'data."lifecycle-state"' --raw-output 2>/dev/null`"" == 'ACTIVE'; do
97+
echo "Waiting for the compartment to become ACTIVE"
98+
sleep 5
99+
done
100+
return 0
101+
}
102+
export -f compartment-dialog
103+
104+
105+
# Setup the state store
106+
# Parameters:
107+
# $1: Full hierarchical name of the state store folder (required)
108+
# $2: Log file (required)
109+
#
110+
# Output:
111+
# Exported state functions
112+
#
113+
function state-store-setup () {
114+
set -u
115+
local STATE_STORE_FOLDER="$1"
116+
local STATE_STORE_LOG="$2"
117+
local STATE_STORE_STATUS
118+
119+
if ! STATE_STORE_STATUS=$(provisioning-get-status $STATE_STORE_FOLDER); then
120+
echo "ERROR: Unable to get workshop state store status"
121+
return 1
122+
fi
123+
124+
case "$STATE_STORE_STATUS" in
125+
126+
applied | byo)
127+
# Nothing to do
128+
;;
129+
130+
applying)
131+
# Setup already running so exit
132+
echo "ERROR: Setup is already running and so cannot run setup"
133+
return 1
134+
;;
135+
136+
destroying-failed | destroying | destroyed)
137+
# Cannot setup during destroy phase
138+
echo "ERROR: Destroy is running and so cannot run setup"
139+
return 1
140+
;;
141+
142+
applying-failed | new)
143+
# Start or restart the state_store setup
144+
cd $STATE_STORE_FOLDER
145+
echo "STATE_LOG='$STATE_STORE_LOG'" > $STATE_STORE_FOLDER/input.env
146+
if ! provisioning-apply $MSDD_INFRA_CODE/state_store; then
147+
echo "ERROR: Failed to create state_store in $STATE_STORE_FOLDER"
148+
return 1
149+
fi
150+
;;
151+
152+
esac
153+
source $STATE_STORE_FOLDER/output.env
154+
return 0
155+
}
156+
export -f state-store-setup
157+
158+
159+
# Setup folder based vault
160+
# Parameters:
161+
# $1: Full hierarchical name of the vault state folder (required)
162+
# Output:
163+
# Exported vault functions
164+
#
165+
function folder-vault-setup () {
166+
set -u
167+
local VAULT_STATE_FOLDER="$1"
168+
local VAULT_STATUS
169+
170+
if ! VAULT_STATUS=$(provisioning-get-status "$VAULT_STATE_FOLDER"); then
171+
echo "ERROR: Unable to get workshop vault status"
172+
return 1
173+
fi
174+
175+
case "$VAULT_STATUS" in
176+
177+
applied | byo)
178+
# No setup to do
179+
;;
180+
181+
applying)
182+
# Setup already running so exit
183+
echo "ERROR: Setup is already running and so cannot run setup"
184+
return 1
185+
;;
186+
187+
destroying-failed | destroying | destroyed)
188+
# Cannot setup during destroy phase
189+
echo "ERROR: Destroy is running and so cannot run setup"
190+
return 1
191+
;;
192+
193+
applying-failed | new)
194+
# Start or restart the vault setup
195+
cd $VAULT_STATE_FOLDER
196+
if ! provisioning-apply $MSDD_INFRA_CODE/vault/folder; then
197+
echo "ERROR: Failed to create vault in $VAULT_STATE_FOLDER"
198+
return 1
199+
fi
200+
;;
201+
202+
esac
203+
source $VAULT_STATE_FOLDER/output.env
204+
}
205+
export -f folder-vault-setup
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Copyright (c) 2021 Oracle and/or its affiliates.
2+
-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
5+
WHENEVER SQLERROR EXIT 1
6+
connect $ORDER_USER/"$ORDER_PASSWORD"@$DB1_ALIAS
7+
8+
@$COMMON_SCRIPT_HOME/order-object-scripts.sql
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Copyright (c) 2021 Oracle and/or its affiliates.
2+
-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
5+
WHENEVER SQLERROR EXIT 1
6+
connect $ORDER_USER/"$ORDER_PASSWORD"@$DB1_ALIAS
7+
8+
@$COMMON_SCRIPT_HOME/order-object-scripts.sql
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Copyright (c) 2021 Oracle and/or its affiliates.
2+
-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
5+
WHENEVER SQLERROR EXIT 1
6+
connect $ORDER_USER/"$ORDER_PASSWORD"@$DB1_ALIAS
7+
8+
@$COMMON_SCRIPT_HOME/order-object-scripts.sql

0 commit comments

Comments
 (0)