Skip to content

Commit c095833

Browse files
committed
Some more stuff
1 parent 5a5a797 commit c095833

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

docker-compose.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '2'
2+
services:
3+
couchbase:
4+
image: rishabhdev/couchbase-server-sandbox:latest
5+
ports:
6+
- '127.0.0.1:8091-8095:8091-8095'
7+
- '127.0.0.1:11210:11210'
8+
volumes:
9+
- ./var:/opt/couchbase/var

scripts/configure-node.sh

+48-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22

33
# Log all subsequent commands to logfile. FD 3 is now the console
44
# for things we want to show up in "docker logs".
5+
LOGFILE=/opt/couchbase/var/lib/couchbase/logs/container-startup.log
56
# exec 3>&1 1>>${LOGFILE} 2>&1
67

8+
CONFIG_DONE_FILE=/opt/couchbase/var/lib/couchbase/container-configured
79
config_done() {
10+
touch ${CONFIG_DONE_FILE}
811
echo "Couchbase Admin UI: http://localhost:8091" \
912
"\nLogin credentials: Administrator / password" | tee /dev/fd/3
1013
echo "Stopping config-couchbase service"
1114
sv stop /etc/service/config-couchbase
1215
}
1316

14-
echo "Configuring Couchbase Server. Please wait (~60 sec)..." | tee /dev/fd/3
17+
if [ -e ${CONFIG_DONE_FILE} ]; then
18+
echo "Container previously configured." | tee /dev/fd/3
19+
config_done
20+
else
21+
echo "Configuring Couchbase Server. Please wait (~60 sec)..." | tee /dev/fd/3
22+
fi
1523

1624
export PATH=/opt/couchbase/bin:${PATH}
1725

@@ -30,6 +38,23 @@ wait_for_uri() {
3038
echo "$uri ready, continuing"
3139
}
3240

41+
42+
wait_for_uri_with_auth_and_data() {
43+
uri=$1
44+
data=$2
45+
expected=$3
46+
echo "Waiting for $uri to be available..."
47+
while true; do
48+
status=$(curl -s -u Administrator:password -w "%{http_code}" -o /dev/null $uri -d "$data")
49+
if [ "x$status" = "x$expected" ]; then
50+
break
51+
fi
52+
echo "$uri not up yet, waiting 2 seconds..."
53+
sleep 2
54+
done
55+
echo "$uri ready, continuing"
56+
}
57+
3358
panic() {
3459
cat <<EOF 1>&3
3560
@@ -65,7 +90,7 @@ curl_check() {
6590
wait_for_uri http://127.0.0.1:8091/ui/index.html 200
6691

6792
echo "Setting memory quotas with curl"
68-
curl_check http://127.0.0.1:8091/pools/default -d memoryQuota=256 -d indexMemoryQuota=256 -d ftsMemoryQuota=256 -d cbasMemoryQuota=1024
93+
curl http://127.0.0.1:8091/pools/default -d memoryQuota=256 -d indexMemoryQuota=256 -d ftsMemoryQuota=256 -d cbasMemoryQuota=1024
6994
echo
7095

7196
echo "Configuring Services with curl"
@@ -84,15 +109,34 @@ echo "Creating 'datadog-test' bucket with curl"
84109
curl_check -u Administrator:password -X POST http://127.0.0.1:8091/pools/default/buckets -d name=datadog-test -d ramQuotaMB=100 -d authType=sasl \
85110
-d replicaNumber=0 -d bucketType=couchbase
86111

87-
wait_for_uri http://127.0.0.1:8093/query/service 400
112+
wait_for_uri_with_auth_and_data http://127.0.0.1:8093/query/service 'statement=SELECT 1' 200
113+
114+
echo "Adding document to test bucket with curl"
115+
curl -u Administrator:password -X POST http://127.0.0.1:8093/query/service \
116+
-d 'statement=INSERT INTO `datadog-test` ( KEY, VALUE )
117+
VALUES
118+
(
119+
"landmark_1",
120+
{
121+
"id": "1",
122+
"type": "landmark",
123+
"name": "La Tour Eiffel",
124+
"location": "France"
125+
}
126+
)'
88127

89128
wait_for_uri http://127.0.0.1:8094/api/index 403
90129

91-
echo "Creating test FTS index with curl:"
130+
echo "Creating test FTS index with curl"
92131
curl_check -u Administrator:password -X PUT http://127.0.0.1:8094/api/index/test -H Content-Type:application/json -d @/opt/couchbase/create-index.json
93132
rm /opt/couchbase/create-index.json
94133
echo
95134

135+
echo "Creating datadoc design document"
136+
curl_check -u Administrator:password -X PUT http://127.0.0.1:8092/datadog-test/_design/datadoc -H Content-Type:application/json -d @/opt/couchbase/create-ddoc.json
137+
rm /opt/couchbase/create-ddoc.json
138+
echo
139+
96140
echo "Creating RBAC 'admin' user on datadog-test bucket"
97141
couchbase_cli_check user-manage --set \
98142
--rbac-username admin --rbac-password password \

scripts/create-ddoc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"views": {
3+
"by_name": {
4+
"map": "function (doc, meta) {\n if (doc.type && doc.type == 'landmark') {\n emit(doc.name, null)\n }\n }"
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)