diff --git a/toci_functions.sh b/toci_functions.sh deleted file mode 100755 index b92b03b10..000000000 --- a/toci_functions.sh +++ /dev/null @@ -1,68 +0,0 @@ -# Tripleo CI functions - -# Revert a commit for tripleo ci -# $1 : project name e.g. nova -# $2 : hash id of commit to revert -# $3 : bug id of reason for revert (used to skip revert if found in commit -# that triggers ci). -function temprevert(){ - # Before reverting check to ensure this isn't the related fix - if git --git-dir=/opt/stack/new/${ZUUL_PROJECT#*/}/.git log -1 | grep -iE "bug.*$3" ; then - echo "Skipping temprevert because bug fix $3 was found in git message." - return 0 - fi - - pushd /opt/stack/new/$1 - # Abort on fail so we're not left in a conflict state - git revert --no-edit $2 || git revert --abort || true - popd -} - -# Pin to a commit for tripleo ci -# $1 : project name e.g. nova -# $2 : hash id of commit to pin too -# $3 : bug id of reason for the pin (used to skip revert if found in commit -# that triggers ci). -function pin(){ - # Before reverting check to ensure this isn't the related fix - if git --git-dir=/opt/stack/new/${ZUUL_PROJECT#*/}/.git log -1 | grep -iE "bug.*$3" ; then - echo "Skipping pin because bug fix $3 was found in git message." - return 0 - fi - - pushd /opt/stack/new/$1 - git reset --hard $2 - popd -} - -# Cherry-pick a commit for tripleo ci -# $1 : project name e.g. nova -# $2 : Gerrit refspec to cherry pick -function cherrypick(){ - local PROJ_NAME=$1 - local REFSPEC=$2 - - # Before cherrypicking check to ensure this isn't the related fix - if git --git-dir=/opt/stack/new/${ZUUL_PROJECT#*/}/.git log -1 | grep -iE "bug.*$3" ; then - echo "Skipping cherrypick because bug fix $3 was found in git message." - return 0 - fi - - pushd /opt/stack/new/$PROJ_NAME - git fetch https://review.openstack.org/openstack/$PROJ_NAME "$REFSPEC" - # Abort on fail so we're not left in a conflict state - git cherry-pick FETCH_HEAD || git cherry-pick --abort - popd - - # Export a DIB_REPOREF variable as well - export DIB_REPOREF_${PROJ_NAME//-/_}=$REFSPEC - -} - -# echo's out a project name from a ref -# $1 : e.g. openstack/nova:master:refs/changes/87/64787/3 returns nova -function filterref(){ - PROJ=${1%%:*} - PROJ=${PROJ##*/} - echo $PROJ -} diff --git a/toci_gate_test.sh b/toci_gate_test.sh index 13dc6d0b2..4eaf68e90 100755 --- a/toci_gate_test.sh +++ b/toci_gate_test.sh @@ -50,6 +50,7 @@ sudo sed -i -e "s|^#baseurl=http://download.fedoraproject.org/pub/fedora/linux|b sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT +echo 1 | sudo dd of=/proc/sys/net/ipv4/ip_forward TIMEOUT_SECS=$((DEVSTACK_GATE_TIMEOUT*60)) # ./testenv-client kill everything in its own process group it it hits a timeout diff --git a/toci_instack.sh b/toci_instack.sh index 2869f1395..a81ef13f1 100755 --- a/toci_instack.sh +++ b/toci_instack.sh @@ -6,14 +6,14 @@ if [ ! -e "$TE_DATAFILE" ] ; then exit 1 fi -export PATH=/sbin:/usr/sbin:$PATH -source toci_functions.sh - export TRIPLEO_ROOT=/opt/stack/new +export PATH=/sbin:/usr/sbin:$PATH + +source $TRIPLEO_ROOT/tripleo-common/scripts/common_functions.sh + mkdir -p $WORKSPACE/logs -# ===== Start : Yum repository setup ==== -[ -d $TRIPLEO_ROOT/delorean ] || git clone https://github.com/openstack-packages/delorean.git $TRIPLEO_ROOT/delorean +MY_IP=$(ip addr show dev eth1 | awk '/inet / {gsub("/.*", "") ; print $2}') # Now that we have setup all of our git repositories we need to build packages from them # If this is a job to test master of everything we get a list of all git repo's @@ -23,42 +23,8 @@ if [ -z "${ZUUL_CHANGES:-}" ] ; then fi ZUUL_CHANGES=${ZUUL_CHANGES//^/ } -# prep delorean -sudo yum install -y docker-io createrepo yum-plugin-priorities yum-utils -sudo systemctl start docker - -cd $TRIPLEO_ROOT/delorean - -# Delorean upstream is using mock and we're not yet setup to use it -# pin delorean while we have a chance to make the changes -git reset --hard a35a58207e4004d202daa6fe4bed3cf03b7f8440 - -sudo rm -rf data *.sqlite -mkdir -p data - -sudo semanage fcontext -a -t svirt_sandbox_file_t "$TRIPLEO_ROOT/delorean/data(/.)?" -sudo semanage fcontext -a -t svirt_sandbox_file_t "$TRIPLEO_ROOT/delorean/scripts(/.)?" -sudo restorecon -R "$TRIPLEO_ROOT/delorean" - -MY_IP=$(ip addr show dev eth1 | awk '/inet / {gsub("/.*", "") ; print $2}') - -sudo chown :$(id -g) /var/run/docker.sock -# Download a prebuilt build image instead of building one. -# Image built as usual then exported using "docker save delorean/centos > centos-$date-$x.tar" -curl http://${PYPIMIRROR}/buildimages/centos-20150921-1.tar | docker load - -docker rm -f builder-centos || true - -sed -i -e "s%reponame=.*%reponame=delorean-ci%" projects.ini -sed -i -e "s%target=.*%target=centos%" projects.ini -sed -i -e "s%baseurl=.*%baseurl=https://trunk.rdoproject.org/centos7%" projects.ini -# Remove the rpm install test to speed up delorean (our ci test will to this) -# TODO: and an option for this in delorean -sed -i -e 's%.*installed.*%touch $OUTPUT_DIRECTORY/installed%' scripts/build_rpm.sh - -virtualenv venv -./venv/bin/pip install -r requirements.txt -./venv/bin/python setup.py install +# Setup delorean +$TRIPLEO_ROOT/tripleo-common/scripts/tripleo.sh --delorean-setup # post ci chores to run at the end of ci SSH_OPTIONS='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=Verbose -o PasswordAuthentication=no' @@ -91,50 +57,31 @@ function postci(){ } trap "postci" EXIT -# build packages -# loop through each of the projects listed in ZUUL_CHANGES if it is a project we -# are capable of building an rpm for then build it. -# e.g. ZUUL_CHANGES=openstack/cinder:master:refs/changes/61/71461/4^opensta... +DELOREAN_BUILD_REFS= for PROJFULLREF in $ZUUL_CHANGES ; do - PROJ=$(filterref $PROJFULLREF) - - # If ci is being run for a change to ci its ok not to have a ci repository + # If ci is being run for a change to ci its ok not to have a ci produced repository # We also don't build packages for puppet repositories, we use them from source if [ "$PROJ" == "tripleo-ci" ] || [[ "$PROJ" =~ puppet-* ]] ; then - NO_CI_REPO_OK=1 + mkdir -p $TRIPLEO_ROOT/delorean/data/repos/current + touch $TRIPLEO_ROOT/delorean/data/repos/current/delorean-ci.repo if [[ "$PROJ" =~ puppet-* ]] ; then # openstack/puppet-nova:master:refs/changes/02/213102/5 -> refs/changes/02/213102/5 export DIB_REPOREF_${PROJ//-/_}=${PROJFULLREF##*:} fi + else + DELOREAN_BUILD_REFS="$DELOREAN_BUILD_REFS $PROJ" fi - - MAPPED_PROJ=$(./venv/bin/python scripts/map-project-name $PROJ || true) - [ -e data/$MAPPED_PROJ ] && continue - cp -r $TRIPLEO_ROOT/$PROJ data/$MAPPED_PROJ - pushd data/$MAPPED_PROJ - GITHASH=$(git rev-parse HEAD) - - # Set the branches delorean reads to the same git hash as ZUUL has left for us - for BRANCH in master origin/master ; do - git checkout -b $BRANCH || git checkout $BRANCH - git reset --hard $GITHASH - done - popd - - ./venv/bin/delorean --config-file projects.ini --head-only --package-name $MAPPED_PROJ --local --build-env DELOREAN_DEV=1 --build-env http_proxy=$http_proxy --info-repo rdoinfo done -# If this was a ci job for a change to ci then we do not have a ci repository (no packages to build) -# Create a dummy repository file so ci can proceed as normal -if [ "${NO_CI_REPO_OK:-}" == 1 ] ; then - mkdir -p data/repos/current - touch data/repos/current/delorean-ci.repo +# Build packages +if [ -n "$DELOREAN_BUILD_REFS" ] ; then + $TRIPLEO_ROOT/tripleo-common/scripts/tripleo.sh --delorean-build $DELOREAN_BUILD_REFS fi # kill the http server if its already running ps -ef | grep -i python | grep SimpleHTTPServer | awk '{print $2}' | xargs kill -9 || true -cd data/repos +cd $TRIPLEO_ROOT/delorean/data/repos sudo iptables -I INPUT -p tcp --dport 8766 -i eth1 -j ACCEPT python -m SimpleHTTPServer 8766 1>$WORKSPACE/logs/yum_mirror.log 2>$WORKSPACE/logs/yum_mirror_error.log &