From 648f74b0068793f52dd3296c051ef60cbb5e82ed Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Mon, 13 Jul 2015 23:49:18 +1000 Subject: Add tool for updating datasets Crude copy of migration script for updating datasets for testing. Change-Id: Ic92809c2b9f963af94ca43872835a7e43a9c6d35 --- tools/update_datasets.sh | 278 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 tools/update_datasets.sh diff --git a/tools/update_datasets.sh b/tools/update_datasets.sh new file mode 100644 index 0000000..b635b84 --- /dev/null +++ b/tools/update_datasets.sh @@ -0,0 +1,278 @@ +#!/bin/bash +# +# Copyright 2014 Rackspace Australia +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# A tool to update a given dataset to a given version. Used to keep datasets +# somewhat fresh rather than over-exercising old migrations. + + +# Usage: ./update_datasets.sh VENV_NAME WORKING_DIR GIT_PATH DB_USER DB_PASS DB_NAME SEED_DATA OUTPUT_DATA +# apt-get install git virtualenvwrapper python-pip mysql-server python-lxml build-essential libffi-dev + +# $1 is the unique job id +# $2 is the working dir path +# $3 is the path to the git repo path +# $4 is the nova db user +# $5 is the nova db password +# $6 is the nova db name +# $7 is the path to the seed dataset to test against +# $8 is the logging.conf for openstack +# $9 is the pip cache dir + +UNIQUE_ID=$1 +WORKING_DIR_PATH=`realpath $2` +GIT_REPO_PATH=`realpath $3` +DB_USER=$4 +DB_PASS=$5 +DB_NAME=$6 +DATASET_SEED_SQL=`realpath $7` +DATASET_OUTPUT_SQL=$8 + +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +# We also support the following environment variables to tweak our behavour: +# NOCLEANUP: if set to anything, don't cleanup at the end of the run + +pip_requires() { + pip install -q mysql-python + pip install -q eventlet + requires="tools/pip-requires" + if [ ! -e $requires ] + then + requires="requirements.txt" + fi + echo "Install pip requirements from $requires" + pip install -q -r $requires + echo "Requirements installed" +} + +db_sync() { + # $1 is the test target (ie branch name) + # $2 is an (optional) destination version number + + # Create a nova.conf file + cat - > $WORKING_DIR_PATH/nova-$1.conf < $DATASET_OUTPUT_SQL -- cgit v1.2.1