summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2013-11-06 16:08:39 -0500
committerAbhishek Koneru <akoneru@redhat.com>2013-11-10 15:15:37 -0500
commitb9d125a25e7b53cfe1cc9437b6a31a87c324bbe2 (patch)
tree28434dbf47dbf2ac6711604ac3f8e4c0513dc327 /scripts
parentbb20c9ffb38baae7ae89f16737e37569af445bdc (diff)
downloadpki-b9d125a25e7b53cfe1cc9437b6a31a87c324bbe2.tar.gz
pki-b9d125a25e7b53cfe1cc9437b6a31a87c324bbe2.tar.xz
pki-b9d125a25e7b53cfe1cc9437b6a31a87c324bbe2.zip
Provide compose scripts for tests.
Provide a compose script for building the test rpm and creating the job xml (by updating the job template with custom values provided in a job xml config file). Also add a new option --createrepo to the compose_pki_core_package script to create a repository of the built rpms at the location specified in a config file. Tickets #657, 722,723,724
Diffstat (limited to 'scripts')
-rw-r--r--scripts/compose_functions84
-rwxr-xr-xscripts/compose_pki_core_packages7
-rwxr-xr-xscripts/compose_pki_test_package80
-rwxr-xr-xscripts/run_tests28
-rwxr-xr-xscripts/scp_the_repo.exp16
5 files changed, 213 insertions, 2 deletions
diff --git a/scripts/compose_functions b/scripts/compose_functions
index 3c08453e7..49ca67f48 100644
--- a/scripts/compose_functions
+++ b/scripts/compose_functions
@@ -109,6 +109,9 @@ Usage()
printf " ${MESSAGE}\n\n"
printf "Options:\n"
printf " --without-javadoc do not build Javadoc RPMS\n\n"
+ printf " --createrepo=<repository_location_details_file> create a \n"
+ printf " repository with the rpms built."
+ printf " Provide the configuration file with the details. \n\n"
}
@@ -236,12 +239,90 @@ Fetch_Source_Tarball()
done
}
+###
+# Create repository using the details in the config file ###
+# Function parameters - $1 - repository file path.
+# Sample repository file :
+# ### Location where the files have to be copied ###
+# ### Same parameter for both local and remote ###
+# REPOSITORY_LOCATION=/var/www/html/pki/
+#
+# ### Remote host details###
+# REMOTE_HOSTNAME_OR_IP=vm-051.idm.lab.bos.redhat.com
+# USERNAME=root
+# PASSWORD=********
+###
+#
+Create_repo_after_build()
+{
+ if [ $# -eq 0 ]; then
+ echo "No repository configuration provided. Cannot create a repo."
+ exit -1
+ fi
+
+ if [ ! -f $1 ]; then
+ echo "$1 does not exist."
+ exit -1
+ fi
+
+ source $1
+
+ ### Remove leading and trailing whitespaces ###
+ repo_location=`echo $REPOSITORY_LOCATION |sed -e 's/^ *//g' -e 's/ *$//g'`
+ destination=`echo $REMOTE_HOSTNAME_OR_IP|sed -e 's/^ *//g' -e 's/ *$//g'`
+ uname=`echo $USERNAME |sed -e 's/^ *//g' -e 's/ *$//g'`
+ pwd=`echo $PASSWORD |sed -e 's/^ *//g' -e 's/ *$//g'`
+
+ if [ "$repo_location" != "" ] ; then
+ if [ "$destination" != "" ] ; then
+ createrepo ./RPMS/noarch/
+ createrepo ./RPMS/x86_64/
+ createrepo ./SOURCES/
+ createrepo ./SRPMS/
+ createrepo ./SPECS/
+ if [ $uname == "" ] ; then
+ echo "No username provided in the configuration file."
+ echo "Enter the username:"
+ read $uname
+ fi
+ if [ $pwd == "" ] ; then
+ echo "No password provided in the configuration file."
+ echo "Enter the password:"
+ read -s $pwd
+ fi
+ url="$uname@$destination:$repo_location"
+ echo $url
+ ./scp_the_repo.exp "RPMS/" $url $PASSWORD
+ ./scp_the_repo.exp "SRPMS/" $url $PASSWORD
+ ./scp_the_repo.exp "SOURCES/" $url $PASSWORD
+ ./scp_the_repo.exp "SPECS/" $url $PASSWORD
+ if [ $? -ne 0 ]; then
+ echo "Cannot copy the repositories to $destination\n"
+ exit -1
+ fi
+ echo "Copied the repo to the location on the destination"
+ exit 0
+ fi
+ if [ ! -e $repo_location ] ; then
+ mkdir -p $repo_location
+ fi
+ cp -r RPMS SOURCES SRPMS SPECS $repo_location
+ createrepo $REPOSITORY_LOCATION/RPMS/noarch/
+ createrepo $REPOSITORY_LOCATION/RPMS/x86_64/
+ createrepo $REPOSITORY_LOCATION/SOURCES/
+ createrepo $REPOSITORY_LOCATION/SRPMS/
+ createrepo $REPOSITORY_LOCATION/SPECS/
+ echo "Build repository created at $repo_location."
+ exit 0
+ fi
+ echo "Cannot create repository. $repo_location has empty value in repository.cfg"
+}
##
## Check for command line argument validity
##
-GETOPT=`getopt -o '' -l without-javadoc,work-dir: -n "$0" -- "$@"`
+GETOPT=`getopt -o '' -l without-javadoc,work-dir:,createrepo: -n "$0" -- "$@"`
if [ $? != 0 ] ; then
Usage
@@ -254,6 +335,7 @@ while true ; do
case "$1" in
--without-javadoc) JAVADOC="--without javadoc" ; shift ;;
--work-dir) WORK_DIR="$2" ; shift 2 ;;
+ --createrepo) CREATEREPO="Y" ; REPO_CFG_FILE="$2" ; shift 2 ;;
--) shift ; break ;;
*) echo "$0: unrecognized option '$1'" 1>&2 ; exit 255 ;;
esac
diff --git a/scripts/compose_pki_core_packages b/scripts/compose_pki_core_packages
index eb124ebb0..fbd2b96b1 100755
--- a/scripts/compose_pki_core_packages
+++ b/scripts/compose_pki_core_packages
@@ -11,7 +11,6 @@
COMPOSE_PWD=`dirname $0`
source ${COMPOSE_PWD}/compose_functions
-
## Always switch into the base directory three levels
## above this shell script prior to executing it so
## that all of its output is written to this directory
@@ -214,3 +213,9 @@ chmod 775 ${PKI_CORE_PACKAGE_SCRIPT}
cd ${PKI_PACKAGES} ;
bash ./package_${PKI_CORE} | tee package_${PKI_CORE}.log 2>&1
+if [ "$CREATEREPO" == "Y" ] ; then
+ echo "Creating a repository of the built rpms"
+ cp -r $PKI_PWD/$PKI_DIR/scripts/repository.cfg .
+ cp -r $PKI_PWD/$PKI_DIR/scripts/scp_the_repo.exp .
+ Create_repo_after_build $REPO_CFG_FILE
+fi
diff --git a/scripts/compose_pki_test_package b/scripts/compose_pki_test_package
new file mode 100755
index 000000000..075495489
--- /dev/null
+++ b/scripts/compose_pki_test_package
@@ -0,0 +1,80 @@
+#!/bin/bash
+# BEGIN COPYRIGHT BLOCK
+# (C) 2010 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+
+check_for_dependencies()
+{
+ NOT_FOUND="FALSE"
+ for i in "expect" "beakerlib" "beaker-client" "rhts-devel"
+ do
+ rpm -qa $i
+ if [ $? -ne 0 ] ; then
+ echo "$i package required."
+ NOT_FOUND="TRUE"
+ fi
+ done
+ if [ $NOT_FOUND = "TRUE" ] ; then
+ echo "Cannot compose test rpm without installing the dependencies."
+ exit -1
+ fi
+}
+
+check_for_dependencies
+
+if [ $# -lt 2 ];
+then
+ echo "Usage: $0 User-ID_for_personalization Job_xml_config_file [--runtests]"
+ exit -1
+fi
+
+RUN_TESTS='N'
+
+if [ $# -gt 2 ];
+then
+ if [ $3 = "--runtests" ]
+ then
+ RUN_TESTS='Y'
+ fi
+fi
+
+### Directory with all the compose scripts
+COMPOSE_DIR=`dirname $0 | cd ; pwd`
+
+PKI_SOURCE_DIR=`cd $COMPOSE_DIR/..; pwd`
+
+### Build the task rpm outside the PKI git source tree.
+### The rhts-build-package command checks if the code is is a git repository,
+### if yes, it will compare tags of the current branch and the master branch.
+### If they do not match then the rpm is not built.
+
+WORK_DIR=`cd $COMPOSE_DIR/../..;pwd`
+
+BUILD_DIR="$WORK_DIR/package.tests"
+
+rm -rf $BUILD_DIR
+
+mkdir $BUILD_DIR
+
+cd $BUILD_DIR
+
+cp -r "$PKI_SOURCE_DIR/tests" .
+
+cd tests/dogtag
+
+### Passing the keyword for personalizing and an option
+### to maintain a seperate folder for each beaker job (Optional)
+./make-package.sh $1 $2
+
+mv *.rpm ../../
+
+mv *.xml ../../
+
+### Running the tasks
+
+cd $COMPOSE_DIR
+
+if [ $RUN_TESTS = "Y" ] ; then
+ ./run_tests
+fi
diff --git a/scripts/run_tests b/scripts/run_tests
new file mode 100755
index 000000000..8e4d65e9f
--- /dev/null
+++ b/scripts/run_tests
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+WAIT_FOR_RESULT='N'
+if [ $# -ge 1 ] ; then
+ if [ "$1" = "--wait-on-beaker-job" ] ; then
+ WAIT_FOR_RESULT="Y"
+ else
+ echo "Unrecognized option. Usage: ./runtests --wait-on-beaker-job(Optional)"
+ fi
+fi
+COMPOSE_PWD=`dirname $0 | cd; pwd`
+
+TEST_PACKAGE=`cd $COMPOSE_PWD/../../package.tests; pwd`
+
+if [ ! -d $TEST_PACKAGE ] ; then
+ echo "Cannot run tests on beaker. Please compose the test rpms."
+ exit -1
+fi
+
+cd $TEST_PACKAGE
+
+bkr task-add *.rpm
+
+if [ "$WAIT_FOR_RESULT" = "Y" ] ; then
+ bkr job-submit --wait *.xml
+else
+ bkr job-submit *.xml
+fi
diff --git a/scripts/scp_the_repo.exp b/scripts/scp_the_repo.exp
new file mode 100755
index 000000000..5b9637239
--- /dev/null
+++ b/scripts/scp_the_repo.exp
@@ -0,0 +1,16 @@
+#!/usr/bin/expect
+
+set timeout 20
+
+set copy_dir [lindex $argv 0]
+set url [lindex $argv 1]
+
+set password [lindex $argv 2]
+
+spawn scp -r $copy_dir $url
+
+expect "*password*"
+
+send "$password\r"
+
+expect eof