Skip to content

Commit

Permalink
Colorize different outputs differently for visual disambiguation
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Sep 18, 2021
1 parent e334c1b commit 0861ffc
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions testExamples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
set -e # Fail on error
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT # Kill subprocesses on exit

highlight() { grep --color -E "\S|$" "${@:1}" ; }
echo "Comments and Results => Black"
highlightServer () { export GREP_COLORS='ms=0;32'; highlight ; }
echo "Server => Green" | highlightServer
highlightClient () { export GREP_COLORS='ms=0;34'; highlight ; }
echo "Client => Blue" | highlightClient
highlightSupport () { export GREP_COLORS='ms=0;33'; highlight ; }
echo "Support => Yellow" | highlightSupport
highlightGradle () { export GREP_COLORS='ms=0;36'; highlight ; }
echo "Gradle => Cyan" | highlightGradle
lastStartedPid () { jobs -p | tail -n 1; }

build() {
echo "Building project"
./gradlew clean --console=plain
./gradlew build --console=plain
./gradlew clean --console=plain |& highlightGradle
./gradlew build --console=plain |& highlightGradle
sleep 2s
}

Expand All @@ -14,11 +26,11 @@ localTest() {
echo "Starting Local test"

# Run environment
./gradlew :example:local-grpc-server:bootRun -x jar -x classes --console=plain &
LOCAL_SERVER=$!
./gradlew :example:local-grpc-server:bootRun -x jar -x classes --console=plain |& highlightServer &
LOCAL_SERVER=`lastStartedPid`
sleep 10s # Wait for the server to start
./gradlew :example:local-grpc-client:bootRun -x jar -x classes --console=plain &
LOCAL_CLIENT=$!
./gradlew :example:local-grpc-client:bootRun -x jar -x classes --console=plain |& highlightClient &
LOCAL_CLIENT=`lastStartedPid`
sleep 30s # Wait for the client to start and the server to be ready

# Test
Expand Down Expand Up @@ -56,19 +68,21 @@ cloudTest() {
# Run environment
if [[ "$1" = "consul" ]]; then
CONSUL=`docker run --name=consul -d --rm -p 8500:8500 consul`
docker logs -f $CONSUL |& highlightSupport &
stopCloudEnv() {
echo "Stopping consul server"
docker stop $CONSUL
}
elif [[ "$1" == "eureka" ]]; then
./gradlew :example:cloud-eureka-server:bootRun -x jar -x classes --console=plain &
EUREKA=$!
./gradlew :example:cloud-eureka-server:bootRun -x jar -x classes --console=plain |& highlightSupport &
EUREKA=`lastStartedPid`
stopCloudEnv() {
echo "Stopping eureka server"
kill -s TERM $EUREKA
}
elif [[ "$1" = "nacos" ]]; then
NACOS=`docker run --env MODE=standalone --name nacos -d --rm -p 8848:8848 nacos/nacos-server`
docker logs -f $NACOS |& highlightSupport &
stopCloudEnv() {
echo "Stopping nacos server"
docker stop $NACOS
Expand All @@ -83,16 +97,16 @@ cloudTest() {
# curl -sSL https://zipkin.io/quickstart.sh | bash -s
# fi
# java -jar zipkin.jar &
# ZIPKIN=$!
# ZIPKIN=`lastStartedPid`
# sleep 10s # Wait for the server to start
# cd ..

./gradlew -Pdiscovery=$1 :example:cloud-grpc-server:bootRun -x jar -x classes --console=plain &
CLOUD_SERVER=$!
./gradlew -Pdiscovery=$1 :example:cloud-grpc-server:bootRun -x jar -x classes --console=plain |& highlightServer &
CLOUD_SERVER=`lastStartedPid`
sleep 10s # Wait for the server to start

./gradlew -Pdiscovery=$1 :example:cloud-grpc-client:bootRun -x jar -x classes --console=plain &
CLOUD_CLIENT=$!
./gradlew -Pdiscovery=$1 :example:cloud-grpc-client:bootRun -x jar -x classes --console=plain |& highlightClient &
CLOUD_CLIENT=`lastStartedPid`
sleep 30s # Wait for the client to start and the server to be ready
sleep 60s # Wait for the discovery service to refresh

Expand All @@ -111,8 +125,8 @@ cloudTest() {
sleep 1s # Wait for the shutdown logs to pass

# and restart server
./gradlew -Pdiscovery=$1 :example:cloud-grpc-server:bootRun -x jar -x classes --console=plain &
CLOUD_SERVER=$!
./gradlew -Pdiscovery=$1 :example:cloud-grpc-server:bootRun -x jar -x classes --console=plain |& highlightServer &
CLOUD_SERVER=`lastStartedPid`
sleep 30s # Wait for the server to start
sleep 60s # Wait for the discovery service to refresh

Expand Down Expand Up @@ -163,11 +177,11 @@ securityBasicAuthTest() {
echo "Starting Security Basic Auth test"

# Run environment
./gradlew :example:security-grpc-server:bootRun -x jar -x classes --console=plain &
LOCAL_SERVER=$!
./gradlew :example:security-grpc-server:bootRun -x jar -x classes --console=plain |& highlightServer &
LOCAL_SERVER=`lastStartedPid`
sleep 10s # Wait for the server to start
./gradlew :example:security-grpc-client:bootRun -x jar -x classes --console=plain &
LOCAL_CLIENT=$!
./gradlew :example:security-grpc-client:bootRun -x jar -x classes --console=plain |& highlightClient &
LOCAL_CLIENT=`lastStartedPid`
sleep 30s # Wait for the client to start and the server to be ready

# Test
Expand Down

0 comments on commit 0861ffc

Please sign in to comment.