diff options
-rw-r--r-- | scripts/compose_functions | 84 | ||||
-rwxr-xr-x | scripts/compose_pki_core_packages | 7 | ||||
-rwxr-xr-x | scripts/compose_pki_test_package | 80 | ||||
-rwxr-xr-x | scripts/run_tests | 28 | ||||
-rwxr-xr-x | scripts/scp_the_repo.exp | 16 | ||||
-rw-r--r-- | tests/dogtag/beakerjob.rhcs.xml.template (renamed from tests/dogtag/beakerjob.rhcs.x86_64.f19.xml) | 12 | ||||
-rwxr-xr-x | tests/dogtag/make-package.sh | 14 | ||||
-rwxr-xr-x | tests/dogtag/update_beaker_job.py | 52 |
8 files changed, 278 insertions, 15 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 diff --git a/tests/dogtag/beakerjob.rhcs.x86_64.f19.xml b/tests/dogtag/beakerjob.rhcs.xml.template index a15417cf5..5ba50d086 100644 --- a/tests/dogtag/beakerjob.rhcs.x86_64.f19.xml +++ b/tests/dogtag/beakerjob.rhcs.xml.template @@ -9,15 +9,12 @@ <packages/> <ks_appends/> <repos> - <repo name="repo1" url="http://mickey.dsdev.sjc.redhat.com/repos/pki/dogtag/10/F19/devel_x86_64/x86_64/"/> - <repo name="repo2" url="http://mickey.dsdev.sjc.redhat.com/repos/pki/dogtag/10/F19/devel_x86_64/noarch/"/> </repos> <distroRequires> <and> - <distro_family op="=" value="Fedora19"/> - <distro_variant op="=" value="Fedora"/> - <distro_name op="=" value="Fedora-19"/> - <distro_arch op="=" value="x86_64"/> + <distro_family op="=" value=""/> + <distro_name op="=" value=""/> + <distro_arch op="=" value=""/> </and> </distroRequires> <hostRequires> @@ -27,7 +24,7 @@ <task name="/distribution/install" role="STANDALONE"> <params/> </task> - <task name="/CoreOS/rhcs/lsunkaras_dir" role="MASTER"> + <task name="/CoreOS/rhcs/PKI_TEST_USER_ID" role="MASTER"> <params> <param name="TEST_ALL" value="TRUE"/> <param name="QUICKINSTALL" value="FALSE"/> @@ -35,6 +32,7 @@ <param name="USER_SHOW_CA" value="FALSE"/> <param name="USER_FIND_CA" value="FALSE"/> <param name="USER_DEL_CA" value="FALSE"/> + <param name="DEV_JAVA_TESTS" value="FALSE"/> </params> </task> <task name="/distribution/reservesys" role="STANDALONE"> diff --git a/tests/dogtag/make-package.sh b/tests/dogtag/make-package.sh index 6e809104a..0ba0018a5 100755 --- a/tests/dogtag/make-package.sh +++ b/tests/dogtag/make-package.sh @@ -1,9 +1,9 @@ #!/bin/sh -### Exit if there is no personalization id specified. -if [ $# -lt 1 ]; +### Exit if there not enough parameters specified. +if [ $# -lt 2 ]; then - echo "Usage: ./make-package.sh <User-ID> <Different_subfolder_for_each_beaker_job_?(Y/N)(Optional)>" + echo "Usage: ./make-package.sh User-ID Job_xml_config_file [Different_subfolder_for_each_beaker_job_?(Y/N)]" exit -1 fi @@ -22,8 +22,6 @@ then fi fi -#rpm_identifier=".$date_time" -echo $user_id ### Replacing the default value with the "user_id/current_number" sed -e "s|PKI_TEST_USER_ID|${user_id}|g" -e "s|_RPM_IDENTIFIER|${rpm_identifier}|g" .Makefile.save >> Makefile @@ -32,8 +30,12 @@ chmod +x Makefile ### Making the rpm make package -### Remove the current rpm and place the original back +### Remove the current makefile and place the original back rm -rf Makefile mv .Makefile.save Makefile + +sed -e "s|PKI_TEST_USER_ID|${user_id}|g" beakerjob.rhcs.xml.template >> beakerjob.rhcs.xml + +python update_beaker_job.py beakerjob.rhcs.xml $2 diff --git a/tests/dogtag/update_beaker_job.py b/tests/dogtag/update_beaker_job.py new file mode 100755 index 000000000..3987e30cd --- /dev/null +++ b/tests/dogtag/update_beaker_job.py @@ -0,0 +1,52 @@ +#! /usr/bin/python + +import sys +from lxml import etree +from ConfigParser import ConfigParser + + +""" Parse the xml template and replace the values with the + values from the configuration file passed. + Usage: py modifybeakerjobxml.py <XML_TEMPLATE_PATH> <CONFIG_FILE_PATH>""" + + +doc = etree.parse(str(sys.argv[1])) + +parser = ConfigParser() +parser.read(str(sys.argv[2])) + +props=parser.defaults() + +repos=props['repos'] + +if repos is not None: + repos = str(repos).split() + repos_element=doc.getroot().find('recipeSet/recipe/repos') + i = 1 + for repo in repos: + new_child = etree.SubElement(repos_element, 'repo', name='repo'+str(i), url=repo) + i = i + 1 + +element = None +distro_family = props['distro_family'] +if distro_family is not None: + element=doc.find('recipeSet/recipe/distroRequires/and/distro_family') + element.attrib['value'] = distro_family + +distro_name = props['distro_name'] +if distro_name is not None: + element=doc.find('recipeSet/recipe/distroRequires/and/distro_name') + element.attrib['value'] = distro_name + +distro_arch = props['distro_arch'] +if distro_arch is not None: + element=doc.find('recipeSet/recipe/distroRequires/and/distro_arch') + element.attrib['value'] = distro_arch + +hostname = props['hostname'] +if distro_family is not None: + element=doc.find('recipeSet/recipe/hostRequires') + etree.SubElement(element, 'hostname', op='=', value=hostname) + +with open(str(sys.argv[1]), 'w') as outfile: + doc.write(outfile) |