Gary Wu | d04e440 | 2017-07-28 12:26:54 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2016-2017 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | # csit plans root dir |
| 19 | ROOT=`git rev-parse --show-toplevel`/autorelease |
| 20 | |
| 21 | BUILD_DIR=$ROOT/build |
| 22 | JJB_DIR=$BUILD_DIR/ci-management/jjb |
| 23 | |
| 24 | WORKSPACE=`git rev-parse --show-toplevel` |
| 25 | PLANS_DIR=`git rev-parse --show-toplevel`/test/csit/plans |
| 26 | |
| 27 | source $ROOT/scripts/generate-jjbs/workarounds.sh |
| 28 | |
| 29 | |
| 30 | TMPDIR=`mktemp -d --suffix="-docker-log"` |
| 31 | $ROOT/scripts/ls-microservice-repos.py | cut -d ' ' -f 1 > $TMPDIR/microservices.txt |
| 32 | |
| 33 | find $PLANS_DIR -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort | while read repo; do |
| 34 | |
| 35 | OUTFILE=$JJB_DIR/$repo/${repo}-csit.yaml |
| 36 | cat > $OUTFILE <<EOF |
| 37 | --- |
| 38 | - project: |
| 39 | name: ${repo}-csit |
| 40 | jobs: |
| 41 | - 'integration-verify-{project}-csit-{functionality}' |
| 42 | - '{project}-csit-{functionality}' |
| 43 | project: '${repo}' |
| 44 | functionality: |
| 45 | EOF |
| 46 | find $PLANS_DIR/$repo -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort | while read func; do |
| 47 | echo $repo / $func |
| 48 | cat >> $OUTFILE <<EOF |
| 49 | - '${func}': |
| 50 | trigger_jobs: |
| 51 | EOF |
| 52 | |
| 53 | docker kill `docker ps -a -q` |
| 54 | docker rm `docker ps -a -q` |
| 55 | |
| 56 | $WORKSPACE/test/csit/run-csit.sh plans/${repo}/${func} |
| 57 | mkdir -p $TMPDIR/${repo} |
| 58 | cp $WORKSPACE/archives/_docker-images.log $TMPDIR/${repo}/${func}.txt |
| 59 | |
| 60 | docker kill `docker ps -a -q` |
| 61 | docker rm `docker ps -a -q` |
| 62 | |
| 63 | |
| 64 | for image in `grep openoint $TMPDIR/${repo}/${func}.txt | grep -f $TMPDIR/microservices.txt | sort`; do |
| 65 | microservice=`echo $image | cut -d '/' -f 2` |
| 66 | cat >> $OUTFILE <<EOF |
| 67 | - 'integration-${microservice}-merge-docker' |
| 68 | EOF |
| 69 | done |
| 70 | |
| 71 | done |
| 72 | |
| 73 | cat >> $OUTFILE <<EOF |
| 74 | robot-options: '' |
| 75 | branch: 'master' |
| 76 | EOF |
| 77 | done |
| 78 | |
| 79 | echo $TMPDIR |