|
#!/bin/bash
|
|
set -ex
|
|
BASE=~/teuth_migration
|
|
#TEUTH_REM=git://ceph.com/git/teuthology.git
|
|
TEUTH_REM=$BASE/clean/teuthology
|
|
TEUTH_REPO=$BASE/split/teuthology
|
|
#SUITE_REM=git://ceph.com/git/ceph-qa-suite.git
|
|
SUITE_REM=$BASE/clean/ceph-qa-suite
|
|
SUITE_REPO=$BASE/split/ceph-qa-suite
|
|
NEW_REPO=$BASE/split/new-repo
|
|
FILES_INT=$(cat ./lists/task_files_keep)
|
|
FILES_EXT=$(cat ./lists/task_files_move)
|
|
DIRS_EXT=$(cat ./lists/task_dirs_move)
|
|
|
|
function clone_repos {
|
|
echo "clone_repos"
|
|
update_clean_copy $TEUTH_REM
|
|
git clone $TEUTH_REM $TEUTH_REPO
|
|
update_clean_copy $SUITE_REM
|
|
git clone $SUITE_REM $SUITE_REPO
|
|
|
|
pushd $SUITE_REPO
|
|
git remote add -f teuthology $TEUTH_REPO
|
|
popd
|
|
}
|
|
|
|
function update_clean_copy {
|
|
echo "update_clean_copy"
|
|
pushd $1
|
|
reset_branch master
|
|
reset_branch firefly
|
|
reset_branch dumpling
|
|
git checkout master
|
|
popd
|
|
}
|
|
|
|
function reset_branch {
|
|
echo "reset_branch"
|
|
BRANCH=$1
|
|
git fetch
|
|
git checkout $BRANCH
|
|
git reset --hard origin/$BRANCH
|
|
}
|
|
|
|
function import_tasks {
|
|
echo "import_tasks"
|
|
BRANCH=$1
|
|
pushd $TEUTH_REPO
|
|
git checkout $BRANCH
|
|
popd
|
|
|
|
pushd $SUITE_REPO
|
|
git checkout $BRANCH
|
|
git checkout -b teuth_$BRANCH
|
|
git fetch teuthology $BRANCH
|
|
git reset --hard teuthology/$BRANCH
|
|
patch_teuthology_pre $BRANCH
|
|
mkdir .tasks/
|
|
git add .tasks/
|
|
git mv -k $FILES_EXT .tasks/
|
|
git mv -k $DIRS_EXT .tasks/
|
|
git mv teuthology/task_util .tasks/util
|
|
git rm -r * .gitignore
|
|
git mv .tasks tasks
|
|
touch tasks/__init__.py
|
|
git add tasks/__init__.py
|
|
git commit -s -a -m "Import teuthology tasks ($BRANCH branch)"
|
|
git checkout $BRANCH
|
|
git checkout -b tasks_$BRANCH
|
|
git merge --no-edit teuth_$BRANCH
|
|
git branch -D teuth_$BRANCH
|
|
popd
|
|
}
|
|
|
|
function patch_teuthology_pre {
|
|
echo "patch_teuthology_pre"
|
|
BRANCH=$1
|
|
if [ $BRANCH = 'dumpling' ]; then
|
|
git am < $BASE/patches/0001-Remove-ship_utilities_dumpling.patch
|
|
git am < $BASE/patches/0002-adjust-ulimits-and-daemon-helper-are-in-PATH_dumpling.patch
|
|
git am < $BASE/patches/0003-Use-new-get_valgrind_args-args_dumpling.patch
|
|
git am < $BASE/patches/0004-Add-wait_until_fuse_mounted_dumpling.patch
|
|
git am < $BASE/patches/0005-Move-write_secret_file-into-task_util-kclient.py_dumpling.patch
|
|
elif [ $BRANCH = 'firefly' ]; then
|
|
git am < $BASE/patches/0004-Add-wait_until_fuse_mounted_firefly.patch
|
|
git am < $BASE/patches/0005-Move-write_secret_file-into-task_util-kclient.py_firefly.patch
|
|
fi
|
|
}
|
|
|
|
function git_mv_if_exists {
|
|
FILES=$1
|
|
DEST=$2
|
|
for FILE in $FILES; do
|
|
if [ -e $FILES]; then
|
|
git mv $FILE $DEST
|
|
else
|
|
echo "$FILE does not exist - not moving"
|
|
fi
|
|
done
|
|
}
|
|
|
|
function git_rm_if_exists {
|
|
FILE=$1
|
|
if [ -d $FILE ]; then
|
|
git rm -r $FILE
|
|
elif [ -e $FILE ]; then
|
|
git rm $FILE
|
|
else
|
|
echo "$FILE does not exist - not removing"
|
|
fi
|
|
}
|
|
|
|
function remove_old_tasks {
|
|
echo "remove_old_tasks"
|
|
BRANCH=$1
|
|
pushd $TEUTH_REPO
|
|
git checkout $BRANCH
|
|
git checkout -b notasks_$BRANCH
|
|
for DIR in $DIRS_EXT; do
|
|
git_rm_if_exists $DIR
|
|
done
|
|
for FILE in $FILES_EXT; do
|
|
git_rm_if_exists $FILE
|
|
done
|
|
git rm -r teuthology/task_util
|
|
git commit -s -a -m "Remove most ceph-specific tasks. They are in ceph-qa-suite now."
|
|
popd
|
|
}
|
|
|
|
function patch_tasks {
|
|
echo "patch_tasks"
|
|
BRANCH=$1
|
|
pushd $SUITE_REPO
|
|
git checkout tasks_$BRANCH
|
|
sed -i '' -e 's/teuthology\.task_util/util/' tasks/*.py
|
|
sed -i '' -e 's/\.\.orchestra/teuthology.orchestra/' tasks/*.py tasks/util/*.py
|
|
sed -i '' -e 's/lock.list_locks(ctx)/list_locks()/' tasks/*.py
|
|
sed -i '' -e 's/from teuthology\.task import rbd/from tasks import rbd/' tasks/*.py
|
|
sed -i '' -e 's/from teuthology\.task\.samba/from .samba/' tasks/*.py
|
|
if [ -d tasks/cephfs ]
|
|
then
|
|
sed -i '' -e 's/from teuthology.task.cephfs/from /' tasks/cephfs/*.py
|
|
sed -i '' -e 's/from \.\.\.orchestra import/from teuthology.orchestra import/' tasks/cephfs/*.py
|
|
sed -i '' -e 's/from teuthology\.task import ceph_manager/from tasks import ceph_manager/' tasks/cephfs/*.py
|
|
fi
|
|
sed -i '' -e 's/from teuthology.task.cephfs/from cephfs/' tasks/*.py
|
|
sed -i '' -e 's/from teuthology.task import ceph/from . import ceph/' tasks/*.py
|
|
sed -i '' -e 's/import install/from teuthology.task import install/' tasks/*.py
|
|
sed -i '' -e 's/from .. import/from teuthology import/' tasks/*.py
|
|
sed -i '' -e 's/from ..contextutil import/from teuthology.contextutil import/' tasks/*.py
|
|
sed -i '' -e 's/from .common_fs_utils import/from teuthology.task.common_fs_utils import/' tasks/*.py
|
|
sed -i '' -e 's/from ..config import/from teuthology.config import/' tasks/*.py
|
|
sed -i '' -e 's/teuthology\.task\.ceph/tasks.ceph/' tasks/*.py
|
|
sed -i '' -e 's/teuthology\.task\.scrub/tasks.scrub/' tasks/*.py
|
|
git commit -s -a -m "Update module references"
|
|
|
|
if grep -rq 'exitstatus.get()' tasks/*.py; then
|
|
sed -i '' -e 's/exitstatus\.get()/wait()/g' tasks/*.py
|
|
sed -i '' -e 's/exitstatus\.ready()/poll()/g' tasks/*.py
|
|
git commit -s -a -m "Use newer orchestra API"
|
|
fi
|
|
|
|
if [ $BRANCH = 'dumpling' ] || [ $BRANCH = 'firefly' ]; then
|
|
git am < $BASE/patches/1001-Use-teuthology-s-DaemonGroup_$BRANCH.patch
|
|
git am < $BASE/patches/1002-Use-Remote.user_$BRANCH.patch
|
|
fi
|
|
popd
|
|
}
|
|
|
|
function patch_teuthology_post {
|
|
echo "patch_teuthology_post"
|
|
BRANCH=$1
|
|
pushd $TEUTH_REPO
|
|
git checkout notasks_$BRANCH
|
|
git am < $BASE/patches/2001-Correctly-find-both-internal-and-external-tasks_$BRANCH.patch
|
|
popd
|
|
}
|
|
|
|
function add_remotes {
|
|
pushd $TEUTH_REPO
|
|
git remote add github git@github.com:ceph/teuthology.git
|
|
popd
|
|
pushd $SUITE_REPO
|
|
git remote add github git@github.com:ceph/ceph-qa-suite.git
|
|
popd
|
|
}
|
|
|
|
function push_to_github {
|
|
REPO=$1
|
|
BRANCH=$2
|
|
pushd $REPO
|
|
git checkout $BRANCH
|
|
git push --force github
|
|
popd
|
|
}
|
|
|
|
function do_everything {
|
|
echo "do_everything"
|
|
BRANCH=$1
|
|
import_tasks $BRANCH
|
|
patch_tasks $BRANCH
|
|
remove_old_tasks $BRANCH
|
|
patch_teuthology_post $BRANCH
|
|
push_to_github $SUITE_REPO tasks_$BRANCH
|
|
}
|
|
|
|
pushd $BASE
|
|
clone_repos
|
|
add_remotes
|
|
do_everything dumpling
|
|
do_everything firefly
|
|
do_everything master
|
|
push_to_github $TEUTH_REPO notasks_master
|
|
|
|
|
|
# need to:
|
|
# ✓ change script to keep install and internal in teuth
|
|
# ✓ update teuth to reflect
|
|
# ✓ implement what's needed in teuth-run
|
|
# ✓ update dumpling tasks to reflect adjust-ulimits move
|