diff options
author | dekstroza <dejan.kitic@ericsson.com> | 2018-05-03 16:47:08 +0100 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-05-24 20:48:12 +0300 |
commit | 8352006ec9f5cf8574c83f80d1b5ecb24204abed (patch) | |
tree | 5a95b3b3f937f42e418821795660ffbfde1dc60b /sdc-os-chef/scripts/sanity_run.sh | |
parent | dd275e87db8a7d573ff33a515207766ca4b78768 (diff) |
Add support for running SDC using Docker on OSX
This patch adds support for running SDC on OSX. There are several OSX
specific commands wrt to getting host IP address, mounting
/etc/localtime and using / filesystem in run/build process
Issue-ID: SDC-1297
Change-Id: I2da3ce13d7c254d06376c717ae22f2cb446c63bd
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'sdc-os-chef/scripts/sanity_run.sh')
-rw-r--r-- | sdc-os-chef/scripts/sanity_run.sh | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sdc-os-chef/scripts/sanity_run.sh b/sdc-os-chef/scripts/sanity_run.sh index 4aea3bb410..8898b92a81 100644 --- a/sdc-os-chef/scripts/sanity_run.sh +++ b/sdc-os-chef/scripts/sanity_run.sh @@ -1,5 +1,11 @@ #!/bin/bash +#Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there. +LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro" +# If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be +if [[ "$OSTYPE" == "darwin"* ]]; then + LOCAL_TIME_MOUNT_CMD="" +fi function usage { echo "usage: sanity_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -t|--runTests <Run-with-sanityDocker>] [ -h|--help ]" @@ -140,17 +146,21 @@ while [ $# -gt 0 ]; do done -[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ -[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release -[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW -[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT} -[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO +[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ +[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release +[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW +[ -f ${WORKSPACE}/opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat ${WORKSPACE}/opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT} +[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO cleanup export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'` +#If OSX, then use this to get IP +if [[ "$OSTYPE" == "darwin"* ]]; then + export IP=$(ipconfig getifaddr en0) +fi export PREFIX=${NEXUS_DOCKER_REPO}'/onap' if [ ${LOCAL} = true ]; then @@ -170,7 +180,7 @@ if [[ (${RUNTESTS} = true) && (${healthCheck_http_code} == 200) ]]; then docker pull ${PREFIX}/sdc-sanity:${RELEASE} fi -docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 1500m --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/sdc-sanity/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-sanity/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE} +docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 1500m --ulimit nofile=4096:100000 $LOCAL_TIME_MOUNT_CMD --volume ${WORKSPACE}/data/logs/sdc-sanity/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-sanity/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE} echo "please wait while SANITY is starting....." monitor_docker sdc-sanity |