#!/bin/sh
DIR=`dirname $0`
cd "${DIR}" || exit 1

REPO_URL='https://github.com/openstack/fuel-noop-fixtures.git'

clone_fixtures_repo() {
  if ! [ -d 'fuel-noop-fixtures' ]; then
    echo "Cloning the repository..."
    git clone "${REPO_URL}" 'fuel-noop-fixtures'
  fi
}

update_fixtures_repo() {
  echo "Updating the repository..."
  cd 'fuel-noop-fixtures' || return 1
  git fetch --all
  git clean -fd
  git reset --hard 'origin/master'
  cd '..'
}

link_specs_to_fixtures() {
  if ! [ -L 'fuel-noop-fixtures/spec/hosts' ]; then
    echo "Linking specs top the repository..."
    rm -rf 'fuel-noop-fixtures/spec/hosts'
    ln -sf '../../spec/hosts' 'fuel-noop-fixtures/spec/hosts'
  fi
}

prepare_environment() {
  echo "Preparing the environment..."
  ./noop_tests.sh -bB -d -t -l -L
}

clone_fixtures_repo
update_fixtures_repo
link_specs_to_fixtures
prepare_environment

#!/bin/sh
DIR=`dirname $0`
cd "${DIR}" || exit 1

REPO_URL=${NOOP_FIXTURES_REPO_URL:-'https://github.com/openstack/fuel-noop-fixtures.git'}
BRANCH=${NOOP_FIXTURES_BRANCH:-'origin/master'}
GERRIT_URL=${NOOP_FIXTURES_GERRIT_URL:-'https://review.openstack.org/openstack/fuel-noop-fixtures'}
GERRIT_COMMIT=${NOOP_FIXTURES_GERRIT_COMMIT:-'none'}

clone_fixtures_repo() {
  if ! [ -d 'fuel-noop-fixtures' ]; then
    echo "Cloning the repository..."
    git clone "${REPO_URL}" 'fuel-noop-fixtures'
  fi
}

update_fixtures_repo() {
  echo "Updating the repository..."
  cd 'fuel-noop-fixtures' || return 1
  git fetch --all
  git clean -fd
  git reset --hard $BRANCH
  if [ "$GERRIT_COMMIT" != "none" ]; then
    for patch in $GERRIT_COMMIT ; do
      git fetch $GERRIT_URL $patch && git cherry-pick FETCH_HEAD || exit 1
    done
  fi
  cd '..'
}

link_specs_to_fixtures() {
  if ! [ -L 'fuel-noop-fixtures/spec/hosts' ]; then
    echo "Linking specs top the repository..."
    rm -rf 'fuel-noop-fixtures/spec/hosts'
    ln -sf '../../spec/hosts' 'fuel-noop-fixtures/spec/hosts'
  fi
}

prepare_environment() {
  echo "Preparing the environment..."
  ./noop_tests.sh -bB -d -t -l -L
}

clone_fixtures_repo
update_fixtures_repo
link_specs_to_fixtures
prepare_environment

Add a possibility to customize fixtures source
Add a possibility to customize fixtures source

This patch adds a possibility to provide custom git repo, gerrit
repo, branch and gerrit refs for fuel-noop-fixtures. Does not
affect deployment, only noop rspec tests.

Fuel-CI: disable

Docs update: I10a4572b98d715ce1382fc7533847e1c1f16f81b
Closes-bug: #1566220

Change-Id: I492716d21f9c81325a9f75aaf3b7a0894a5e00cf
