aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/run_containers
blob: d2c806667b729df35a1dd5b75d34e7f48bf1df30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash

# This is a sanity test script for the CODI and toolchain Docker images.
# This runs the test containers.
# Then it runs ceed -l to talk to codi to list the 4 test toolchains
#
# Example:
#
# ./tests/run_containers [NUM_TOOLCHAIN CONATINERS TO START DEFAULT:4]

TOPDIR=`git rev-parse --show-toplevel`
# note, currently the turff node and the container name MUST match exactly or have matching formats
# Example: TURFFID=repo/image:tag and container name repo-image-tag
# The Docker API does not allow special characters in container names except '-'
NAME_BASE="crops-toolchain-test"
NUM_TOOLCHAINS=4
if [ "$1" != "" ]; then
  NUM_TOOLCHAINS=$1
fi


if [ "$DEBUG" == "" ]; then
    echo "Start CODI container"
    docker run -d --name codi-test -v /var/run/docker.sock:/var/run/docker.sock --net=host crops/codi:test || \
	{ echo 'docker run codi failed' ; exit 1; }
else
    echo "Start DEBUG CODI container"
    docker run -d --name codi-test-debug -v /var/run/docker.sock:/var/run/docker.sock --net=host crops/codi:testdebug || \
	{ echo 'docker run codi failed' ; exit 1; }
fi
II=0
while [ $II -lt $NUM_TOOLCHAINS ]; do
  echo "Start toolchain container $II"
  sleep 2;
  docker run -d --name ${NAME_BASE}${II} -v /crops/:/crops/ --env TURFFID=${NAME_BASE}${II} --net=host crops/toolchain:test || \
  { echo 'docker run toolchain-test${II} failed' ; exit 1; }
  let II=$II+1
done

echo "Start Zephyr toolchain container"
sleep 2;
mkdir -p $HOME/crops-test-workspace
docker run -d --name zephyr-test -v $HOME/crops-test-workspace/:/crops/ --env TURFFID=zephyr-test --net=host crops/zephyr:test || \
  { echo 'docker run zephyr-test failed' ; exit 1; }

echo "List containers known to CODI"
sleep 5;
cd ${TOPDIR}/ceed

# if docker-machine exists then we are on a mac/windows and use the address of the vm we are running in
# else localhost
if [ -x "$(command -v docker-machine)" ]; then
  NAME=`docker-machine active`
  ADDRESS=`docker-machine ip ${NAME}`
else
  # linux can run over unix sockets rather than ip but ip is more cross platform
  ADDRESS=127.0.0.1
fi
./ceed -i $ADDRESS -s 10000 -l