You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2017/04/13 13:53:12 UTC

celix git commit: CELIX-408: Adds support to specifiy command arguments for deployments. Adds runtime test for pubsub zmq. Fixes init bug in topic_publication/subscription

Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-408_runtime 95913dd1f -> 4b723e44d


CELIX-408: Adds support to specifiy command arguments for deployments. Adds runtime test for pubsub zmq. Fixes init bug in topic_publication/subscription


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/4b723e44
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/4b723e44
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/4b723e44

Branch: refs/heads/feature/CELIX-408_runtime
Commit: 4b723e44d6f11a634698e9652d5a4a57a5b12852
Parents: 95913dd
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Thu Apr 13 15:51:53 2017 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Thu Apr 13 15:51:53 2017 +0200

----------------------------------------------------------------------
 cmake/cmake_celix/DeployPackaging.cmake         |   4 +-
 cmake/cmake_celix/Runtimes.cmake                |  30 ++++-
 cmake/cmake_celix/runtime_common.sh.in          | 121 +++++++++++++------
 cmake/cmake_celix/runtime_start.sh.in           |  15 +--
 .../private/src/pubsub_admin_impl.c             |   3 +-
 .../private/src/topic_publication.c             |   1 -
 .../private/src/topic_subscription.c            |   9 +-
 .../private/src/pubsub_admin_impl.c             |   5 +-
 .../private/src/topic_subscription.c            |   9 +-
 pubsub/test/CMakeLists.txt                      |  49 +++++++-
 10 files changed, 174 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/cmake/cmake_celix/DeployPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DeployPackaging.cmake b/cmake/cmake_celix/DeployPackaging.cmake
index 626b7b8..8de60ba 100644
--- a/cmake/cmake_celix/DeployPackaging.cmake
+++ b/cmake/cmake_celix/DeployPackaging.cmake
@@ -174,7 +174,9 @@ $<JOIN:$<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_PROPERTIES>,
     set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_COPY_BUNDLES" ${DEPLOY_COPY}) #copy bundles in bundle dir or link using abs paths. NOTE this cannot be changed after a add_deploy command
 
     #deploy specific
-    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_LOCATION" ${DEPLOY_LOCATION})
+    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_NAME" "${DEPLOY_NAME}")
+    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_GROUP" "${DEPLOY_GROUP}")
+    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_LOCATION" "${DEPLOY_LOCATION}")
     set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_PROPERTIES" "")
     #####
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/cmake/cmake_celix/Runtimes.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/Runtimes.cmake b/cmake/cmake_celix/Runtimes.cmake
index 14f88eb..a4e3ae5 100644
--- a/cmake/cmake_celix/Runtimes.cmake
+++ b/cmake/cmake_celix/Runtimes.cmake
@@ -10,7 +10,7 @@ function(add_runtime)
 
     set(OPTIONS USE_TERM LOG_TO_FILES)
     set(ONE_VAL_ARGS WAIT_FOR NAME GROUP)
-    set(MULTI_VAL_ARGS DEPLOYMENTS COMMANDS)
+    set(MULTI_VAL_ARGS DEPLOYMENTS COMMANDS ARGUMENTS)
     cmake_parse_arguments(RUNTIME "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN})
 
     if (NOT RUNTIME_NAME)
@@ -43,6 +43,7 @@ function(add_runtime)
 
     set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_DEPLOYMENTS" "") #deployments that should be runned
     set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_COMMANDS" "") #command that should be executed
+    set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_ARGUMENTS" "") #potential arguments to use for deployments
     set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_NAME" "${RUNTIME_NAME}") #The runtime workdir
     set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_GROUP" "${RUNTIME_GROUP}") #The runtime workdir
     set_target_properties(${RUNTIME_TARGET_NAME} PROPERTIES "RUNTIME_LOCATION" "${RUNTIME_LOCATION}") #The runtime workdir
@@ -90,6 +91,7 @@ function(add_runtime)
 
     runtime_deployments(${RUNTIME_TARGET_NAME} ${RUNTIME_DEPLOYMENTS})
     runtime_commands(${RUNTIME_TARGET_NAME} ${RUNTIME_COMMANDS})
+    runtime_arguments(${RUNTIME_TARGET_NAME} ${RUNTIME_ARGUMENTS})
 
     if (RUNTIME_WAIT_FOR)
         runtime_deployment_wait_for(${RUNTIME_TARGET_NAME} ${RUNTIME_WAIT_FOR})
@@ -121,7 +123,8 @@ function(runtime_deployments)
 
     get_target_property(DEPLOYMENTS ${RUNTIME_NAME} "RUNTIME_DEPLOYMENTS")
     foreach(DEPLOYMENT IN ITEMS ${ARGN})
-	    list(APPEND DEPLOYMENTS "$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_LOCATION>")
+        list(APPEND DEPLOYMENTS "DEPLOYMENTS[$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_NAME>]=\"$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_LOCATION>\"")
+	    #list(APPEND DEPLOYMENTS "$<TARGET_PROPERTY:${DEPLOYMENT},DEPLOY_LOCATION>")
    endforeach()
 
    set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_DEPLOYMENTS" "${DEPLOYMENTS}")
@@ -151,11 +154,30 @@ function(runtime_commands)
 endfunction()
 
 function(runtime_command_wait_for)
-    #0 is deploy TARGET
+    #0 is runtime TARGET
     #1 is COMMAND STR
     list(GET ARGN 0 RUNTIME_NAME)
     list(GET ARGN 1 COMMAND)
 
     set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_WAIT_FOR_COMMAND" "${COMMAND}")
     set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_WAIT_FOR_DEPLOYMENT" "")
-endfunction()
\ No newline at end of file
+endfunction()
+
+function(runtime_arguments)
+    #0 is runtime TARGET
+    #1..n is commands
+    list(GET ARGN 0 RUNTIME_NAME)
+    list(REMOVE_AT ARGN 0)
+
+    get_target_property(ARGUMENTS ${RUNTIME_NAME} "RUNTIME_ARGUMENTS")
+    list(LENGTH ARGN ARG_LENGTH)
+    if (${ARG_LENGTH} GREATER 1)
+        foreach(I RANGE 1 ${ARG_LENGTH} 2)
+            math(EXPR IMINUS "${I}-1")
+            list(GET ARGN ${IMINUS} ARG_NAME)
+            list(GET ARGN ${I} ARG_VAL)
+            list(APPEND ARGUMENTS "ARGUMENTS[$<TARGET_PROPERTY:${ARG_NAME},DEPLOY_NAME>]=\"${ARG_VAL}\"")
+        endforeach()
+    endif ()
+    set_target_properties(${RUNTIME_NAME} PROPERTIES "RUNTIME_ARGUMENTS" "${ARGUMENTS}")
+endfunction()

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/cmake/cmake_celix/runtime_common.sh.in
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/runtime_common.sh.in b/cmake/cmake_celix/runtime_common.sh.in
index a3c6ac3..9dce713 100644
--- a/cmake/cmake_celix/runtime_common.sh.in
+++ b/cmake/cmake_celix/runtime_common.sh.in
@@ -10,9 +10,16 @@ RUNTIME_NAME="${RUNTIME_NAME:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_NA
 RUNTIME_GROUP="${RUNTIME_NAME:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_GROUP>}"
 
 #deployments & commands
-DEPLOYMENTS=${DEPLOYMENTS:-"$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_DEPLOYMENTS>, >"}
 COMMANDS=${COMMANDS:-"$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_COMMANDS>, >"}
 
+declare -A DEPLOYMENTS
+$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_DEPLOYMENTS>,
+>
+
+declare -A ARGUMENTS
+$<JOIN:$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_ARGUMENTS>,
+>
+
 #Options
 TERM_CMD="${TERM_CMD:-xterm}"
 TERM_OPTS="${TERM_OPTS:-}"
@@ -21,24 +28,40 @@ RELEASE_SH="${RELEASE_SH:-}"
 WAIT_FOR_DEPLOYMENT="${WAIT_FOR_DEPLOYMENT:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_WAIT_FOR_DEPLOYMENT>}"
 WAIT_FOR_CMD="${WAIT_FOR_CMD:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_WAIT_FOR_COMMAND>}"
 LOG_TO_FILES="${LOG_TO_FILES:-$<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_LOG_TO_FILES>}"
-KILL_OPTS="${KILL_OPTS:-}"
+KILL_OPTS="${KILL_OPTS:--2}" #default is -2, e.g. SIGINT
+PATIENCE="${PATIENCE:-5}" #in seconds
 
 PIDS=""
 WAIT_FOR_PID=""
-LOG_SUFFIX=$(date +"%s")
+RUNTIME_STARTTIME=$(date +"%s")
 trap stop_all INT
 
-#clear dirs
+##functions
 function rt_init() {
     rm -fr ${RUNTIME_DIR}/run #contains pids, etc
+    rm -fr ${RUNTIME_DIR}/logs
     mkdir ${RUNTIME_DIR}/run
-    if [ ! -e ${RUNTIME_DIR}/logs ] ; then
-        mkdir ${RUNTIME_DIR}/logs
-    fi
+    mkdir ${RUNTIME_DIR}/logs
+    echo "Name: ${RUNTIME_NAME}" > ${RUNTIME_DIR}/logs/init.log
+    echo "Start time: ${RUNTIME_STARTTIME}" >> ${RUNTIME_DIR}/logs/init.log
+}
+
+function rt_start_all() {
+    echo ""
+    echo ""
+    echo "********** Starting runtime ${RUNTIME_NAME} **********"
+    for DEPLOYMENT in "${!DEPLOYMENTS[@]}"
+    do
+        rt_run_deployment ${DEPLOYMENT}
+    done
+
+    for CMD in ${COMMANDS}; do
+        rt_run_cmd "${CMD}"
+    done
 }
 
-##functions
 function rt_stop_all() {
+    echo "********** Stopping runtime ${RUNTIME_NAME} **********"
     for PID in ${PIDS}; do
         echo "Sending signal to ${PID}"
         kill ${KILL_OPTS} ${PID}
@@ -52,31 +75,37 @@ function rt_stop() {
 }
 
 function rt_run_deployment() {
-    DEPLOYMENT_DIR=$1
-    DEPLOYMENT=$(basename ${DEPLOYMENT_DIR})
-    LOG_FILE="${RUNTIME_DIR}/logs/${DEPLOYMENT}-${LOG_SUFFIX}.log"
-    echo "Running ${DEPLOYMENT}"
-    cd ${DEPLOYMENT_DIR} #assuming absolute dir
+    DEPLOYMENT=$1
+    DEPLOYMENT_DIR=${DEPLOYMENTS[${DEPLOYMENT}]}
+    ARGS=${ARGUMENTS[${DEPLOYMENT}]}
+    LOG_FILE="${RUNTIME_DIR}/logs/${DEPLOYMENT}.log"
+    echo ""
+    echo "Starting deployment ${DEPLOYMENT}"
+    cd ${DEPLOYMENT_DIR}
     if [ -d .cache ] ; then
-        echo "Clearing cache"
+        echo "  Clearing cache"
         rm -fr .cache
     fi
     . ./release.sh #run deployment release
+    echo "  Workdir: ${DEPLOYMENT_DIR}"
+    echo "  Cmd used: './${DEPLOYMENT} ${ARGS}'"
     if [ "${USE_TERM}" = "TRUE" ] ; then
         if [ "${LOG_TO_FILES}" = "TRUE" ] ; then
-            ${TERM_CMD} ${TERM_OPTS} -e "./${DEPLOYMENT} &> ${LOG_FILE}" &
+            echo "  Using log file ${LOG_FILE}"
+            ${TERM_CMD} ${TERM_OPTS} -e "./${DEPLOYMENT} ${ARGS} &> ${LOG_FILE}"  &> /dev/null &
         else
-            ${TERM_CMD} ${TERM_OPTS} -e "./${DEPLOYMENT}" &
+            ${TERM_CMD} ${TERM_OPTS} -e "./${DEPLOYMENT} ${ARGS}" &> /dev/null &
         fi
     else #run in this shell
         if [ "${LOG_TO_FILES}" = "TRUE" ] ; then
-            ./${DEPLOYMENT} &> ${LOG_FILE} &
+            echo "  Using log file ${LOG_FILE}"
+            ./${DEPLOYMENT} ${ARGS} &> ${LOG_FILE} &
         else
-            ./${DEPLOYMENT} &
+            ./${DEPLOYMENT} ${ARGS} &
         fi
     fi
     PID=$!
-    echo "PID of DEPLOYMENT '${DEPLOYMENT}' is ${PID}"
+    echo "  Pid of deployment '${DEPLOYMENT}' is ${PID}"
     if [ ! -z "${WAIT_FOR_DEPLOYMENT}" -a "${DEPLOYMENT_DIR}" = "${WAIT_FOR_DEPLOYMENT}" ] ; then
         WAIT_FOR_PID=${PID}
         echo "${PID}" > ${RUNTIME_DIR}/run/wait_for_pid
@@ -84,28 +113,40 @@ function rt_run_deployment() {
         PIDS="${PID} ${PIDS}"
         echo "${PIDS}" > ${RUNTIME_DIR}/run/pids
     fi
-    cd -
+    cd - > /dev/null
 }
 
 function rt_run_cmd() {
     CMD="$1"
-    LOG_FILE="${RUNTIME_DIR}/logs/${CMD}-${LOG_SUFFIX}.log" #TODO only use first word in case of complex command
-    cd ${RUNTIME_DIR}
+    echo ""
+    echo "Starting command '${CMD}'"
+    read CMD_NAME _ <<< ${CMD}
+    LOG_FILE="${RUNTIME_DIR}/logs/${CMD_NAME}.log"
+    WD="${RUNTIME_DIR}/${CMD_NAME}"
+    if [ -d {WD} ] ; then
+        echo "  Clearing previous workdir for command '${CMD}'"
+        rm -fr ${WD}
+    fi
+    echo "  Workdir: ${WD}"
+    mkdir -p ${WD}
+    cd ${WD}
     if [ "${USE_TERM}" = "TRUE" ] ; then
         if [ "${LOG_TO_FILES}" = "TRUE" ] ; then
-            ${TERM_CMD} ${TERM_OPTS} -e "${CMD} &> ${LOG_FILE}" &
+            echo "  Using log file ${LOG_FILE}"
+            ${TERM_CMD} ${TERM_OPTS} -e "${CMD} &> ${LOG_FILE}" &> /dev/null &
         else
-            ${TERM_CMD} ${TERM_OPTS} -e "${CMD}" &
+            ${TERM_CMD} ${TERM_OPTS} -e "${CMD}" &> /dev/null &
         fi
     else
         if [ "${LOG_TO_FILES}" = "TRUE" ] ; then
-            ${CMD} &> \"${LOG_FILE}\" &
+            echo "  Using log file ${LOG_FILE}"
+            ${CMD} &> ${LOG_FILE} &
         else
             ${CMD} &
         fi
     fi
     PID=$!
-    echo "PID of COMMAND '${CMD}' is ${PID}"
+    echo "  Pid of command '${CMD}' is ${PID}"
     if [ ! -z "${WAIT_FOR_CMD}" -a "${CMD}" = "${MWAIT_FOR_CMD}" ] ; then
         WAIT_FOR_PID=${PID}
         echo "${PID}" > ${RUNTIME_DIR}/run/wait_for_pid
@@ -113,11 +154,12 @@ function rt_run_cmd() {
         PIDS="${PID} ${PIDS}"
         echo "${PIDS}" > ${RUNTIME_DIR}/run/pids
     fi
-    cd -
+    cd - > /dev/null
 }
 
 function rt_wait_for() {
     RESULT=0
+    echo ""
     echo "Waiting for pid ${WAIT_FOR_PID}"
     if wait ${WAIT_FOR_PID}; then
         echo "${WAIT_FOR_PID} exited normal"
@@ -126,12 +168,13 @@ function rt_wait_for() {
         RESULT=1
     fi
 
-    echo "Signalling pids: ${PIDS}"
-    kill -2 ${PIDS}
-    TIMES=15
+    echo "Signalling pids '${PIDS}' with '${KILL_OPTS}'"
+    kill ${KILL_OPTS} ${PIDS}
+    echo -n "Waiting "
+    TIMES=${PATIENCE}
     for (( I=1; I<=TIMES; I++ ))
     do
-        echo "Checking if ${PIDS} are still running. ${I}/${TIMES}"
+        echo -n "."
         kill -0 ${PIDS} &> /dev/null
         if [ $? -eq 1 ] ; then #e.g. no such process result
             #all process stopped
@@ -140,14 +183,16 @@ function rt_wait_for() {
             sleep 1
         fi
     done
+    echo ""
 
-    kill -0 ${PIDS} &> /dev/null
-    if [ $? -eq 0 ] ; then
-        echo "Using kill -9 to ensure processes are killed"
-        kill -9 ${PIDS}
-    fi
-
-    echo ${RESULT}
+    for PID in ${PIDS}; do
+        kill -0 ${PID} &> /dev/null
+        if [ $? -eq 0 ] ; then
+            NAME=$(ps -p ${PID} -o comm | tail -n 1)
+            echo "Out of patience, killing process '${NAME}' (${PID}), with kill -9"
+            kill -9 ${PID}
+        fi
+    done
 }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/cmake/cmake_celix/runtime_start.sh.in
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/runtime_start.sh.in b/cmake/cmake_celix/runtime_start.sh.in
index e7e94f6..a6524de 100644
--- a/cmake/cmake_celix/runtime_start.sh.in
+++ b/cmake/cmake_celix/runtime_start.sh.in
@@ -1,23 +1,12 @@
 #!/bin/sh
 source $<TARGET_PROPERTY:@RUNTIME_TARGET_NAME@,RUNTIME_LOCATION>/common.sh
 
-echo "Starting runtime ${RUNTIME_NAME}"
-
 rt_init
-
-for DEPLOYMENT_DIR in ${DEPLOYMENTS}; do
-    rt_run_deployment ${DEPLOYMENT_DIR}
-done
-
-for CMD in ${COMMANDS}; do
-    rt_run_cmd "${CMD}"
-done
-
-echo "PIDS are ${PIDS}."
+rt_start_all
 
 if [ ! -z "${WAIT_FOR_PID}" ] ; then
     rt_wait_for #sets RESULT
-    echo "RESULT is ${RESULT}"
+    echo "********** Runtime ${RUNTIME_NAME} result is ${RESULT} **********"
     exit ${RESULT}
 fi
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c b/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
index d6f9b09..cf63c25 100644
--- a/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
+++ b/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
@@ -432,7 +432,8 @@ celix_status_t pubsubAdmin_addPublication(pubsub_admin_pt admin,pubsub_endpoint_
 		if (factory == NULL) {
 			topic_publication_pt pub = NULL;
 			status = pubsub_topicPublicationCreate(admin->sendSocket, pubEP, admin->mcIpAddress,&pub);
-			pubsub_topicPublicationSetSerializer(pub, admin->serializerSvc);
+			pubsub_topicPublicationSetSerializer(pub, admin->serializerSvc); //TODO move back to contructor
+			//TODO this is certainly needed when admin are created per available serializer
 			if(status == CELIX_SUCCESS){
 				status = pubsub_topicPublicationStart(admin->bundle_context,pub,&factory);
 				if(status==CELIX_SUCCESS && factory !=NULL){

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c b/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
index 227761b..9dcb083 100644
--- a/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
+++ b/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
@@ -127,7 +127,6 @@ celix_status_t pubsub_topicPublicationCreate(int sendSocket, pubsub_endpoint_pt
 
 celix_status_t pubsub_topicPublicationDestroy(topic_publication_pt pub){
 	celix_status_t status = CELIX_SUCCESS;
-
 	celixThreadMutex_lock(&(pub->tp_lock));
 
 	free(pub->endpoint);

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/pubsub/pubsub_admin_udp_mc/private/src/topic_subscription.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_udp_mc/private/src/topic_subscription.c b/pubsub/pubsub_admin_udp_mc/private/src/topic_subscription.c
index 6d4c22f..7a3f5a9 100644
--- a/pubsub/pubsub_admin_udp_mc/private/src/topic_subscription.c
+++ b/pubsub/pubsub_admin_udp_mc/private/src/topic_subscription.c
@@ -114,7 +114,7 @@ celix_status_t pubsub_topicSubscriptionCreate(char* ifIp,bundle_context_pt bundl
 
 	ts->running = false;
 	ts->nrSubscribers = 0;
-	ts->serializerSvc = serializer;
+	ts->serializerSvc = NULL;
 
 	celixThreadMutex_create(&ts->ts_lock,NULL);
 	arrayList_create(&ts->sub_ep_list);
@@ -151,7 +151,10 @@ celix_status_t pubsub_topicSubscriptionCreate(char* ifIp,bundle_context_pt bundl
 
 	sigaction(SIGUSR1,&actions,NULL);
 
-	*out=ts;
+    if (status == CELIX_SUCCESS) {
+        *out=ts;
+        pubsub_topicSubscriptionSetSerializer(ts, serializer);
+    }
 
 	return status;
 }
@@ -396,7 +399,7 @@ unsigned int pubsub_topicGetNrSubscribers(topic_subscription_pt ts) {
 	return ts->nrSubscribers;
 }
 
-celix_status_t pubsub_topicSubscriptionSetSerializer(topic_subscription_pt ts, pubsub_serializer_service_t* serializerSvc){
+celix_status_t pubsub_topicSubscriptionSetSerializer(topic_subscription_pt ts, pubsub_serializer_service_t* serializerSvc) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	celixThreadMutex_lock(&ts->ts_lock);

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c b/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
index 6095d8a..5ccee2c 100644
--- a/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
+++ b/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
@@ -445,7 +445,8 @@ celix_status_t pubsubAdmin_addPublication(pubsub_admin_pt admin, pubsub_endpoint
         if (factory == NULL) {
             topic_publication_pt pub = NULL;
             status = pubsub_topicPublicationCreate(admin->bundle_context, pubEP, admin->ipAddress, admin->basePort, admin->maxPort, &pub);
-			pubsub_topicPublicationSetSerializer(pub, admin->serializerSvc);
+			pubsub_topicPublicationSetSerializer(pub, admin->serializerSvc); //TODO serializer back to constructor. This is certainly when
+			//TODO admin are created for every available serializer
             if (status == CELIX_SUCCESS) {
                 status = pubsub_topicPublicationStart(admin->bundle_context, pub, &factory);
                 if (status == CELIX_SUCCESS && factory != NULL) {
@@ -667,7 +668,7 @@ celix_status_t pubsubAdmin_matchSubscriber(pubsub_admin_pt admin, pubsub_endpoin
 	return status;
 }
 
-celix_status_t pubsubAdmin_setSerializer(pubsub_admin_pt admin, pubsub_serializer_service_t* serializerSvc){
+celix_status_t pubsubAdmin_setSerializer(pubsub_admin_pt admin, pubsub_serializer_service_t* serializerSvc) {
 	celix_status_t status = CELIX_SUCCESS;
 	admin->serializerSvc = serializerSvc;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/pubsub/pubsub_admin_zmq/private/src/topic_subscription.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_zmq/private/src/topic_subscription.c b/pubsub/pubsub_admin_zmq/private/src/topic_subscription.c
index 537fbe5..1f42fa3 100644
--- a/pubsub/pubsub_admin_zmq/private/src/topic_subscription.c
+++ b/pubsub/pubsub_admin_zmq/private/src/topic_subscription.c
@@ -209,7 +209,7 @@ celix_status_t pubsub_topicSubscriptionCreate(bundle_context_pt bundle_context,
 	ts->zmq_socket = zmq_s;
 	ts->running = false;
 	ts->nrSubscribers = 0;
-	ts->serializerSvc = serializer;
+	ts->serializerSvc = NULL;
 
 	#ifdef BUILD_WITH_ZMQ_SECURITY
 	if (subEP->is_secure){
@@ -254,7 +254,10 @@ celix_status_t pubsub_topicSubscriptionCreate(bundle_context_pt bundle_context,
 
 	sigaction(SIGUSR1,&actions,NULL);
 
-	*out=ts;
+	if (status == CELIX_SUCCESS) {
+		*out=ts;
+		pubsub_topicSubscriptionSetSerializer(ts, serializer);
+	}
 
 	return status;
 }
@@ -429,7 +432,7 @@ unsigned int pubsub_topicGetNrSubscribers(topic_subscription_pt ts) {
 	return ts->nrSubscribers;
 }
 
-celix_status_t pubsub_topicSubscriptionSetserializer(topic_subscription_pt ts, pubsub_serializer_service_t* serializerSvc){
+celix_status_t pubsub_topicSubscriptionSetSerializer(topic_subscription_pt ts, pubsub_serializer_service_t* serializerSvc) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	celixThreadMutex_lock(&ts->ts_lock);

http://git-wip-us.apache.org/repos/asf/celix/blob/4b723e44/pubsub/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/pubsub/test/CMakeLists.txt b/pubsub/test/CMakeLists.txt
index 1270b7b..93a95f0 100644
--- a/pubsub/test/CMakeLists.txt
+++ b/pubsub/test/CMakeLists.txt
@@ -42,11 +42,20 @@ add_deploy(pubsub_udpmc_sut
         org.apache.celix.pubsub_serializer.PubSubSerializerJson
         org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
         org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-        #org.apache.celix.pubsub_admin.PubSubAdminZmq
         org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
         pubsub_sut
     DIR ${PROJECT_BINARY_DIR}/runtimes/test/pubsub/udpmc
 )
+add_deploy(pubsub_zmq_sut
+    NAME deploy_sut
+    BUNDLES
+        org.apache.celix.pubsub_serializer.PubSubSerializerJson
+        org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+        org.apache.celix.pubsub_admin.PubSubAdminZmq
+        org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+        pubsub_sut
+    DIR ${PROJECT_BINARY_DIR}/runtimes/test/pubsub/zmq
+)
 
 add_bundle(pubsub_tst
     #Test bundle containing cpputests and uses celix_test_runner launcher instead of the celix launcher
@@ -66,11 +75,22 @@ add_deploy(pubsub_udpmc_tst
         org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
         org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
         org.apache.celix.pubsub_admin.PubSubAdminUdpMc
-        #org.apache.celix.pubsub_admin.PubSubAdminZmq
         pubsub_tst
+    #NOTE using $<TARGET_PROPERTY:pubsub_test_udpmc_runtime,RUNTIME_DIR> in DIR not (yet) possible
     DIR ${PROJECT_BINARY_DIR}/runtimes/test/pubsub/udpmc
     LAUNCHER celix_test_runner
 )
+add_deploy(pubsub_zmq_tst
+    NAME deploy_tst
+    BUNDLES
+        org.apache.celix.pubsub_serializer.PubSubSerializerJson
+        org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
+        org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
+        org.apache.celix.pubsub_admin.PubSubAdminZmq
+        pubsub_tst
+    DIR ${PROJECT_BINARY_DIR}/runtimes/test/pubsub/zmq
+    LAUNCHER celix_test_runner
+)
 
 if (ETCD_CMD)
     add_runtime(pubsub_test_udpmc_runtime
@@ -83,12 +103,29 @@ if (ETCD_CMD)
             etcd
         WAIT_FOR
             pubsub_udpmc_tst
+        LOG_TO_FILES
         #USE_TERM
-        #LOG_TO_FILES
     )
-
     add_test(NAME pubsub_udpmc_test
-            COMMAND ./start.sh
-            WORKING_DIRECTORY $<TARGET_PROPERTY:pubsub_test_udpmc_runtime,RUNTIME_LOCATION>
+        COMMAND $<TARGET_PROPERTY:pubsub_test_udpmc_runtime,RUNTIME_LOCATION>/start.sh
+    )
+
+    add_runtime(pubsub_test_zmq_runtime
+        NAME zmq
+        GROUP test/pubsub
+        DEPLOYMENTS
+            pubsub_zmq_sut
+            pubsub_zmq_tst
+        COMMANDS
+            etcd
+        ARGUMENTS
+            pubsub_zmq_tst "-o junit"
+        WAIT_FOR
+            pubsub_zmq_tst
+        LOG_TO_FILES
+        #USE_TERM
+    )
+    add_test(NAME pubsub_zmq_test
+        COMMAND $<TARGET_PROPERTY:pubsub_test_zmq_runtime,RUNTIME_LOCATION>/start.sh
     )
 endif ()