-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge blank-environment into develop
- Loading branch information
Showing
7 changed files
with
200 additions
and
35 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
services: | ||
test-runner: | ||
container_name: test-runner | ||
environment: | ||
- LOCAL=1 | ||
image: iofog/test-runner:latest | ||
networks: | ||
- iofog | ||
volumes: | ||
- ./conf:/conf | ||
version: '3' | ||
services: | ||
# Test Harness image | ||
test-runner: | ||
container_name: test-runner | ||
environment: | ||
- LOCAL=1 | ||
image: iofog/test-runner:latest | ||
networks: | ||
- iofog | ||
volumes: | ||
- ./conf:/conf | ||
volumes: | ||
conf: null | ||
conf: null | ||
networks: | ||
iofog: null | ||
iofog: null |
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
#!/usr/bin/env sh | ||
# stop.sh - shut down the Demo docker-compose environment | ||
# | ||
# Usage: stop.sh | ||
|
||
docker-compose down | ||
docker-compose -f docker-compose-init.yml down | ||
set -e | ||
|
||
# Import our helper functions | ||
. ./utils.sh | ||
|
||
prettyHeader "Spinning down iofog Demo environment" | ||
docker-compose down -v | ||
docker-compose -f docker-compose-init.yml down | ||
|
||
echoInfo "ioFog demo is stopped" |
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 |
---|---|---|
@@ -1,17 +1,39 @@ | ||
#!/usr/bin/env sh | ||
# test.sh - Run the iofog Test Runner suite against the Demo environment | ||
# | ||
# Usage: test.sh | ||
|
||
set -e | ||
|
||
# Import our helper functions | ||
. ./utils.sh | ||
|
||
prettyHeader "Running Test Runner Suite" | ||
|
||
# Output the config for our Test suite config | ||
echo 'iofog-connector:8080' > conf/connector.conf | ||
echo 'iofog-controller:51121' > conf/controller.conf | ||
echo 'root@iofog-agent-1' > conf/agents.conf | ||
echo 'root@iofog-agent-2' >> conf/agents.conf | ||
echo 'root@iofog-agent' > conf/agents.conf | ||
|
||
# Check to see if we are already running the Demo | ||
NUM_CONTAINERS=$(docker-compose ps | grep iofog | grep Up | wc -l | awk '{print $1}') | ||
|
||
if [ "$NUM_CONTAINERS" -eq "3" ]; then | ||
echoInfo "Demo compose environment is already running" | ||
else | ||
echoInfo "Spinning up Demo compose environment" | ||
docker-compose -f docker-compose.yml up | ||
fi | ||
|
||
echoInfo "Pulling Test Runner Image" | ||
docker-compose -f docker-compose-test.yml pull test-runner | ||
|
||
echoInfo "Running Test Runner suite" | ||
docker-compose -f docker-compose-test.yml up \ | ||
--build \ | ||
--abort-on-container-exit \ | ||
--exit-code-from test-runner \ | ||
--force-recreate \ | ||
--renew-anon-volumes | ||
--renew-anon-volumes | ||
|
||
echoNotify "Test Runner Tests complete" |
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,130 @@ | ||
#!/usr/bin/env sh | ||
# utils.sh - a simple set of functions for use throughout our bash scripts | ||
# | ||
# Usage : source utils.sh | ||
|
||
|
||
# Export the name of the script for later use | ||
THIS_SCRIPT="$(basename "${0}")" | ||
export THIS_SCRIPT | ||
|
||
# | ||
# Check for DEBUG - looks for the DEBUG environment variable. If it | ||
# is found, it enables more debugging output. | ||
checkForDebug() { | ||
|
||
# Allow anyone to set a DEBUG environment variable for extra output | ||
if env | grep -q "DEBUG"; then | ||
echoNotify " :: DEBUG is set ::" | ||
set -x | ||
fi | ||
} | ||
|
||
# | ||
# Display a nice header for any command line script. You can optionally populate it with a string | ||
# | ||
# Usage: prettyHeader "Bootstrapping ioFog" | ||
# | ||
prettyHeader() { | ||
echoInfo "## $1 ####################################################" | ||
echoInfo "## Copyright (C) 2019, Edgeworx, Inc." | ||
echo | ||
} | ||
|
||
# | ||
# Extract and display our script options in a pretty manner | ||
# | ||
# Usage: prettyUsage ${THIS_SCRIPT} | ||
# | ||
prettyUsage() { | ||
|
||
grep -e '--.*")' <"${1}" | grep -v 'grep -e' | tr -d '"' | tr ')' '\t' | ||
} | ||
|
||
# | ||
# Check for Installation will check to see whether a particular command exists in | ||
# the $PATH of the current shell. Optionally, you can check for a specific version. | ||
# | ||
# Usage: checkForInstallation protoc "libprotoc 3.6.1" | ||
# | ||
checkForInstallation() { | ||
|
||
# Does the command exist? | ||
if [ ! "$(command -v "$1")" ]; then | ||
echoError " ✖️ $1 not found please review your bootstrap script for missing dependencies" | ||
exit 1 | ||
else | ||
# Are we looking for a specific version? | ||
if [ ! -z "$2" ]; then | ||
if [ "$2" != "$($1 --version)" ]; then | ||
echoError " ✖️ $1 is the wrong version. Found $($1 --version) but expected $2" | ||
exit 1 | ||
fi | ||
fi | ||
echoSuccess " ✔️ $1 $2 found at $(command -v "$1")" | ||
return 0 | ||
fi | ||
} | ||
|
||
# | ||
# Check OS Platform attempts to determine which platform we're running on currently. | ||
# It will export the results into two env variables that can be used in your scripts: | ||
# $OS_ID - the name of the host os. E.g. ubuntu | ||
# $D_NUM - the version number of the os E.g. 16 | ||
# | ||
checkOSPlatform() { | ||
if [ "$(uname -s)" = "Darwin" ]; then | ||
ID=macos | ||
D_NUM="$(sysctl kern.osproductversion | awk '{print $2}' | awk -F '.' '{print $1}')" | ||
else | ||
. /etc/os-release | ||
D_NUM="$(echo ${VERSION_ID} | awk -F '.' '{print $1}')" | ||
|
||
# Push us into privileged if we aren't already | ||
if [ ! "$(id -u)" = "0" ] && [ ! "$1" = "--help" ]; then | ||
echoNotify " If you are a new developer please run this script with --help" | ||
exec sudo -E "PATH=$PATH" sh "${THIS_SCRIPT}" "$@" | ||
fi | ||
fi | ||
|
||
export ID D_NUM | ||
} | ||
|
||
# | ||
# The following are a bunch or pretty printing echo methods | ||
# | ||
|
||
# This is the list of colors used in our messages | ||
NO_FORMAT="\\033[0m" | ||
C_SKYBLUE1="\\033[38;5;117m" | ||
C_DEEPSKYBLUE4="\\033[48;5;25m" | ||
RED="\\033[38;5;1m" | ||
GREEN="\\033[38;5;28m" | ||
|
||
# Need this as bash and sh require different args for the echo command | ||
if [ "${ISBASH}" ]; then | ||
PRINTARGS="-e" | ||
fi | ||
|
||
# Basic subtle output | ||
echoInfo() { | ||
echo $PRINTARGS "${C_SKYBLUE1}$1 ${NO_FORMAT}" | ||
} | ||
|
||
# Highlighted output with a background | ||
echoNotify() { | ||
echo $PRINTARGS "${C_DEEPSKYBLUE4}${1} ${NO_FORMAT}" | ||
} | ||
|
||
# Hurrah! | ||
echoSuccess() { | ||
echo $PRINTARGS "${GREEN}$1 ${NO_FORMAT}" | ||
} | ||
|
||
# Houston, we have a problem! | ||
echoError() { | ||
echo $PRINTARGS "${RED}$1 ${NO_FORMAT}" | ||
} | ||
|
||
# Are we in debug mode? | ||
checkForDebug |