+- builder:
+ name: set-functest-env
+ builders:
+ - shell: |
+ #!/bin/bash
+ set +e
+ if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
+ INSTALLER_IP=$(cat instack /var/lib/libvirt/dnsmasq/default.leases \
+ |sed 's/.*192/192/g' | sed 's/\ in.*//g')
+ sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
+ fi
+ echo "Functest: Start Docker and prepare environment"
+ envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME}"
+ labconfig=""
+ # If production lab then creds may be retrieved dynamically
+ # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
+ if [ -n "${LAB_CONFIG}" ]; then
+ labconfig="-v ${LAB_CONFIG}:/home/opnfv/functest/conf/openstack.creds"
+ fi
+
+ docker pull opnfv/functest:latest_stable
+ cmd="docker run -id -e $envs ${labconfig} ${sshkey} opnfv/functest:latest_stable /bin/bash"
+ echo "Functest: Running docker run command: ${cmd}"
+ ${cmd}
+ docker ps -a
+ sleep 5
+ container_id=$(docker ps | grep 'opnfv/functest:latest_stable' | awk '{print $1}' | head -1)
+ echo "Container ID=${container_id}"
+ if [ -z ${container_id} ]; then
+ echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
+ docker ps -a
+ exit 1
+ fi
+ echo "Starting the container: docker start ${container_id}"
+ docker start ${container_id}
+ sleep 5
+ docker ps
+ if [ $(docker ps | grep 'opnfv/functest:latest_stable' | wc -l) == 0 ]; then
+ echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
+ exit 1
+ fi
+ cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
+ echo "Executing command inside the docker: ${cmd}"
+ docker exec ${container_id} ${cmd}