Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 1 | #!/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 | |
| 17 | ZUUL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" |
| 18 | ARA_DIR=$(dirname $(python3 -c 'import ara ; print(ara.__file__)')) |
| 19 | WORK_DIR=$PWD/test-logs-output |
| 20 | |
| 21 | mkdir -p $WORK_DIR |
| 22 | |
| 23 | if [ -z $1 ] ; then |
| 24 | INVENTORY=$WORK_DIR/hosts.yaml |
| 25 | cat >$INVENTORY <<EOF |
| 26 | all: |
| 27 | hosts: |
| 28 | controller: |
| 29 | ansible_host: localhost |
| 30 | node1: |
| 31 | ansible_host: localhost |
| 32 | node2: |
| 33 | ansible_host: localhost |
| 34 | node: |
| 35 | hosts: |
| 36 | node1: null |
| 37 | node2: null |
| 38 | EOF |
| 39 | else |
| 40 | INVENTORY=$(realpath $1) |
| 41 | fi |
| 42 | |
| 43 | cat >$WORK_DIR/ansible.cfg <<EOF |
| 44 | [defaults] |
| 45 | hostfile = $INVENTORY |
| 46 | gathering = smart |
| 47 | gather_subset = !all |
| 48 | fact_caching = jsonfile |
| 49 | fact_caching_connection = ~/.cache/facts |
| 50 | lookup_plugins = $ZUUL_DIR/zuul/ansible/lookup |
| 51 | callback_plugins = $ZUUL_DIR/zuul/ansible/callback:$ARA_DIR/plugins/callbacks |
| 52 | module_utils = $ZUUL_DIR/zuul/ansible/module_utils |
| 53 | stdout_callback = zuul_stream |
| 54 | library = $ZUUL_DIR/zuul/ansible/library |
| 55 | retry_files_enabled = False |
| 56 | EOF |
| 57 | |
| 58 | cd $WORK_DIR |
| 59 | python3 $ZUUL_DIR/zuul/ansible/logconfig.py |
| 60 | export ZUUL_JOB_LOG_CONFIG=$WORK_DIR/logging.json |
| 61 | export ARA_DIR=$WORK_DIR/.ara |
| 62 | export ARA_LOG_CONFIG=$ZUUL_JOB_LOG_CONFIG |
| 63 | rm -rf $ARA_DIR |
| 64 | ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/fixtures/test-stream.yaml |
| 65 | ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/fixtures/test-stream-failure.yaml |
| 66 | echo "Logs are in $WORK_DIR" |