New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBG-2711 add 3 node cluster option to jenkins #6176
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2023-Present Couchbase, Inc. | ||
# | ||
# Use of this software is governed by the Business Source License included | ||
# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified | ||
# in that file, in accordance with the Business Source License, use of this | ||
# software will be governed by the Apache License, Version 2.0, included in | ||
# the file licenses/APL2.txt. | ||
|
||
services: | ||
couchbase: | ||
container_name: couchbase | ||
image: "couchbase/server:${COUCHBASE_DOCKER_IMAGE_NAME:-enterprise-7.1.4}" | ||
ports: | ||
- 8091:8091 | ||
- 8092:8092 | ||
- 8093:8093 | ||
- 8094:8094 | ||
- 8095:8095 | ||
- 8096:8096 | ||
- 11207:11207 | ||
- 11210:11210 | ||
- 11211:11211 | ||
- 18091:18091 | ||
- 18092:18092 | ||
- 18093:18093 | ||
- 18094:18094 | ||
volumes: | ||
- "${DOCKER_CBS_ROOT_DIR:-.}/cbs:/root" | ||
- "${WORKSPACE_ROOT:-.}:/workspace" | ||
couchbase-replica1: | ||
container_name: couchbase-replica1 | ||
image: "couchbase/${COUCHBASE_DOCKER_IMAGE_NAME:-server:enterprise-7.1.4}" | ||
couchbase-replica2: | ||
container_name: couchbase-replica2 | ||
image: "couchbase/server:${COUCHBASE_DOCKER_IMAGE_NAME:-enterprise-7.1.4}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
# Copyright 2023-Present Couchbase, Inc. | ||
# | ||
# Use of this software is governed by the Business Source License included | ||
# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified | ||
# in that file, in accordance with the Business Source License, use of this | ||
# software will be governed by the Apache License, Version 2.0, included in | ||
# the file licenses/APL2.txt. | ||
|
||
set -eux -o pipefail | ||
|
||
function usage() { | ||
echo "Usage: $0 [-m] [-h] containername" | ||
} | ||
|
||
if [ $# -gt 2 ]; then | ||
echo "Expected maximally two arguments" | ||
exit 1 | ||
fi | ||
|
||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
case $key in | ||
-m | --multi-node) | ||
MULTI_NODE=true | ||
shift | ||
;; | ||
-h | --help) | ||
echo "Usage: $0 [-m] [-h] containername" | ||
exit 1 | ||
;; | ||
*) | ||
COUCHBASE_DOCKER_IMAGE_NAME="$1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
WORKSPACE_ROOT="$(pwd)" | ||
DOCKER_CBS_ROOT_DIR="$(pwd)" | ||
if [ "${CBS_ROOT_DIR:-}" != "" ]; then | ||
DOCKER_CBS_ROOT_DIR="${CBS_ROOT_DIR}" | ||
fi | ||
|
||
if [[ -n "${JENKINS_URL:-}" ]]; then | ||
DOCKER_COMPOSE="docker-compose" # use docker-compose v1 for Jenkins AWS Linux 2 | ||
else | ||
DOCKER_COMPOSE="docker compose" | ||
fi | ||
cd -- "${BASH_SOURCE%/*}/" | ||
${DOCKER_COMPOSE} down || true | ||
export SG_TEST_COUCHBASE_SERVER_DOCKER_NAME=couchbase | ||
# Start CBS | ||
docker stop ${SG_TEST_COUCHBASE_SERVER_DOCKER_NAME} || true | ||
docker rm ${SG_TEST_COUCHBASE_SERVER_DOCKER_NAME} || true | ||
# --volume: Makes and mounts a CBS folder for storing a CBCollect if needed | ||
|
||
if [[ -z "${MULTI_NODE:-}" ]]; then | ||
docker run -d --name ${SG_TEST_COUCHBASE_SERVER_DOCKER_NAME} --volume "${DOCKER_CBS_ROOT_DIR}/cbs:/root" --volume "${WORKSPACE_ROOT}:/workspace" -p 8091-8096:8091-8096 -p 11207:11207 -p 11210:11210 -p 11211:11211 -p 18091-18094:18091-18094 "couchbase/server:${COUCHBASE_DOCKER_IMAGE_NAME}" | ||
else | ||
${DOCKER_COMPOSE} up -d --force-recreate --renew-anon-volumes --remove-orphans | ||
fi | ||
|
||
# Test to see if Couchbase Server is up | ||
# Each retry min wait 5s, max 10s. Retry 20 times with exponential backoff (delay 0), fail at 120s | ||
curl --retry-all-errors --connect-timeout 5 --max-time 10 --retry 20 --retry-delay 0 --retry-max-time 120 'http://127.0.0.1:8091' | ||
|
||
# Set up CBS | ||
|
||
docker exec couchbase couchbase-cli cluster-init --cluster-username Administrator --cluster-password password --cluster-ramsize 3072 --cluster-index-ramsize 3072 --cluster-fts-ramsize 256 --services data,index,query | ||
docker exec couchbase couchbase-cli setting-index --cluster couchbase://localhost --username Administrator --password password --index-threads 4 --index-log-level verbose --index-max-rollback-points 10 --index-storage-setting default --index-memory-snapshot-interval 150 --index-stable-snapshot-interval 40000 | ||
|
||
curl -u Administrator:password -v -X POST http://127.0.0.1:8091/node/controller/rename -d 'hostname=127.0.0.1' | ||
|
||
if [[ -n "${MULTI_NODE:-}" ]]; then | ||
REPLICA1_NAME=couchbase-replica1 | ||
REPLICA2_NAME=couchbase-replica2 | ||
CLI_ARGS=(-c couchbase://couchbase -u Administrator -p password) | ||
docker exec ${REPLICA1_NAME} couchbase-cli node-init "${CLI_ARGS[@]}" | ||
docker exec ${REPLICA2_NAME} couchbase-cli node-init "${CLI_ARGS[@]}" | ||
REPLICA1_IP=$(docker inspect --format '{{json .NetworkSettings.Networks}}' ${REPLICA1_NAME} | jq -r 'first(.[]) | .IPAddress') | ||
REPLICA2_IP=$(docker inspect --format '{{json .NetworkSettings.Networks}}' ${REPLICA2_NAME} | jq -r 'first(.[]) | .IPAddress') | ||
docker exec ${SG_TEST_COUCHBASE_SERVER_DOCKER_NAME} couchbase-cli server-add "${CLI_ARGS[@]}" --server-add "$REPLICA2_IP" --server-add-username Administrator --server-add-password password --services data,index,query | ||
docker exec ${SG_TEST_COUCHBASE_SERVER_DOCKER_NAME} couchbase-cli server-add "${CLI_ARGS[@]}" --server-add "$REPLICA1_IP" --server-add-username Administrator --server-add-password password --services data,index,query | ||
docker exec ${SG_TEST_COUCHBASE_SERVER_DOCKER_NAME} couchbase-cli rebalance "${CLI_ARGS[@]}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Num replicas here should be zero, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be 1 because this is multi-node cluster and we want at least one replica for each bucket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad - read the if backwards.
Should we specify 2 replicas in that case, if we know there are 3 CB Data nodes?