Commit 78d65739 authored by Greg Williams's avatar Greg Williams
Browse files

Updated simulator integration to allow X number of simulators to be started....

Updated simulator integration to allow X number of simulators to be started. Default is still 2 simulators, but can be configured for  Make and to the vendor/kinetic-simulator/startSimulators.sh via NUM_SIMS environment variable.
Cleaned up log formatting to use consistent case for addresses for easier inspection of log info.
parent 12ab7bf5
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -26,6 +26,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
@@ -293,11 +294,15 @@ 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

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

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

stop_simulator: stop_sims

.PHONY: update_simulator erase_simulator stop_simulator

+8 −5
Original line number Diff line number Diff line
@@ -192,9 +192,10 @@ void KineticController_HandleUnexecpectedResponse(void *msg,
    (void)seq_id;
    (void)bus_udata;

    LOGF2("[PDU RX UNSOLICITED] pdu: 0x%0llX, session: 0x%llX, bus: 0x%llX, "
    LOGF2("[PDU RX UNSOLICITED] pdu: %p, session: %p, bus: %p, "
                "fd: %6d, protoLen: %u, valueLen: %u",
                response, connection->pSession, connection->messageBus, connection->socket,
                (void*)response, (void*)connection->pSession,
                (void*)connection->messageBus, connection->socket,
                response->header.protobufLength, response->header.valueLength);

    // Handle unsolicited status PDUs
@@ -247,10 +248,12 @@ void KineticController_HandleExpectedResponse(bus_msg_result_t *res, void *udata
            status = KINETIC_STATUS_INVALID;
        }

        LOGF2("[PDU RX] pdu: 0x%0llX, op: 0x%llX, session: 0x%llX, bus: 0x%llX, fd: %6d, "
        LOGF2("[PDU RX] pdu: %p, op: %p, session: %p, bus: %p, fd: %6d, "
            "seq: %5lld, protoLen: %4u, valueLen: %u, status: %s",
            response, op, op->connection->pSession, op->connection->messageBus, op->connection->socket, 
            response->command->header->ackSequence, response->header.protobufLength, response->header.valueLength,
            (void*)response, (void*)op,
            (void*)op->connection->pSession, (void*)op->connection->messageBus,
            op->connection->socket, response->command->header->ackSequence,
            response->header.protobufLength, response->header.valueLength,
            Kinetic_GetStatusDescription(status));
        KineticLogger_LogHeader(3, &response->header);
        KineticLogger_LogProtobuf(3, response->proto);
+2 −1
Original line number Diff line number Diff line
@@ -155,7 +155,8 @@ static KineticStatus KineticOperation_SendRequestInner(KineticOperation* const o
    assert(operation->request);
    assert(operation->connection);
    assert(request);
    LOGF2("[PDU TX] pdu: %p, op: %p, session: %p, bus: %p, fd: %6d, seq: %5lld, protoLen: %4u, valueLen: %u",
    LOGF2("[PDU TX] pdu: %p, op: %p, session: %p, bus: %p, fd: %6d, "
        "seq: %5lld, protoLen: %4u, valueLen: %u",
        (void*)operation->request, (void*)operation,
        (void*)operation->connection->pSession, (void*)operation->connection->messageBus,
        operation->connection->socket, request->message.header.sequence,
+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
+55 −0
Original line number Diff line number Diff line
@@ -20,8 +20,36 @@ 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")
      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
Loading