Skip to content

Commit 65387c4

Browse files
vitalykorolevVitaly Korolev
and
Vitaly Korolev
authoredMay 31, 2022
Feature/CLD-484 (#87) (#89)
* Fixed PR template * Updated copyright year * reformat and add conditional init * format shell script * Squashed commit of the following: commit 3b78c9b Author: Vitaly <vitaly.korolev@gmail.com> Date: Wed May 18 15:24:55 2022 -0700 Rename yml files to yaml (#83) (#84) Co-authored-by: Vitaly Korolev <vkorolev@marklogic.com> Co-authored-by: Vitaly Korolev <vkorolev@marklogic.com> commit 1e6c239 Author: Vitaly <vitaly.korolev@gmail.com> Date: Wed May 18 10:03:11 2022 -0700 Feature/CLD-420 (#81) (#82) * Replace all instances of yml with yaml * Fix docker test cases * Increase wait and add port to report output * add -s to curl and remove secrets processing * Strict condition checks & bash style improvements * Adding test cases for uncoupled cluster * Additional shellCheck fixes * move checkpoint file creation to the end Co-authored-by: Vitaly Korolev <vkorolev@marklogic.com> Co-authored-by: Vitaly Korolev <vkorolev@marklogic.com>
1 parent 3b78c9b commit 65387c4

11 files changed

+314
-134
lines changed
 

‎.github/PULL_REQUEST_TEMPLATE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
- ##### Owner:
66

7-
- [ ] JIRA_ID as part of branch name
7+
- [ ] JIRA_ID as part of branch/PR name
88
- [ ] Rebase the branch with upstream
99
- [ ] Squashed all commits into a single commit
1010
- [ ] Added Tests
1111

1212
- ##### Reviewer:
1313

1414
- [ ] Reviewed Tests
15-
- [ ] Added to Release Wiki
15+
- [ ] Added to Release Wiki/Jira

‎Jenkinsfile

+6-7
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,15 @@ def DockerRunTests() {
216216
def defaultParams='-it -d -p 8000:8000 -p 8001:8001 -p 8002:8002 -p7997:7997'
217217
def curlCommand='curl -sL'
218218
def curlCommandAuth='curl -sL --anyauth -u test_admin:test_admin_pass'
219-
def composePath='./docker-compose/'
220219
def jUnitReport = "docker-test-results.xml"
221220
def testCases = readJSON file: './test/docker-test-cases.json'
222221

223222
//validate JSON data
224223
assert testCases instanceof Map
225224

226225
//create credential files for compose
227-
writeFile(file: "${composePath}mldb_admin_username.txt", text: "test_admin")
228-
writeFile(file: "${composePath}mldb_admin_password.txt", text: "test_admin_pass")
226+
writeFile(file: "./docker-compose/mldb_admin_username.txt", text: "test_admin")
227+
writeFile(file: "./docker-compose/mldb_admin_password.txt", text: "test_admin_pass")
229228

230229
def testResults = ''
231230
def totalTests = 0
@@ -241,11 +240,11 @@ def DockerRunTests() {
241240
// if .yaml config is provided in params, start compose. otherwise docker run is used
242241
if ( value.params.toString().contains(".yaml")) {
243242
//update image label in yaml file
244-
composeFile = readFile(composePath + value.params)
243+
composeFile = readFile(value.params)
245244
composeFile = composeFile.replaceFirst(/image: .*/, "image: "+testImage)
246-
writeFile( file: composePath + value.params, text: composeFile)
245+
writeFile( file: value.params, text: composeFile)
247246
// start docker compose
248-
sh( returnStdout: true, script: "docker compose -f ${composePath}${value.params} up -d" )
247+
sh( returnStdout: true, script: "docker compose -f ${value.params} up -d" )
249248
} else {
250249
//insert valid license data in parameters
251250
value.params = value.params.toString().replaceAll("LICENSE_PLACEHOLDER", "LICENSEE='MarkLogic - Version 9 QA Test License' -e LICENSE_KEY=\"${env.QA_LICENSE_KEY}\"")
@@ -300,7 +299,7 @@ def DockerRunTests() {
300299
}
301300
echo "-Deleting resources"
302301
if ( value.params.toString().contains(".yaml")) {
303-
sh( returnStdout: true, script: "docker compose -f ${composePath}${value.params} down" )
302+
sh( returnStdout: true, script: "docker compose -f ${value.params} down" )
304303
} else {
305304
sh( returnStdout: true, script: "docker rm -f ${testCont}" )
306305
}

‎dockerFiles/dockerfile-marklogic-server-centos

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###############################################################
22
#
3-
# Copyright (c) 2021 MarkLogic Corporation
3+
# Copyright (c) 2022 MarkLogic Corporation
44
#
55
###############################################################
66
FROM ml-docker-dev.marklogic.com/marklogic/marklogic-server-centos:10.0-7.3_1.0.0_EA

‎dockerFiles/marklogic-deps-centos:base

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###############################################################
22
#
3-
# Copyright (c) 2021 MarkLogic Corporation
3+
# Copyright (c) 2022 MarkLogic Corporation
44
#
55
###############################################################
66

‎dockerFiles/marklogic-server-centos:base

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###############################################################
22
#
3-
# Copyright (c) 2021 MarkLogic Corporation
3+
# Copyright (c) 2022 MarkLogic Corporation
44
#
55
###############################################################
66

‎src/centos/scripts/join-cluster.sh

+4-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /bin/bash
22
###############################################################
33
#
4-
# Copyright 2019 MarkLogic Corporation. All Rights Reserved.
4+
# Copyright 2022 MarkLogic Corporation. All Rights Reserved.
55
#
66
###############################################################
77
# join host to cluster
@@ -11,46 +11,22 @@
1111
#
1212
###############################################################
1313

14-
################################################################
15-
# check if admin password is a secret or env var
16-
################################################################
17-
SECRET_USR_FILE=/run/secrets/${MARKLOGIC_ADMIN_USERNAME_FILE}
18-
SECRET_PWD_FILE=/run/secrets/${MARKLOGIC_ADMIN_PASSWORD_FILE}
19-
20-
if [[ -f "$SECRET_PWD_FILE" ]] && [[ ! -z "$(<"$SECRET_PWD_FILE")" ]]
21-
then
22-
echo "using docker secrets for credentials"
23-
ML_ADMIN_PASSWORD=$(<"$SECRET_PWD_FILE")
24-
else
25-
echo "using ENV for credentials"
26-
ML_ADMIN_PASSWORD=$MARKLOGIC_ADMIN_PASSWORD
27-
fi
28-
29-
if [[ -f "$SECRET_USR_FILE" ]] && [[ ! -z "$(<"$SECRET_USR_FILE")" ]]
30-
then
31-
echo "using docker secrets for credentials"
32-
ML_ADMIN_USERNAME=$(<"$SECRET_USR_FILE")
33-
else
34-
echo "using ENV for credentials"
35-
ML_ADMIN_USERNAME=$MARKLOGIC_ADMIN_USERNAME
36-
fi
37-
3814
cluster=${1:-${MARKLOGIC_BOOTSTRAP_HOST}}
3915
joiner=${2:-localhost}
4016
user=${3:-${ML_ADMIN_USERNAME}}
4117
pass=${4:-${ML_ADMIN_PASSWORD}}
4218

43-
curl -o host.xml --anyauth --user $user:$pass -X GET -H "Accept: application/xml" \
19+
curl -s -o host.xml --anyauth --user $user:$pass -X GET -H "Accept: application/xml" \
4420
http://${joiner}:8001/admin/v1/server-config
4521

46-
curl -v --anyauth --user $user:$pass -X POST -d "group=Default" \
22+
curl -s -v --anyauth --user $user:$pass -X POST -d "group=Default" \
4723
--data-urlencode "server-config@./host.xml" \
4824
-H "Content-type: application/x-www-form-urlencoded" \
4925
-o cluster.zip http://${cluster}:8001/admin/v1/cluster-config
5026

5127
sleep 10s
5228

53-
curl -v --anyauth --user $user:$pass -X POST -H "Content-type: application/zip" \
29+
curl -s -v --anyauth --user $user:$pass -X POST -H "Content-type: application/zip" \
5430
--data-binary @./cluster.zip \
5531
http://${joiner}:8001/admin/v1/cluster-config
5632

‎src/centos/scripts/start-marklogic.sh

+109-92
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,177 @@
11
#! /bin/bash
22
###############################################################
33
#
4-
# Copyright 2019 MarkLogic Corporation. All Rights Reserved.
4+
# Copyright 2022 MarkLogic Corporation. All Rights Reserved.
55
#
66
###############################################################
7-
# initialise and start MarkLogic server
7+
# Initialise and start MarkLogic server
88
#
99
# ex.
1010
# > start-marklogic.sh
1111
#
1212
###############################################################
1313

14-
cd ~
14+
###############################################################
15+
# Prepare script
16+
###############################################################
17+
cd ~ || exit
18+
# Convert booleans to lowercase
19+
for var in OVERWRITE_ML_CONF INSTALL_CONVERTERS MARKLOGIC_DEV_BUILD MARKLOGIC_INIT MARKLOGIC_JOIN_CLUSTER; do
20+
declare $var="$(echo "${!var}" | sed -e 's/[[:blank:]]//g' | awk '{print tolower($0)}')"
21+
done
22+
23+
# define log and err functions
24+
log() {
25+
echo "$(basename "${0}"): ${*}"
26+
}
27+
err() {
28+
echo "$(basename "${0}") ERROR: ${*}" >&2
29+
exit 1
30+
}
1531

1632
################################################################
17-
# Read in ENV values
33+
# Read in ENV values for marklogic.conf
1834
################################################################
1935

20-
# If an ENV value exists in a list, append it to the /etc/marklogic.conf file
21-
if [[ -z $OVERWRITE_ML_CONF ]] || [[ "$OVERWRITE_ML_CONF" = "false" ]] ; then
22-
echo "Not writing to /etc/marklogic.conf"
23-
else
24-
echo "Deleting previous /etc/marklogic.conf ,if it exists, and overwriting with env variables"
36+
# If an ENV value exists in a list, append it to the /etc/marklogic.conf file
37+
if [[ "${OVERWRITE_ML_CONF}" = "true" ]]; then
38+
log "Deleting previous /etc/marklogic.conf, if it exists, and overwriting with env variables."
2539
rm -f /etc/marklogic.conf
2640
sudo touch /etc/marklogic.conf && sudo chmod 777 /etc/marklogic.conf
2741

28-
29-
[[ $MARKLOGIC_PID_FILE ]] && sudo echo "export MARKLOGIC_PID_FILE=$MARKLOGIC_PID_FILE" >> /etc/marklogic.conf
30-
[[ $MARKLOGIC_UMASK ]] && sudo echo "export MARKLOGIC_UMASK=$MARKLOGIC_UMASK" >> /etc/marklogic.conf
31-
[[ $TZ ]] && sudo echo "export TZ=$TZ " >> /etc/marklogic.conf
32-
[[ $MARKLOGIC_ADMIN_USERNAME ]] && sudo echo "export MARKLOGIC_ADMIN_USERNAME=$MARKLOGIC_ADMIN_USERNAME" >> /etc/marklogic.conf
33-
[[ $MARKLOGIC_ADMIN_PASSWORD ]] && sudo echo "export MARKLOGIC_ADMIN_PASSWORD=$MARKLOGIC_ADMIN_PASSWORD" >> /etc/marklogic.conf
34-
[[ $MARKLOGIC_LICENSEE ]] && sudo echo "export MARKLOGIC_LICENSEE=$MARKLOGIC_LICENSEE" >> /etc/marklogic.conf
35-
[[ $MARKLOGIC_LICENSE_KEY ]] && sudo echo "export MARKLOGIC_LICENSE_KEY=$MARKLOGIC_LICENSE_KEY" >> /etc/marklogic.conf
36-
[[ $ML_HUGEPAGES_TOTAL ]] && sudo echo "export ML_HUGEPAGES_TOTAL=$ML_HUGEPAGES_TOTAL" >> /etc/marklogic.conf
37-
[[ $MARKLOGIC_DISABLE_JVM ]] && sudo echo "export MARKLOGIC_DISABLE_JVM=$MARKLOGIC_DISABLE_JVM" >> /etc/marklogic.conf
38-
[[ $MARKLOGIC_USER ]] && sudo echo "export MARKLOGIC_USER=$MARKLOGIC_USER" >> /etc/marklogic.conf
39-
[[ $JAVA_HOME ]] && sudo echo "export JAVA_HOME=$JAVA_HOME" >> /etc/marklogic.conf
40-
[[ $CLASSPATH ]] && sudo echo "export CLASSPATH=$CLASSPATH" >> /etc/marklogic.conf
41-
42+
[[ "${MARKLOGIC_PID_FILE}" ]] && echo "export MARKLOGIC_PID_FILE=$MARKLOGIC_PID_FILE" >>/etc/marklogic.conf
43+
[[ "${MARKLOGIC_UMASK}" ]] && echo "export MARKLOGIC_UMASK=$MARKLOGIC_UMASK" >>/etc/marklogic.conf
44+
[[ "${TZ}" ]] && echo "export TZ=$TZ " >>/etc/marklogic.conf
45+
[[ "${MARKLOGIC_ADMIN_USERNAME}" ]] && echo "export MARKLOGIC_ADMIN_USERNAME=$MARKLOGIC_ADMIN_USERNAME" >>/etc/marklogic.conf
46+
[[ "${MARKLOGIC_ADMIN_PASSWORD}" ]] && echo "export MARKLOGIC_ADMIN_PASSWORD=$MARKLOGIC_ADMIN_PASSWORD" >>/etc/marklogic.conf
47+
[[ "${MARKLOGIC_LICENSEE}" ]] && echo "export MARKLOGIC_LICENSEE=$MARKLOGIC_LICENSEE" >>/etc/marklogic.conf
48+
[[ "${MARKLOGIC_LICENSE_KEY}" ]] && echo "export MARKLOGIC_LICENSE_KEY=$MARKLOGIC_LICENSE_KEY" >>/etc/marklogic.conf
49+
[[ "${ML_HUGEPAGES_TOTAL}" ]] && echo "export ML_HUGEPAGES_TOTAL=$ML_HUGEPAGES_TOTAL" >>/etc/marklogic.conf
50+
[[ "${MARKLOGIC_DISABLE_JVM}" ]] && echo "export MARKLOGIC_DISABLE_JVM=$MARKLOGIC_DISABLE_JVM" >>/etc/marklogic.conf
51+
[[ "${MARKLOGIC_USER}" ]] && echo "export MARKLOGIC_USER=$MARKLOGIC_USER" >>/etc/marklogic.conf
52+
[[ "${JAVA_HOME}" ]] && echo "export JAVA_HOME=$JAVA_HOME" >>/etc/marklogic.conf
53+
[[ "${CLASSPATH}" ]] && echo "export CLASSPATH=$CLASSPATH" >>/etc/marklogic.conf
4254

4355
sudo chmod 400 /etc/marklogic.conf
44-
fi
45-
46-
4756

57+
elif [[ -z ${OVERWRITE_ML_CONF} ]] || [[ "${OVERWRITE_ML_CONF}" = "false" ]]; then
58+
log "Not writing to /etc/marklogic.conf"
59+
else
60+
err "OVERWRITE_ML_CONF must be true or false."
61+
fi
4862

4963
################################################################
5064
# Install Converters if required
5165
################################################################
52-
if [[ -z $INSTALL_CONVERTERS ]] || [[ "$INSTALL_CONVERTERS" = "false" ]] ; then
53-
echo "Not Installing Converters"
54-
else
66+
if [[ "${INSTALL_CONVERTERS}" == "true" ]]; then
5567
if [[ -d "/opt/MarkLogic/Converters" ]]; then
56-
echo "Converters directory: /opt/MarkLogic/Converters already exists, skipping installation"
68+
log "Converters directory: /opt/MarkLogic/Converters already exists, skipping installation."
5769
else
58-
echo "Installing Converters"
70+
log "Installing Converters"
5971
CONVERTERS_PATH="/converters.rpm"
6072
sudo yum localinstall -y $CONVERTERS_PATH
6173
fi
74+
elif [[ -z "${INSTALL_CONVERTERS}" ]] || [[ "${INSTALL_CONVERTERS}" = "false" ]]; then
75+
log "Not Installing Converters"
76+
else
77+
err "INSTALL_CONVERTERS must be true or false."
6278
fi
6379

64-
6580
################################################################
6681
# Setup timezone
6782
################################################################
68-
if [ ! -z $TZ ]; then
69-
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
70-
echo $TZ | sudo tee /etc/timezone
83+
if [ -n "${TZ}" ]; then
84+
log "Setting timezone to ${TZ}"
85+
sudo ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime
86+
echo "${TZ}" | sudo tee /etc/timezone
7187
fi
7288

73-
7489
################################################################
75-
# start MarkLogic service
90+
# Start MarkLogic service
7691
################################################################
77-
if [ -z $MARKLOGIC_DEV_BUILD ]
78-
then
79-
sudo service MarkLogic start
92+
if [[ "${MARKLOGIC_DEV_BUILD}" == "true" ]]; then
93+
log "MARKLOGIC_DEV_BUILD is true, starting using ${MARKLOGIC_INSTALL_DIR}/MarkLogic"
94+
sudo "${MARKLOGIC_INSTALL_DIR}/MarkLogic" -i . -d "${MARKLOGIC_DATA_DIR}" -p "${MARKLOGIC_PID_FILE}" &
95+
elif [[ -z "${MARKLOGIC_DEV_BUILD}" ]] || [[ "${MARKLOGIC_DEV_BUILD}" == "false" ]]; then
96+
sudo service MarkLogic start
8097
else
81-
echo "MARKLOGIC_DEV_BUILD is defined, starting using ${MARKLOGIC_INSTALL_DIR}/MarkLogic"
82-
sudo ${MARKLOGIC_INSTALL_DIR}/MarkLogic -i . -d $MARKLOGIC_DATA_DIR -p ${MARKLOGIC_PID_FILE} &
98+
err "MARKLOGIC_DEV_BUILD must be true or false."
8399
fi
84100
sleep 5s
85101

86102
################################################################
87-
# check if admin password is a secret or env var
103+
# Check if admin password is a secret or env var
88104
################################################################
89-
SECRET_USR_FILE=/run/secrets/${MARKLOGIC_ADMIN_USERNAME_FILE}
90-
SECRET_PWD_FILE=/run/secrets/${MARKLOGIC_ADMIN_PASSWORD_FILE}
105+
SECRET_USR_FILE="/run/secrets/${MARKLOGIC_ADMIN_USERNAME_FILE}"
106+
SECRET_PWD_FILE="/run/secrets/${MARKLOGIC_ADMIN_PASSWORD_FILE}"
91107

92-
if [[ -f "$SECRET_PWD_FILE" ]] && [[ ! -z "$(<"$SECRET_PWD_FILE")" ]]
93-
then
94-
echo "using docker secrets for credentials"
95-
ML_ADMIN_PASSWORD=$(<"$SECRET_PWD_FILE")
108+
if [[ -f "${SECRET_PWD_FILE}" ]] && [[ -n "$(<"${SECRET_PWD_FILE}")" ]]; then
109+
log "Using docker secrets for credentials."
110+
ML_ADMIN_PASSWORD=$(<"$SECRET_PWD_FILE")
96111
else
97-
echo "using ENV for credentials"
98-
ML_ADMIN_PASSWORD=$MARKLOGIC_ADMIN_PASSWORD
112+
log "Using ENV for credentials."
113+
ML_ADMIN_PASSWORD="${MARKLOGIC_ADMIN_PASSWORD}"
99114
fi
100115

101-
if [[ -f "$SECRET_USR_FILE" ]] && [[ ! -z "$(<"$SECRET_USR_FILE")" ]]
102-
then
103-
echo "using docker secrets for credentials"
104-
ML_ADMIN_USERNAME=$(<"$SECRET_USR_FILE")
116+
if [[ -f "$SECRET_USR_FILE" ]] && [[ -n "$(<"$SECRET_USR_FILE")" ]]; then
117+
log "Using docker secrets for credentials."
118+
ML_ADMIN_USERNAME=$(<"$SECRET_USR_FILE")
105119
else
106-
echo "using ENV for credentials"
107-
ML_ADMIN_USERNAME=$MARKLOGIC_ADMIN_USERNAME
120+
log "Using ENV for credentials."
121+
ML_ADMIN_USERNAME="${MARKLOGIC_ADMIN_USERNAME}"
108122
fi
109123

110124
################################################################
111125
# check bootstrap marklogic (eg. MARKLOGIC_INIT is set)
112126
################################################################
113-
if [ -z $MARKLOGIC_INIT ] || [[ "$MARKLOGIC_INIT" = "false" ]]
114-
then
115-
echo "MARKLOGIC_INIT is not defined, no bootstrap"
116-
else
117-
echo "MARKLOGIC_INIT is defined, bootstrapping"
127+
if [[ -f /opt/MarkLogic/DOCKER_INIT ]]; then
128+
log "MARKLOGIC_INIT is already initialized, no bootstrap."
129+
elif [[ "${MARKLOGIC_INIT}" = "true" ]]; then
130+
log "MARKLOGIC_INIT is true, bootstrapping."
118131

119-
################################################################
120-
# generate JSON payload conditionally with license details.
121-
################################################################
122-
if [[ -z $LICENSE_KEY ]] || [[ -z $LICENSEE ]]
123-
then
124-
LICENSE_PAYLOAD="{}"
125-
else
126-
echo "LICENSE_KEY and LICENSEE are defined, generating license payload"
127-
LICENSE_PAYLOAD="{\"license-key\" : \"$LICENSE_KEY\",\"licensee\" : \"$LICENSEE\"}"
128-
fi
132+
# generate JSON payload conditionally with license details.
133+
if [[ -z "${LICENSE_KEY}" ]] || [[ -z "${LICENSEE}" ]]; then
134+
LICENSE_PAYLOAD="{}"
135+
else
136+
log "LICENSE_KEY and LICENSEE are defined, generating license payload."
137+
LICENSE_PAYLOAD="{\"license-key\" : \"${LICENSE_KEY}\",\"licensee\" : \"${LICENSEE}\"}"
138+
fi
129139

130-
################################################################
131-
# run init requests via curl.
132-
################################################################
133-
curl --anyauth -i -X POST \
134-
-H "Content-type:application/json" \
135-
-d "$LICENSE_PAYLOAD" \
136-
http://$HOSTNAME:8001/admin/v1/init
137-
sleep 5s
138-
curl -X POST -H "Content-type: application/x-www-form-urlencoded" \
139-
--data "admin-username=$ML_ADMIN_USERNAME" --data "admin-password=$ML_ADMIN_PASSWORD" \
140-
--data "realm=public" \
141-
http://$HOSTNAME:8001/admin/v1/instance-admin
142-
sleep 5s
140+
log "Bootstrapping MarkLogic on ${HOSTNAME}."
141+
curl -s --anyauth -i -X POST \
142+
-H "Content-type:application/json" \
143+
-d "${LICENSE_PAYLOAD}" \
144+
"http://${HOSTNAME}:8001/admin/v1/init"
145+
sleep 5s
146+
curl -s -X POST -H "Content-type: application/x-www-form-urlencoded" \
147+
--data "admin-username=${ML_ADMIN_USERNAME}" --data "admin-password=${ML_ADMIN_PASSWORD}" \
148+
--data "realm=public" \
149+
"http://${HOSTNAME}:8001/admin/v1/instance-admin"
150+
sleep 5s
151+
sudo touch /opt/MarkLogic/DOCKER_INIT
152+
elif [[ -z "${MARKLOGIC_INIT}" ]] || [[ "${MARKLOGIC_INIT}" = "false" ]]; then
153+
log "MARKLOGIC_INIT is set to false or not defined, no bootstrap."
154+
else
155+
err "MARKLOGIC_INIT must be true or false."
143156
fi
144157

145158
################################################################
146159
# check join cluster (eg. MARKLOGIC_JOIN_CLUSTER is set)
147160
################################################################
148-
if [ -z $MARKLOGIC_JOIN_CLUSTER ] || [[ "$MARKLOGIC_JOIN_CLUSTER" = "false" ]]
149-
then
150-
echo "MARKLOGIC_JOIN_CLUSTER is not defined, not joining cluster"
161+
if [[ -f /opt/MarkLogic/DOCKER_JOIN_CLUSTER ]]; then
162+
log "MARKLOGIC_JOIN_CLUSTER is already joined, not joining cluster."
163+
elif [[ "${MARKLOGIC_JOIN_CLUSTER}" = "true" ]]; then
164+
log "MARKLOGIC_JOIN_CLUSTER is true, joining cluster."
165+
sleep 5s
166+
/usr/local/bin/join-cluster.sh "${MARKLOGIC_BOOTSTRAP_HOST}" "${HOSTNAME}" "${ML_ADMIN_USERNAME}" "${ML_ADMIN_PASSWORD}"
167+
sudo touch /opt/MarkLogic/DOCKER_JOIN_CLUSTER
168+
elif [ -z "${MARKLOGIC_JOIN_CLUSTER}" ] || [[ "${MARKLOGIC_JOIN_CLUSTER}" = "false" ]]; then
169+
log "MARKLOGIC_JOIN_CLUSTER is false or not defined, not joining cluster."
151170
else
152-
echo "MARKLOGIC_JOIN_CLUSTER is defined, joining cluster"
153-
sleep 5s
154-
/usr/local/bin/join-cluster.sh $MARKLOGIC_BOOTSTRAP_HOST $HOSTNAME
171+
err "MARKLOGIC_JOIN_CLUSTER must be true or false."
155172
fi
156173

157174
################################################################
158175
# tail ErrorLog for docker logs
159176
################################################################
160-
tail -f $MARKLOGIC_DATA_DIR/Logs/ErrorLog.txt
177+
tail -f "${MARKLOGIC_DATA_DIR}/Logs/ErrorLog.txt"

‎test/compose-test-3.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Docker compose file sample to setup a three node cluster
2+
version: '3.6'
3+
services:
4+
bootstrap:
5+
image: marklogic-centos/marklogic-server-centos:10-internal
6+
hostname: bootstrap
7+
container_name: bootstrap
8+
dns_search: ""
9+
environment:
10+
- MARKLOGIC_INIT=true
11+
- MARKLOGIC_ADMIN_USERNAME=test_admin
12+
- MARKLOGIC_ADMIN_PASSWORD=test_admin_pass
13+
- TZ=America/Los_Angeles
14+
volumes:
15+
- MarkLogic_3n_vol1:/var/opt/MarkLogic
16+
ports:
17+
- 7100-7110:8000-8010
18+
- 7197:7997
19+
networks:
20+
- external_net
21+
node2:
22+
image: marklogic-centos/marklogic-server-centos:10-internal
23+
hostname: node2
24+
container_name: node2
25+
dns_search: ""
26+
environment:
27+
- MARKLOGIC_INIT=true
28+
- MARKLOGIC_ADMIN_USERNAME=test_admin
29+
- MARKLOGIC_ADMIN_PASSWORD=test_admin_pass
30+
- MARKLOGIC_JOIN_CLUSTER=true
31+
- TZ=America/Los_Angeles
32+
volumes:
33+
- MarkLogic_3n_vol2:/var/opt/MarkLogic
34+
ports:
35+
- 7200-7210:8000-8010
36+
- 7297:7997
37+
depends_on:
38+
- bootstrap
39+
networks:
40+
- external_net
41+
networks:
42+
external_net: {}
43+
volumes:
44+
MarkLogic_3n_vol1:
45+
MarkLogic_3n_vol2:

‎test/compose-test-4.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#Docker compose file sample to setup a three node cluster
2+
version: '3.6'
3+
services:
4+
bootstrap:
5+
image: marklogic-centos/marklogic-server-centos:10-internal
6+
hostname: testbootstrap
7+
container_name: testbootstrap
8+
dns_search: ""
9+
environment:
10+
- MARKLOGIC_INIT=true
11+
- MARKLOGIC_ADMIN_USERNAME=test_admin
12+
- MARKLOGIC_ADMIN_PASSWORD=test_admin_pass
13+
- TZ=America/Los_Angeles
14+
volumes:
15+
- MarkLogic_3n_vol1:/var/opt/MarkLogic
16+
ports:
17+
- 7100-7110:8000-8010
18+
- 7197:7997
19+
networks:
20+
- external_net
21+
node2:
22+
image: marklogic-centos/marklogic-server-centos:10-internal
23+
hostname: testnode
24+
container_name: testnode
25+
dns_search: ""
26+
environment:
27+
- MARKLOGIC_INIT=true
28+
- MARKLOGIC_ADMIN_USERNAME=test_admin
29+
- MARKLOGIC_ADMIN_PASSWORD=test_admin_pass
30+
- MARKLOGIC_JOIN_CLUSTER=false
31+
- TZ=America/Los_Angeles
32+
volumes:
33+
- MarkLogic_3n_vol2:/var/opt/MarkLogic
34+
ports:
35+
- 7200-7210:8000-8010
36+
- 7297:7997
37+
depends_on:
38+
- bootstrap
39+
networks:
40+
- external_net
41+
networks:
42+
external_net: {}
43+
volumes:
44+
MarkLogic_3n_vol1:
45+
MarkLogic_3n_vol2:
46+

‎test/compose-test-5.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#Docker compose file sample to setup a three node cluster
2+
version: '3.6'
3+
services:
4+
bootstrap:
5+
image: marklogic-centos/marklogic-server-centos:10-internal
6+
hostname: testbootstrap
7+
container_name: testbootstrap
8+
dns_search: ""
9+
environment:
10+
- MARKLOGIC_INIT=true
11+
- MARKLOGIC_ADMIN_USERNAME=test_admin
12+
- MARKLOGIC_ADMIN_PASSWORD=test_admin_pass
13+
- TZ=America/Los_Angeles
14+
volumes:
15+
- MarkLogic_3n_vol1:/var/opt/MarkLogic
16+
ports:
17+
- 7100-7110:8000-8010
18+
- 7197:7997
19+
networks:
20+
- external_net
21+
node:
22+
image: marklogic-centos/marklogic-server-centos:10-internal
23+
hostname: testnode
24+
container_name: testnode
25+
dns_search: ""
26+
environment:
27+
- MARKLOGIC_INIT=false
28+
- MARKLOGIC_ADMIN_USERNAME=test_admin
29+
- MARKLOGIC_ADMIN_PASSWORD=test_admin_pass
30+
- MARKLOGIC_JOIN_CLUSTER=false
31+
- TZ=America/Los_Angeles
32+
volumes:
33+
- MarkLogic_3n_vol2:/var/opt/MarkLogic
34+
ports:
35+
- 7200-7210:8000-8010
36+
- 7297:7997
37+
depends_on:
38+
- bootstrap
39+
networks:
40+
- external_net
41+
networks:
42+
external_net: {}
43+
volumes:
44+
MarkLogic_3n_vol1:
45+
MarkLogic_3n_vol2:
46+

‎test/docker-test-cases.json

+53-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
},
6666
"compose-1": {
6767
"description": "Compose single node",
68-
"params": "marklogic-centos.yaml",
68+
"params": "./docker-compose/marklogic-centos.yaml",
6969
"expected": {
7070
"unauthenticated": {
7171
"8000": "401 Unauthorized",
@@ -81,7 +81,7 @@
8181
},
8282
"compose-2": {
8383
"description": "Compose three node",
84-
"params": "marklogic-cluster-centos.yaml",
84+
"params": "./docker-compose/marklogic-cluster-centos.yaml",
8585
"expected": {
8686
"unauthenticated": {
8787
"7100": "401 Unauthorized",
@@ -106,5 +106,56 @@
106106
"7302": "Monitoring Dashboard"
107107
}
108108
}
109+
},
110+
"compose-3": {
111+
"description": "Two node compose with credentials in env",
112+
"params": "./test/compose-test-3.yaml",
113+
"expected": {
114+
"unauthenticated": {
115+
"7100": "401 Unauthorized",
116+
"7101": "401 Unauthorized",
117+
"7102": "401 Unauthorized",
118+
"7200": "401 Unauthorized",
119+
"7201": "401 Unauthorized",
120+
"7202": "401 Unauthorized"
121+
},
122+
"authenticated": {
123+
"7100": "Query Console",
124+
"7101": "No license key has been entered",
125+
"7102": "Monitoring Dashboard",
126+
"7200": "Query Console",
127+
"7201": "No license key has been entered"
128+
}
129+
}
130+
},
131+
"compose-4": {
132+
"description": "Two node compose with second node uncoupled",
133+
"params": "./test/compose-test-4.yaml",
134+
"expected": {
135+
"unauthenticated": {
136+
"7101": "401 Unauthorized",
137+
"7201": "401 Unauthorized"
138+
},
139+
"authenticated": {
140+
"7101": "testbootstrap",
141+
"7201": "testnode"
142+
}
143+
}
144+
},
145+
"compose-5": {
146+
"description": "Two node compose with second node uninitialized",
147+
"params": "./test/compose-test-5.yaml",
148+
"expected": {
149+
"unauthenticated": {
150+
"7101": "401 Unauthorized",
151+
"7201": "401 Unauthorized"
152+
},
153+
"authenticated": {
154+
"7101": "testbootstrap",
155+
"7200": "403 Forbidden",
156+
"7201": "This server must now self-install the initial databases and application servers. Click OK to continue.",
157+
"7202": "403 Forbidden"
158+
}
159+
}
109160
}
110161
}

0 commit comments

Comments
 (0)
Please sign in to comment.