- job: name: tcwg-test-container-matrix project-type: matrix defaults: global properties: - authorization: anonymous: - job-read - job-extended-read linaro: - job-build - job-cancel - build-discarder: days-to-keep: 30 num-to-keep: 30 parameters: - string: name: container_name default: docker-trusty-arm64-tcwg-test description: 'Container name' - string: name: container_user default: tcwg-buildslave description: 'Non-root user inside container' - string: name: public_key default: '' description: 'SSH public key. Leave empty to not install additional public keys or use "ldap" to fetch from LDAP' - string: name: upstream_dest default: '' description: 'SSH destination to write connection parameters to, e.g., dev-01.tcwglab:22:/tmp/my-abe-test-container.param.' - string: name: watchdog default: file description: 'Watchdog to determine when to stop testing container: file or upstream' disabled: false node: tcwg-aarch64-test child-workspace: $label concurrent: true display-name: 'TCWG BBB Test Container' axes: - axis: type: slave name: label values: - docker-trusty-arm64-tcwg-test - docker-trusty-armhf-tcwg-test execution-strategy: sequential: false combination-filter: | label=="$container_name" wrappers: - timeout: timeout: 600 - timestamps - ssh-agent-credentials: # tcwg-buildslave user id users: - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a' - build-name: name: '#${BUILD_NUMBER}' builders: - shell: | #!/bin/bash set -ex if [ x"$public_key" = x"ldap" ]; then public_key="$(ssh -o StrictHostKeyChecking=no aus-colo.linaro.org /etc/ssh/ssh_keys.py $container_user)" fi if [ x"$public_key" != x"" ]; then echo "" >> ~/.ssh/authorized_keys || true echo "$public_key" >> ~/.ssh/authorized_keys || true fi if ! getent passwd $container_user; then container_user_data="$(ssh -o StrictHostKeyChecking=no aus-colo.linaro.org getent passwd $container_user)" container_user_uid="$(echo "$container_user_data" | cut -d: -f 3)" if [ x"$container_user_uid" != x"" ]; then container_user_uid_opt="-u $container_user_uid" fi sudo useradd -m $container_user_uid_opt $container_user sudo rsync -a ~/.ssh/ /home/$container_user/.ssh/ sudo chown -R $container_user /home/$container_user/.ssh/ fi docker_host="$(echo $DOCKER_HOST | sed -e "s#^tcp://\(.*\):.*#\1#")" ssh_port="$(ssh $docker_host docker port $DOCKER_CONTAINER_ID 22)" ssh_port="$(echo $ssh_port | cut -d: -f 2)" if [ x"$upstream_dest" != x"" ]; then upstream_machine="$(echo "$upstream_dest" | cut -d: -f 1)" upstream_port="$(echo "$upstream_dest" | cut -d: -f 2)" upstream_file="$(echo "$upstream_dest" | cut -d: -f 3)" echo "$container_user@$docker_host:$ssh_port" | ssh -o Port=$upstream_port $upstream_machine tee $upstream_file > /dev/null fi set +x echo "Testing container: $container_user@$docker_host:$ssh_port" echo "Hosting tests" case "$watchdog" in "file") sudo touch /keep-container sudo chmod 0777 /keep-container echo "1" > /keep-container echo "To stop container run: ssh -o Port=$ssh_port $container_user@$docker_host sh -c 'echo 0 > /keep-container'" while [ -e /keep-container ] && [ x"$(cat /keep-container)" = x"1" ]; do sleep 60 echo "Running processes: $(ps ax | wc -l)" done ;; "upstream") echo "To stop container remove $upstream_dest" while ssh -o Port=$upstream_port $upstream_machine test -e $upstream_file; do sleep 60 echo "Running processes: $(ps ax | wc -l)" done ;; *) echo "ERROR: Wrong watchdog parameter: $watchdog" ;; esac echo "Exiting"