1#!/bin/bash 2# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 3# This Source Code Form is subject to the terms of the Mozilla Public 4# License, v. 2.0. If a copy of the MPL was not distributed with this 5# file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7# Purpose: This script is needed to start the services with 8# one command. This is necessary as ctest - which is used to run the 9# tests - isn't able to start multiple binaries for one testcase. Therefore 10# the testcase simply executes this script. This script then runs the services 11# and checks that all exit successfully. 12 13FAIL=0 14 15cat <<End-of-message 16******************************************************************************* 17******************************************************************************* 18** Running first test 19******************************************************************************* 20******************************************************************************* 21End-of-message 22 23# Rejecting offer of service instance whose hosting application is still 24# alive: 25# * start application which offers service 26# * start two clients which continuously exchanges messages with the service 27# * start application which offers the same service again -> should be 28# rejected and an error message should be printed. 29# * Message exchange with client application should not be interrupted. 30 31# Array for client pids 32CLIENT_PIDS=() 33export VSOMEIP_CONFIGURATION=offer_test_local.json 34# Start the services 35./offer_test_service 1 & 36PID_SERVICE_ONE=$! 37./offer_test_client SUBSCRIBE & 38CLIENT_PIDS+=($!) 39./offer_test_client SUBSCRIBE & 40CLIENT_PIDS+=($!) 41 42./offer_test_service 2 & 43PID_SERVICE_TWO=$! 44 45# Wait until all clients are finished 46for job in ${CLIENT_PIDS[*]} 47do 48 # Fail gets incremented if a client exits with a non-zero exit code 49 wait $job || FAIL=$(($FAIL+1)) 50done 51 52# kill the services 53kill $PID_SERVICE_TWO 54kill $PID_SERVICE_ONE 55sleep 1 56 57 58cat <<End-of-message 59******************************************************************************* 60******************************************************************************* 61** Running second test 62******************************************************************************* 63******************************************************************************* 64End-of-message 65 66# Rejecting offer of service instance whose hosting application is still 67# alive with daemon: 68# * start daemon (needed as he has to ping the offering client) 69# * start application which offers service 70# * start two clients which continuously exchanges messages with the service 71# * start application which offers the same service again -> should be 72# rejected and an error message should be printed. 73# * Message exchange with client application should not be interrupted. 74 75# Array for client pids 76CLIENT_PIDS=() 77export VSOMEIP_CONFIGURATION=offer_test_local.json 78# start daemon 79../examples/routingmanagerd/./routingmanagerd & 80PID_VSOMEIPD=$! 81 82# Start the services 83./offer_test_service 2 & 84PID_SERVICE_TWO=$! 85./offer_test_client SUBSCRIBE & 86CLIENT_PIDS+=($!) 87./offer_test_client SUBSCRIBE & 88CLIENT_PIDS+=($!) 89 90./offer_test_service 3 & 91PID_SERVICE_THREE=$! 92 93# Wait until all clients are finished 94for job in ${CLIENT_PIDS[*]} 95do 96 # Fail gets incremented if a client exits with a non-zero exit code 97 wait $job || FAIL=$(($FAIL+1)) 98done 99 100# kill the services 101kill $PID_SERVICE_THREE 102kill $PID_SERVICE_TWO 103sleep 1 104kill $PID_VSOMEIPD 105sleep 1 106 107 108cat <<End-of-message 109******************************************************************************* 110******************************************************************************* 111** Running third test 112******************************************************************************* 113******************************************************************************* 114End-of-message 115 116# Accepting offer of service instance whose hosting application crashed 117# with (send SIGKILL) 118# * start daemon 119# * start application which offers service 120# * start client which exchanges messages with the service 121# * kill application with SIGKILL 122# * start application which offers the same service again -> should be 123# accepted. 124# * start another client which exchanges messages with the service 125# * Client should now communicate with new offerer. 126 127# Array for client pids 128CLIENT_PIDS=() 129export VSOMEIP_CONFIGURATION=offer_test_local.json 130# start daemon 131../examples/routingmanagerd/./routingmanagerd & 132PID_VSOMEIPD=$! 133# Start the service 134./offer_test_service 2 & 135PID_SERVICE_TWO=$! 136 137# Start a client 138./offer_test_client METHODCALL & 139CLIENT_PIDS+=($!) 140 141# Kill the service 142sleep 1 143kill -KILL $PID_SERVICE_TWO 144 145# reoffer the service 146./offer_test_service 3 & 147PID_SERVICE_THREE=$! 148 149# Start another client 150./offer_test_client METHODCALL & 151CLIENT_PIDS+=($!) 152 153# Wait until all clients are finished 154for job in ${CLIENT_PIDS[*]} 155do 156 # Fail gets incremented if a client exits with a non-zero exit code 157 wait $job || FAIL=$(($FAIL+1)) 158done 159 160# kill the services 161kill $PID_SERVICE_THREE 162kill $PID_VSOMEIPD 163sleep 1 164 165cat <<End-of-message 166******************************************************************************* 167******************************************************************************* 168** Running fourth test 169******************************************************************************* 170******************************************************************************* 171End-of-message 172 173# Accepting offer of service instance whose hosting application became 174# unresponsive (SIGSTOP) 175# * start daemon 176# * start application which offers service 177# * Send a SIGSTOP to the service to make it unresponsive 178# * start application which offers the same service again -> should be 179# marked as PENDING_OFFER and a ping should be sent to the paused 180# application. 181# * After the timeout passed the new offer should be accepted. 182# * start client which exchanges messages with the service 183# * Client should now communicate with new offerer. 184 185# Array for client pids 186CLIENT_PIDS=() 187export VSOMEIP_CONFIGURATION=offer_test_local.json 188# start daemon 189../examples/routingmanagerd/./routingmanagerd & 190PID_VSOMEIPD=$! 191# Start the service 192./offer_test_service 2 & 193PID_SERVICE_TWO=$! 194 195# Start a client 196./offer_test_client METHODCALL & 197CLIENT_PIDS+=($!) 198 199# Pause the service 200sleep 1 201kill -STOP $PID_SERVICE_TWO 202 203# reoffer the service 204./offer_test_service 3 & 205PID_SERVICE_THREE=$! 206 207# Start another client 208./offer_test_client METHODCALL & 209CLIENT_PIDS+=($!) 210 211# Wait until all clients are finished 212for job in ${CLIENT_PIDS[*]} 213do 214 # Fail gets incremented if a client exits with a non-zero exit code 215 wait $job || FAIL=$(($FAIL+1)) 216done 217 218# kill the services 219kill -CONT $PID_SERVICE_TWO 220kill $PID_SERVICE_TWO 221kill $PID_SERVICE_THREE 222kill $PID_VSOMEIPD 223sleep 1 224 225cat <<End-of-message 226******************************************************************************* 227******************************************************************************* 228** Running fifth test 229******************************************************************************* 230******************************************************************************* 231End-of-message 232 233# Rejecting offers for which there is already a pending offer 234# * start daemon 235# * start application which offers service 236# * Send a SIGSTOP to the service to make it unresponsive 237# * start application which offers the same service again -> should be 238# marked as PENDING_OFFER and a ping should be sent to the paused 239# application. 240# * start application which offers the same service again -> should be 241# rejected as there is already a PENDING_OFFER pending. 242# * After the timeout passed the new offer should be accepted. 243# * start client which exchanges messages with the service 244# * Client should now communicate with new offerer. 245 246# Array for client pids 247CLIENT_PIDS=() 248export VSOMEIP_CONFIGURATION=offer_test_local.json 249# start daemon 250../examples/routingmanagerd/./routingmanagerd & 251PID_VSOMEIPD=$! 252# Start the service 253./offer_test_service 2 & 254PID_SERVICE_TWO=$! 255 256# Start a client 257./offer_test_client METHODCALL & 258CLIENT_PIDS+=($!) 259 260# Pause the service 261sleep 1 262kill -STOP $PID_SERVICE_TWO 263 264# reoffer the service 265./offer_test_service 3 & 266PID_SERVICE_THREE=$! 267 268# reoffer the service again to provoke rejecting as there is 269# already a pending offer 270./offer_test_service 4 & 271PID_SERVICE_FOUR=$! 272 273# Start another client 274./offer_test_client METHODCALL & 275CLIENT_PIDS+=($!) 276 277# Wait until all clients are finished 278for job in ${CLIENT_PIDS[*]} 279do 280 # Fail gets incremented if a client exits with a non-zero exit code 281 wait $job || FAIL=$(($FAIL+1)) 282done 283 284# kill the services 285kill -CONT $PID_SERVICE_TWO 286kill $PID_SERVICE_TWO 287kill $PID_SERVICE_THREE 288kill $PID_SERVICE_FOUR 289kill $PID_VSOMEIPD 290 291 292# Check if everything went well 293if [ $FAIL -eq 0 ] 294then 295 exit 0 296else 297 exit 1 298fi 299