github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/hack/make/.integration-daemon-start (about) 1 #!/usr/bin/env bash 2 3 # see test-integration for example usage of this script 4 5 base="$ABS_DEST/.." 6 export PATH="$base/binary-daemon:$base/dynbinary-daemon:$PATH" 7 8 export TEST_CLIENT_BINARY=docker 9 10 # Do not bump this version! Integration tests should no longer rely on the docker cli, they should be 11 # API tests instead. For the existing tests the scripts will use a frozen version of the docker cli 12 # with a DOCKER_API_VERSION frozen to 1.30, which should ensure that the CI remains green at all times. 13 export DOCKER_API_VERSION=1.30 14 if [ -n "$DOCKER_CLI_PATH" ]; then 15 export TEST_CLIENT_BINARY=/usr/local/cli/$(basename "$DOCKER_CLI_PATH") 16 fi 17 18 echo "Using test binary $TEST_CLIENT_BINARY" 19 if ! command -v "$TEST_CLIENT_BINARY" &> /dev/null; then 20 echo >&2 'error: missing test client $TEST_CLIENT_BINARY' 21 false 22 fi 23 24 # This is a temporary hack for split-binary mode. It can be removed once 25 # https://github.com/docker/docker/pull/22134 is merged into docker master 26 if [ "$(go env GOOS)" = 'windows' ]; then 27 return 28 fi 29 30 if [ -z "$DOCKER_TEST_HOST" ]; then 31 if docker version &> /dev/null; then 32 echo >&2 'skipping daemon start, since daemon appears to be already started' 33 return 34 fi 35 fi 36 37 if ! command -v dockerd &> /dev/null; then 38 echo >&2 'error: binary-daemon or dynbinary-daemon must be run before .integration-daemon-start' 39 false 40 fi 41 42 # intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers 43 exec 41>&1 42>&2 44 45 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs} 46 export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} 47 48 # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" 49 storage_params="" 50 if [ -n "$DOCKER_STORAGE_OPTS" ]; then 51 IFS=',' 52 for i in ${DOCKER_STORAGE_OPTS}; do 53 storage_params="--storage-opt $i $storage_params" 54 done 55 unset IFS 56 fi 57 58 # example usage: DOCKER_REMAP_ROOT=default 59 extra_params="" 60 if [ "$DOCKER_REMAP_ROOT" ]; then 61 extra_params="--userns-remap $DOCKER_REMAP_ROOT" 62 fi 63 64 # example usage: DOCKER_EXPERIMENTAL=1 65 if [ "$DOCKER_EXPERIMENTAL" ]; then 66 echo >&2 '# DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled! ' 67 extra_params="$extra_params --experimental" 68 fi 69 70 if [ -z "$DOCKER_TEST_HOST" ]; then 71 # Start apparmor if it is enabled 72 if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then 73 # reset container variable so apparmor profile is applied to process 74 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 75 export container="" 76 ( 77 [ -n "$TESTDEBUG" ] && set -x 78 /etc/init.d/apparmor start 79 ) 80 fi 81 82 # "pwd" tricks to make sure $DEST is an absolute path, not a relative one 83 export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" 84 ( 85 echo "Starting dockerd" 86 [ -n "$TESTDEBUG" ] && set -x 87 exec \ 88 dockerd --debug \ 89 --host "$DOCKER_HOST" \ 90 --storage-driver "$DOCKER_GRAPHDRIVER" \ 91 --pidfile "$DEST/docker.pid" \ 92 --userland-proxy="$DOCKER_USERLANDPROXY" \ 93 $storage_params \ 94 $extra_params \ 95 &> "$DEST/docker.log" 96 ) & 97 else 98 export DOCKER_HOST="$DOCKER_TEST_HOST" 99 fi 100 101 # give it a little time to come up so it's "ready" 102 tries=60 103 echo "INFO: Waiting for daemon to start..." 104 while ! $TEST_CLIENT_BINARY version &> /dev/null; do 105 (( tries-- )) 106 if [ $tries -le 0 ]; then 107 printf "\n" 108 if [ -z "$DOCKER_HOST" ]; then 109 echo >&2 "error: daemon failed to start" 110 echo >&2 " check $DEST/docker.log for details" 111 else 112 echo >&2 "error: daemon at $DOCKER_HOST fails to '$TEST_CLIENT_BINARY version':" 113 $TEST_CLIENT_BINARY version >&2 || true 114 # Additional Windows CI debugging as this is a common error as of 115 # January 2016 116 if [ "$(go env GOOS)" = 'windows' ]; then 117 echo >&2 "Container log below:" 118 echo >&2 "---" 119 # Important - use the docker on the CI host, not the one built locally 120 # which is currently in our path. 121 ! /c/bin/docker -H=$MAIN_DOCKER_HOST logs docker-$COMMITHASH 122 echo >&2 "---" 123 fi 124 fi 125 false 126 fi 127 printf "." 128 sleep 2 129 done 130 printf "\n"