Commit c7da83c4 authored by Greg Williams's avatar Greg Williams
Browse files

Pulled in Java simulator support changes from 'develop' to better support...

Pulled in Java simulator support changes from 'develop' to better support starting/stopping X number of simulators (via NUM_SIMS environment variable, defaults to 2).
Merged in some Makefile cleanup from 'develop' better integrate json-c into development builds.
Added explicit json_install/json_uninstall tasks which are NOT tied into default Make install/uninstall tasks for the lib.
parent 61b33af2
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ WARN = -Wall -Wextra -Werror -Wstrict-prototypes -Wcast-align -pedantic -Wno-mis
CDEFS += -D_POSIX_C_SOURCE=199309L -D_C99_SOURCE=1 -DSYSTEM_TEST_HOST=${SYSTEM_TEST_HOST}
CFLAGS += -std=c99 -fPIC -g $(WARN) $(CDEFS) $(OPTIMIZE)
LDFLAGS += -lm -L${OPENSSL_PATH}/lib -lcrypto -lssl -lpthread -ljson-c
NUM_SIMS ?= 2

#===============================================================================
# Kinetic-C Library Build Support
@@ -101,11 +102,10 @@ clean: makedirs update_git_submodules
	rm -rf ./bin/**/*
	rm -f $(OUT_DIR)/*.o $(OUT_DIR)/*.a *.core *.log
	bundle exec rake clobber
	-./vendor/kinetic-simulator/stopSimulator.sh &> /dev/null;
	cd ${SOCKET99} && make clean
	cd ${LIB_DIR}/threadpool && make clean
	cd ${LIB_DIR}/bus && make clean
	# cd ${JSONC} && make clean --- make clean task does NOT exist
	if [ -f ${JSONC}/Makefile ]; then cd ${JSONC} && make clean; fi;

update_git_submodules:
	git submodule update --init
@@ -144,8 +144,11 @@ $(OUT_DIR)/%.o: ${LIB_DIR}/bus/%.c ${LIB_DIR}/bus/%.h

${OUT_DIR}/*.o: src/lib/kinetic_types_internal.h


ci: uninstall all stop_simulator test_internals install
ci: stop_sims start_sims all stop_sims
	@echo 
	@echo Testing installation/uninstallation of kinetic-c
	sudo make install
	sudo make uninstall
	@echo
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) build completed successfully!
@@ -160,6 +163,13 @@ ci: uninstall all stop_simulator test_internals install

json: ${OUT_DIR}/libjson-c.a

json_install: json
	cd ${JSONC} && \
	make install

json_uninstall:
	if [ -f ${JSONC}/Makefile ]; then cd ${JSONC} && make uninstall; fi;

${JSONC}/Makefile:
	cd ${JSONC} && \
	sh autogen.sh && \
@@ -172,6 +182,7 @@ ${JSONC}/.libs/libjson-c.a: ${JSONC}/Makefile
${OUT_DIR}/libjson-c.a: ${JSONC}/.libs/libjson-c.a
	cp ${JSONC}/.libs/libjson-c.a ${OUT_DIR}/libjson-c.a


#-------------------------------------------------------------------------------
# Test Support
#-------------------------------------------------------------------------------
@@ -282,13 +293,18 @@ update_simulator:
	cd vendor/kinetic-java; mvn clean package; cd -
	cp vendor/kinetic-java/kinetic-simulator/target/*.jar vendor/kinetic-java-simulator/

start_simulator:
	./vendor/kinetic-simulator/start2Simulators.sh
start_sims:
	./vendor/kinetic-simulator/startSimulators.sh
 		 
start_simulator: start_sims

stop_sims:
	./vendor/kinetic-simulator/stopSimulators.sh

stop_simulator: stop_sims

stop_simulator:
	./vendor/kinetic-simulator/stopSimulator.sh

.PHONY: update_simulator erase_simulator stop_simulator
.PHONY: update_simulator start_sims start_simulator stop_sims stop_simulator



+0 −57
Original line number Diff line number Diff line
#! /usr/bin/env bash
BASE_DIR=`dirname "$0"`
BASE_DIR=`cd "$BASE_DIR"; pwd`

JAVA=""
if [ "$JAVA_HOME" != "" ]; then
   JAVA=$JAVA_HOME/bin/java
else
   JAVA_HOME='/usr'
   JAVA=`which java`
fi

#Set the classpath
if [ "$CLASSPATH" != "" ]; then
   CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
else
   CLASSPATH=$JAVA_HOME/lib/tools.jar
fi
for f in $BASE_DIR/*.jar; do
   CLASSPATH=${CLASSPATH}:$f
done

if ! netstat -an | grep LISTEN | grep "[\.:].8123"; then
    exec "$JAVA" -classpath "$CLASSPATH" com.seagate.kinetic.simulator.internal.SimulatorRunner "$@" -port 8123 -tlsport 8443 -home ~/kinetic1 &  
fi

if ! netstat -an | grep LISTEN | grep "[\.:].8124"; then
    exec "$JAVA" -classpath "$CLASSPATH" com.seagate.kinetic.simulator.internal.SimulatorRunner "$@" -port 8124 -tlsport 8444 -home ~/kinetic2 &
fi

# if ! netstat -an | grep LISTEN | grep "[\.:].8125"; then
#     exec "$JAVA" -classpath "$CLASSPATH" com.seagate.kinetic.simulator.internal.SimulatorRunner "$@" -port 8125 -tlsport 8445 -home ~/kinetic3 &
# fi

# if ! netstat -an | grep LISTEN | grep "[\.:].8126"; then
#     exec "$JAVA" -classpath "$CLASSPATH" com.seagate.kinetic.simulator.internal.SimulatorRunner "$@" -port 8126 -tlsport 8446 -home ~/kinetic4 &
# fi

while ! netstat -an | grep LISTEN | grep "[\.:]8123"
do sleep 1; done
while ! netstat -an | grep LISTEN | grep "[\.:]8443"
do sleep 1; done

while ! netstat -an | grep LISTEN | grep "[\.:]8124"
do sleep 1; done
while ! netstat -an | grep LISTEN | grep "[\.:]8444"
do sleep 1; done

# while ! netstat -an | grep LISTEN | grep "[\.:]8125"
# do sleep 1; done
# while ! netstat -an | grep LISTEN | grep "[\.:]8445"
# do sleep 1; done

# while ! netstat -an | grep LISTEN | grep "[\.:]8126"
# do sleep 1; done
# while ! netstat -an | grep LISTEN | grep "[\.:]8446"
# do sleep 1; done
+57 −0
Original line number Diff line number Diff line
@@ -20,8 +20,38 @@ for f in $BASE_DIR/*.jar; do
   CLASSPATH=${CLASSPATH}:$f
done

if ! netstat -an | grep LISTEN | grep "[\.:].8123"; then
    exec "$JAVA" -classpath "$CLASSPATH" com.seagate.kinetic.simulator.internal.SimulatorRunner "$@" &
    while ! netstat -an | grep LISTEN | grep "[\.:]8123"
    do sleep 1; done
if [ "$NUM_SIMS" != "" ]; then
   LIMIT=$NUM_SIMS
else
   LIMIT=2
fi

let BASE_PORT=8123
let BASE_TLS_PORT=8443
SIM="com.seagate.kinetic.simulator.internal.SimulatorRunner"
new_ports=()

echo Starting $LIMIT kinetic simulators...
let index=0
while [ $index -lt $LIMIT ]; do
   let NUM=$index+1
   let PORT=$BASE_PORT+$index
   let TLS_PORT=$BASE_TLS_PORT+$index
   if ! netstat -an | grep LISTEN | grep "[\.:]$PORT"; then
      echo Starting simulator instance $NUM of $LIMIT
      new_ports=("${new_ports[@]}" "$PORT" "$TLS_PORT")
      mkdir -p ~/kinetic$NUM
      exec "$JAVA" -classpath "$CLASSPATH" $SIM "$@" -port $PORT -tlsport $TLS_PORT -home ~/kinetic$NUM &> ~/kinetic$NUM/kinetic-sim.log &
   fi
   let index=index+1
done

for port in "${new_ports[@]}"; do
   echo Waiting for simulator on port $port
   while ! netstat -an | grep LISTEN | grep "[\.:]$PORT"
   do sleep 1; done
done

echo
echo Successfully started $LIMIT kinetic simulators
+26 −0
Original line number Diff line number Diff line
#! /usr/bin/env bash

function get_running_sims() {
  echo 
}

# Kill any simulators running
_SIMS=`ps -ef | grep "kinetic-simulator/kinetic-simulator-" | grep -v 'grep' | sed -e 's/^ *//' -e 's/ *$//' | tr -s ' ' | cut -d ' ' -f 2`
if [[ ! -z $_SIMS ]]; then
@@ -10,5 +14,13 @@ if [[ ! -z $_SIMS ]]; then
      kill $sim
    fi
  done

  _SIMS=`ps -ef | grep "kinetic-simulator/kinetic-simulator-" | grep -v 'grep' | sed -e 's/^ *//' -e 's/ *$//' | tr -s ' ' | cut -d ' ' -f 2`
  while [[ ! -z $_sims ]]; do
     echo Waiting for simulators to shutdown...
     sleep 1
     _SIMS=`ps -ef | grep "kinetic-simulator/kinetic-simulator-" | grep -v 'grep' | sed -e 's/^ *//' -e 's/ *$//' | tr -s ' ' | cut -d ' ' -f 2`
  done

  echo All simulators have been terminated!
fi
Loading