Skip to content

Commit

Permalink
Merge pull request #21 from malscent/main
Browse files Browse the repository at this point in the history
Added the following changes
  • Loading branch information
malscent authored Apr 20, 2021
2 parents 3794f24 + 7e7dfa0 commit 4a92220
Show file tree
Hide file tree
Showing 18 changed files with 598 additions and 304 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/StackTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- name: Docker containers running?
run: docker ps
- name: Test
run: docker run --network compose-files_cb-net-ubuntu appropriate/curl --retry 10 --retry-connrefused http://ubuntu-clusterhost:8091/
run: while ! curl http://localhost:8080; do sleep 10; done;
timeout-minutes: 10
- name: Teardown
run: docker-compose -f ./compose-files/UbuntuClusterCompose.yml down
13 changes: 10 additions & 3 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: Shellcheck and Bats Tests

# Controls when the action will run.
on:
Expand All @@ -16,7 +16,7 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
ShellCheck:
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand All @@ -31,4 +31,11 @@ jobs:
with:
check_together: 'yes'
ignore: test_scripts

BatsTests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Bats
run: |
cd $GITHUB_WORKSPACE
docker build -f ./test_scripts/unit_tests/Dockerfile -t bats_tests . --no-cache --progress=plain && docker run --rm bats_tests
56 changes: 56 additions & 0 deletions common/constants.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

# Main Constants
export HELP=0
export VERSION="6.6.1"
export OS="UBUNTU"
export readonly AVAILABLE_OS_VALUES=("UBUNTU" "RHEL" "CENTOS" "DEBIAN" "AMAZON")
export ENV="OTHER"
export readonly AVAILABLE_ENV_VALUES=("AZURE" "AWS" "GCP" "DOCKER" "KUBERNETES" "OTHER")
export DEFAULT_USERNAME="couchbase"
export DEFAULT_PASSWORD=""
DEFAULT_PASSWORD=$(__generate_random_string)
export CB_USERNAME=$DEFAULT_USERNAME
export CB_PASSWORD=$DEFAULT_PASSWORD
export DAEMON=0
export STARTUP=0
export SYNC_GATEWAY=0
export WAIT=0
export NO_CLUSTER=0
export DO_CLUSTER=0
export readonly DEFAULT_SERVICES=("data" "index" "analytics" "eventing" "fts" "query")
export SERVICES="${DEFAULT_SERVICES[*]}"
export SERVICES="${SERVICES// /,}"
export DATA_QUOTA=0
DATA_QUOTA=$(__getTotalRam)
export DATA_QUOTA=$((DATA_QUOTA / 2)) #50% of available as default
export INDEX_QUOTA=0
INDEX_QUOTA=$(__getTotalRam)
export INDEX_QUOTA=$((15 * INDEX_QUOTA / 100 )) #15% of available as default
export SEARCH_QUOTA=256
export ANALYTICS_QUOTA=1024
export EVENTING_QUOTA=256

#Installer Constants
export readonly CENTOS_OS_SUPPORTED_VERSIONS=("8" "7")
export readonly CENTOS_SUPPORTED_VERSIONS=("6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly CENTOS_SUPPORTED_SYNC_GATEWAY_VERSIONS=("1.5.1" "1.5.2" "2.0.0" "2.1.0" "2.1.1" "2.1.2" "2.1.3" "2.5.0" "2.5.1" "2.6.0" "2.6.1" "2.7.0" "2.7.1" "2.7.2" "2.7.3" "2.7.4" "2.8.0" "2.8.2")
export readonly DEBIAN_OS_SUPPORTED_VERSIONS=("10" "9" "8")
export readonly DEBIAN_10_SUPPORTED_VERSIONS=("6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly DEBIAN_9_SUPPORTED_VERSIONS=("5.1.0" "5.1.1" "5.1.2" "5.1.3" "5.5.0" "5.5.1" "5.5.2" "5.5.3" "5.5.4" "5.5.5" "5.5.6" "6.0.0" "6.0.1" "6.0.2" "6.0.3" "6.0.4" "6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly DEBIAN_8_SUPPORTED_VERSIONS=("5.0.1" "5.1.0" "5.1.1" "5.1.2" "5.1.3" "5.5.0" "5.5.1" "5.5.2" "5.5.3" "5.5.4" "5.5.5" "5.5.6" "6.0.0" "6.0.1" "6.0.2" "6.0.3" "6.0.4" "6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly DEBIAN_SUPPORTED_SYNC_GATEWAY_VERSIONS=("1.5.1" "1.5.2" "2.0.0" "2.1.0" "2.1.1" "2.1.2" "2.1.3" "2.5.0" "2.5.1" "2.6.0" "2.6.1" "2.7.0" "2.7.1" "2.7.2" "2.7.3" "2.7.4" "2.8.0" "2.8.2")
export readonly RHEL_OS_SUPPORTED_VERSIONS=("8" "7" "6")
export readonly RHEL_8_SUPPORTED_VERSIONS=("6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly RHEL_7_SUPPORTED_VERSIONS=("6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly RHEL_6_SUPPORTED_VERSIONS=("5.0.1" "5.1.0" "5.1.1" "5.1.2" "5.1.3" "5.5.0" "5.5.1" "5.5.2" "5.5.3" "5.5.4" "5.5.5" "5.5.6" "6.0.0" "6.0.1" "6.0.2" "6.0.3" "6.0.4")
export readonly RHEL_SUPPORTED_SYNC_GATEWAY_VERSIONS=("1.5.1" "1.5.2" "2.0.0" "2.1.0" "2.1.1" "2.1.2" "2.1.3" "2.5.0" "2.5.1" "2.6.0" "2.6.1" "2.7.0" "2.7.1" "2.7.2" "2.7.3" "2.7.4" "2.8.0" "2.8.2")
export readonly UBUNTU_OS_SUPPORTED_VERSIONS=("14.04" "16.04" "18.04" "20.04")
export readonly UBUNTU_14_SUPPORTED_VERSIONS=("5.0.1" "5.1.0" "5.1.1" "5.1.2" "5.1.3" "5.5.0" "5.5.1" "5.5.2" "5.5.3" "5.5.4" "5.5.5" "5.5.6" "6.0.0" "6.0.1")
export readonly UBUNTU_16_SUPPORTED_VERSIONS=("5.0.1" "5.1.0" "5.1.1" "5.1.2" "5.1.3" "5.5.0" "5.5.1" "5.5.2" "5.5.3" "5.5.4" "5.5.5" "5.5.6" "6.0.0" "6.0.1" "6.0.2" "6.0.3" "6.0.4" "6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly UBUNTU_18_SUPPORTED_VERSIONS=("6.0.1" "6.0.2" "6.0.3" "6.0.4" "6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2" "7.0.0")
export readonly UBUNTU_20_SUPPORTED_VERSIONS=("7.0.0")
export readonly UBUNTU_SUPPORTED_SYNC_GATEWAY_VERSIONS=("1.5.1" "1.5.2" "2.0.0" "2.1.0" "2.1.1" "2.1.2" "2.1.3" "2.5.0" "2.5.1" "2.6.0" "2.6.1" "2.7.0" "2.7.1" "2.7.2" "2.7.3" "2.7.4" "2.8.0" "2.8.2")
export readonly AMAZON_LINUX_OS_SUPPORTED_VERSIONS=("2")
export readonly AMAZON_LINUX_SUPPORTED_VERSIONS=("6.5.0" "6.5.1" "6.6.0" "6.6.1" "6.6.2")
export readonly AMAZON_LINUX_SUPPORTED_SYNC_GATEWAY_VERSIONS=("1.5.1" "1.5.2" "2.0.0" "2.1.0" "2.1.1" "2.1.2" "2.1.3" "2.5.0" "2.5.1" "2.6.0" "2.6.1" "2.7.0" "2.7.1" "2.7.2" "2.7.3" "2.7.4" "2.8.0" "2.8.2")
102 changes: 99 additions & 3 deletions common/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function __elementIn() {
local e match
match=$(echo "$1" | tr '[:lower:]' '[:upper:]')
shift
for e; do [[ "${e}" = "${match}" ]] && echo 0 && return; done
for e; do [[ "$(__toUpper "${e}")" = "${match}" ]] && echo 0 && return; done
echo 1
}

Expand Down Expand Up @@ -57,7 +57,7 @@ function __compareVersions() {
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
echo 2
echo -1
return
fi
done
Expand All @@ -84,7 +84,7 @@ function __findClosestVersion() {
for i in "${compatibleVersions[@]}"; do
comparison=$(__compareVersions "$requestedVersion" "$i")
selectedComparison=$(__compareVersions "$selectedVersion" "$i")
if [[ "$comparison" == "1" && "$selectedComparison" == "2" ]]; then
if [[ "$comparison" == "1" && "$selectedComparison" == "-1" ]]; then
# our selected version is greater than the requested so we go with it
selectedVersion=$i

Expand All @@ -93,4 +93,100 @@ function __findClosestVersion() {

echo "$selectedVersion"
return
}

function __getTotalRam() {
# check for free, which is part of gnu core-utils which is
# present on almost every distro, but not macOS
if which free > /dev/null; then
free --mebi | awk 'NR==2{print $2}'
return
fi
# here we grab the memsize in bytes then convert to MiB
# this works on macOS - Big Sur
size=$(sysctl hw.memsize | cut -d ' ' -f 2)
echo $((size / 1024 / 1024))
return
}

function __convertToMiB() {
local value
value=$(__toUpper "${1}")
local default=0
if [ -n "$2" ]; then
default=$(__convertToMiB "$2")
fi
local gib=0
local tib=0
local totalRAM=0
totalRAM=$(__getTotalRam)
# for suffixes TiB, TIB, or tib
if [[ "$value" == *TIB ]]; then
gib=1
tib=1
value="${value%TIB}"
fi
# for suffixes TI, Ti, or ti
if [[ "$value" == *TI ]]; then
gib=1
tib=1
value="${value%TI}"

fi
# for suffixes GiB or GIB or gib
if [[ "$value" == *GIB ]]; then
gib=1
value="${value%GIB}"
fi
# for suffixes GI or Gi or gi
if [[ "$value" == *GI ]]; then
gib=1
value="${value%GI}"
fi
# for suffixes of MIB, MiB, mIB, miB or mib
if [[ "$value" == *MIB ]]; then
value="${value%MIB}"
fi
# for suffixes off MI, mI, Mi, or mi
if [[ "$value" == *MI ]]; then
value="${value%MI}"
fi
# confirm it's actually a number after we strip the suffix
if ! [[ "$value" =~ ^[0-9]+$ ]]; then
echo "$default"
return 0
fi
# If it's a tib, we need to convert to GiB for next conversion
if [[ "$tib" == "1" ]]; then
value=$((value * 1024))
fi
# if it's a gib, we need to swap it over to MiB
if [[ "$gib" == "1" ]]; then
value=$((value * 1024))
fi
# If our value is greater than the total ram, we return default
if [[ $value -gt $totalRAM ]]; then
echo "$default"
else
echo "$value"
fi
return 0
}

function __allExists {
local oifs=$IFS
needles=()
IFS="," read -r -a needles <<< "$1"
IFS=$oifs
shift
haystack=("$@")
for x in "${needles[@]}"
do
output=$(__elementIn "$x" "${haystack[@]}")
if [[ "$output" == "1" ]]; then
echo "$output"
return 1
fi
done
return 0
}
25 changes: 19 additions & 6 deletions compose-files/CentosClusterCompose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
networks:
- cb-net-centos
container_name: centos-clusterhost
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r -w 3
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r -w 3 --services data,index,query -dm 256 -im 256 -qm 256
privileged: true
nodeone:
image: couchbase/centos
Expand All @@ -25,7 +25,7 @@ services:
ports:
- "8081:8091"
container_name: centos-node-one
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r --services data,index,query -dm 256 -im 256 -qm 256
privileged: true
nodetwo:
image: couchbase/centos
Expand All @@ -38,8 +38,21 @@ services:
ports:
- "8082:8091"
container_name: centos-node-two
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r --services data,index,query,analytics,eventing,fts -dm 256 -im 256 -qm 256 -am 1024 -em 256 -sm 256
privileged: true
nocluster:
image: couchbase/centos
hostname: 'no_cluster'
tty: true
depends_on:
- rallyhost
networks:
- cb-net-centos
ports:
- "8083:8091"
container_name: centos-no-cluster
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os CENTOS -r --no-cluster --services data,index,query,analytics,eventing,fts -dm 256 -im 256 -qm 256 -am 1024 -em 256 -sm 256
privileged: true
gateway:
image: couchbase/centos
hostname: 'gateway'
Expand All @@ -49,10 +62,10 @@ services:
networks:
- cb-net-centos
ports:
- "8083:4985"
- "8084:4984"
- "8085:4985"
- "8086:4984"
container_name: gateway
command: --version 2.8.0 -u couchbase -p foo123! -ch centos-clusterhost -d -os CENTOS -g -r
command: --version 2.8.2 -u couchbase -p foo123! -ch centos-clusterhost -d -os CENTOS -g -r
privileged: true
networks:
cb-net-centos:
25 changes: 19 additions & 6 deletions compose-files/DebianClusterCompose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
networks:
- cb-net-debian
container_name: debian-clusterhost
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os DEBIAN -r -w 3
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os DEBIAN -r -w 3 --services data,index,query -dm 256 -im 256 -qm 256
privileged: true
nodeone:
image: couchbase/debian
Expand All @@ -25,7 +25,7 @@ services:
ports:
- "8081:8091"
container_name: debian-node-one
command: --version 6.6.1 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -r
command: --version 6.6.1 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -r --services data,index,query -dm 256 -im 256 -qm 256
privileged: true
nodetwo:
image: couchbase/debian
Expand All @@ -38,8 +38,21 @@ services:
ports:
- "8082:8091"
container_name: debian-node-two
command: --version 6.6.1 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -r
command: --version 6.6.1 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -r --services data,index,query,analytics,eventing,fts -dm 256 -im 256 -qm 256 -am 1024 -em 256 -sm 256
privileged: true
nocluster:
image: couchbase/debian
hostname: 'no_cluster'
tty: true
depends_on:
- rallyhost
networks:
- cb-net-debian
ports:
- "8083:8091"
container_name: debian-no-cluster
command: --version 6.6.1 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -r --no-cluster --services data,index,query,analytics,eventing,fts -dm 256 -im 256 -qm 256 -am 1024 -em 256 -sm 256
privileged: true
gateway:
image: couchbase/debian
hostname: 'gateway'
Expand All @@ -49,10 +62,10 @@ services:
networks:
- cb-net-debian
ports:
- "8083:4985"
- "8084:4984"
- "8085:4985"
- "8086:4984"
container_name: gateway
command: --version 2.8.0 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -g -r
command: --version 2.8.2 -u couchbase -p foo123! -ch debian-clusterhost -d -os DEBIAN -g -r
privileged: true
networks:
cb-net-debian:
25 changes: 19 additions & 6 deletions compose-files/RHELClusterCompose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
networks:
- cb-net-redhat
container_name: redhat-clusterhost
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os RHEL -r -w 3
command: --version 6.6.1 -u couchbase -p foo123! -ch clusterhost -d -os RHEL -r -w 3 --services data,index,query -dm 256 -im 256 -qm 256
privileged: true
nodeone:
image: couchbase/redhat
Expand All @@ -25,7 +25,7 @@ services:
ports:
- "8081:8091"
container_name: redhat-node-one
command: --version 6.6.1 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -r
command: --version 6.6.1 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -r --services data,index,query -dm 256 -im 256 -qm 256
privileged: true
nodetwo:
image: couchbase/redhat
Expand All @@ -38,7 +38,20 @@ services:
ports:
- "8082:8091"
container_name: redhat-node-two
command: --version 6.6.1 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -r
command: --version 6.6.1 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -r --services data,index,query,analytics,eventing,fts -dm 256 -im 256 -qm 256 -am 1024 -em 256 -sm 256
privileged: true
nocluster:
image: couchbase/redhat
hostname: 'no_cluster'
tty: true
depends_on:
- rallyhost
networks:
- cb-net-redhat
ports:
- "8083:8091"
container_name: redhat-no-cluster
command: --version 6.6.1 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -r --no-cluster --services data,index,query,analytics,eventing,fts -dm 256 -im 256 -qm 256 -am 1024 -em 256 -sm 256
privileged: true
gateway:
image: couchbase/redhat
Expand All @@ -49,10 +62,10 @@ services:
networks:
- cb-net-redhat
ports:
- "8083:4985"
- "8084:4984"
- "8085:4985"
- "8086:4984"
container_name: gateway
command: --version 2.8.0 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -g -r
command: --version 2.8.2 -u couchbase -p foo123! -ch redhat-clusterhost -d -os RHEL -g -r
privileged: true
networks:
cb-net-redhat:
Loading

0 comments on commit 4a92220

Please sign in to comment.