github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/integration/sawtooth_integration/tests/test_systemd.sh (about) 1 #!/bin/bash 2 # Copyright 2017 Intel Corporation 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # ------------------------------------------------------------------------------ 16 17 # A simple test to verify that the each systemd service is able to startup 18 # without immediately crashing given the default arguments 19 20 services=" 21 smallbank-tp-go 22 xo-tp-go 23 intkey-tp-go 24 validator 25 rest-api 26 intkey-tp-python 27 xo-tp-python 28 settings-tp 29 identity-tp 30 poet-validator-registry-tp 31 devmode-rust 32 " 33 34 if [ -z $ISOLATION_ID ] 35 then 36 ISOLATION_ID=latest 37 fi 38 39 for serv in $services 40 do 41 # 1. Create a docker container running systemd 42 image=sawtooth-$serv:$ISOLATION_ID 43 container=${ISOLATION_ID}_systemd_test_$serv 44 service=sawtooth-$serv 45 echo "Starting container '$container' from '$image'..." 46 docker run -d --name $container --privileged --rm $image systemd 47 sleep 1 # Give systemd a chance to start 48 49 if [ $serv = "validator" ] 50 then 51 echo "Running keygen in $container..." 52 docker exec $container sawadm keygen 53 fi 54 55 # 2. Start the systemd service in the container 56 echo "Starting $service in $container..." 57 docker exec $container systemctl start $service 58 sleep 1 # Give the service a chance to fail 59 60 # 3. Check if the service started successfully 61 docker exec $container systemctl status $service 62 exitcode=$? 63 echo "Exit code was $exitcode" 64 65 # 4. Cleanup the container 66 docker kill $container 67 68 if [ $exitcode -ne 0 ] 69 then 70 exit $exitcode 71 fi 72 done