From 9bbc5884720a416951903a12778426fa3552e6cb Mon Sep 17 00:00:00 2001 From: Haikel Guemar Date: Sun, 17 Jul 2016 20:06:14 +0200 Subject: [PATCH] tools: parallelize execution Parallelize renderspec and spec-cleaner executions to speed up scripts. There is no constraint to run these jobs sequentially Change-Id: I7bdeee82cc360cf31e9684ef22638f41c53b12b8 --- tools/run_renderspec.sh | 8 +++++++- tools/run_speccleaner.sh | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/run_renderspec.sh b/tools/run_renderspec.sh index 9d96036d6..0b8da6fbb 100755 --- a/tools/run_renderspec.sh +++ b/tools/run_renderspec.sh @@ -8,6 +8,7 @@ specdir=${basedir}/openstack/ WORKSPACE=${WORKSPACE:-$basedir} OUTPUTDIR=$WORKSPACE/logs/ specstyles="suse fedora" +MAXPROC=4 mkdir -p $OUTPUTDIR @@ -16,11 +17,16 @@ for specstyle in $specstyles; do rm -f $OUTPUTDIR/*.${specstyle} done +count=0 echo "run renderspec over specfiles from ${specdir}" for spec in ${specdir}/**/*.spec.j2; do for specstyle in $specstyles; do echo "run ${spec} for ${specstyle}" renderspec --spec-style ${specstyle} ${spec} \ - -o $WORKSPACE/logs/${spec##*/}.${specstyle} + -o $WORKSPACE/logs/${spec##*/}.${specstyle} & + let count+=1 + [[ count -eq $MAXPROC ]] && wait && count=0 done done + +wait diff --git a/tools/run_speccleaner.sh b/tools/run_speccleaner.sh index d5be92974..06088ac66 100755 --- a/tools/run_speccleaner.sh +++ b/tools/run_speccleaner.sh @@ -7,18 +7,24 @@ basedir=${1:-$PWD} WORKSPACE=${WORKSPACE:-$basedir} # tempfile to store the spec-cleaner diff for all specs tmpdir=$(mktemp -d) +MAXPROC=4 echo "run spec-cleaner over specfiles from $WORKSPACE/logs/" +count=0 # TODO(toabctl): also run spec-cleaner with non-SUSE specs # but the current problem is that the license check works for SUSE only for spec in $WORKSPACE/logs/*.suse ; do # NOTE(toabctl):spec-cleaner can not ignore epochs currently sed -i '/^Epoch:.*/d' $spec spec-cleaner -m -d --no-copyright --diff-prog "diff -uw" \ - $spec > $tmpdir/`basename ${spec}`.cleaner.diff + $spec > $tmpdir/`basename ${spec}`.cleaner.diff & + let count+=1 + [[ count -eq $MAXPROC ]] && wait && count=0 done +wait + # check if some diffs are available failed=0 for specdiff in $tmpdir/*; do