blob: 429bac5e8ce8433cad73b1a6b881532a0c087624 [file] [log] [blame]
Monty Taylore5b614e2017-09-01 12:56:57 -05001#!/bin/bash
2# Copyright 2017 Red Hat, Inc.
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
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17ZUUL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
David Moreau Simard6ef1d612018-02-19 23:53:34 -050018# Initialize tox environment if it's not set up
19if [[ ! -d "${ZUUL_DIR}/.tox/venv" ]]; then
20 pushd $ZUUL_DIR
21 echo "Virtualenv doesn't exist... creating."
22 tox -e venv --notest
23 popd
24fi
25# Source tox environment
26source ${ZUUL_DIR}/.tox/venv/bin/activate
Monty Taylore5b614e2017-09-01 12:56:57 -050027
David Moreau Simard6ef1d612018-02-19 23:53:34 -050028# Install ARA if it's not installed (not in requirements.txt by default)
29python -c "import ara" &> /dev/null
30if [ $? -eq 1 ]; then
31 echo "ARA isn't installed... Installing it."
32 pip install ara
33fi
34ARA_DIR=$(dirname $(python3 -c 'import ara; print(ara.__file__)'))
35
36WORK_DIR=$(mktemp -d /tmp/zuul_logs_XXXX)
Monty Taylore5b614e2017-09-01 12:56:57 -050037
38if [ -z $1 ] ; then
39 INVENTORY=$WORK_DIR/hosts.yaml
40 cat >$INVENTORY <<EOF
41all:
42 hosts:
43 controller:
David Moreau Simard6ef1d612018-02-19 23:53:34 -050044 ansible_connection: local
Monty Taylore5b614e2017-09-01 12:56:57 -050045 node1:
David Moreau Simard6ef1d612018-02-19 23:53:34 -050046 ansible_connection: local
Monty Taylore5b614e2017-09-01 12:56:57 -050047 node2:
David Moreau Simard6ef1d612018-02-19 23:53:34 -050048 ansible_connection: local
Monty Taylore5b614e2017-09-01 12:56:57 -050049node:
50 hosts:
51 node1: null
52 node2: null
53EOF
54else
55 INVENTORY=$(realpath $1)
56fi
57
58cat >$WORK_DIR/ansible.cfg <<EOF
59[defaults]
David Shrewsbury501bd052017-09-19 14:15:08 -040060inventory = $INVENTORY
Monty Taylore5b614e2017-09-01 12:56:57 -050061gathering = smart
62gather_subset = !all
63fact_caching = jsonfile
64fact_caching_connection = ~/.cache/facts
65lookup_plugins = $ZUUL_DIR/zuul/ansible/lookup
66callback_plugins = $ZUUL_DIR/zuul/ansible/callback:$ARA_DIR/plugins/callbacks
67module_utils = $ZUUL_DIR/zuul/ansible/module_utils
68stdout_callback = zuul_stream
69library = $ZUUL_DIR/zuul/ansible/library
70retry_files_enabled = False
71EOF
72
73cd $WORK_DIR
74python3 $ZUUL_DIR/zuul/ansible/logconfig.py
75export ZUUL_JOB_LOG_CONFIG=$WORK_DIR/logging.json
76export ARA_DIR=$WORK_DIR/.ara
77export ARA_LOG_CONFIG=$ZUUL_JOB_LOG_CONFIG
78rm -rf $ARA_DIR
79ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/fixtures/test-stream.yaml
80ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/fixtures/test-stream-failure.yaml
David Moreau Simard6ef1d612018-02-19 23:53:34 -050081# ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/functional.yaml
Monty Taylore5b614e2017-09-01 12:56:57 -050082echo "Logs are in $WORK_DIR"