From 2ee22e041d7c003964150cf0c009caca14b7d051 Mon Sep 17 00:00:00 2001 From: Fausto Marzi Date: Mon, 18 Jan 2016 09:23:19 +0000 Subject: [PATCH] Adding devstack plugin for freezer gate job Currently the plugin is moslty a copy of the freeer-api plugin. At first instance we can enable the gate and have the job executign without error, after this we can commit new changes to execute freezer specific tests. Anyway the freezer-api plugin is most likley needed to execute the freezer-agent and freezer-scheduler tests Implements bp: freezer-dsvm Depends-on: I837e3fe973d72c792cb34711cef9f6507a004d49 Change-Id: Iee995d5b32c17c4dbee5f5736b26bf3b9aa8ca14 --- devstack/README.rst | 22 ++++++++ devstack/gate_hook.sh | 21 ++++++++ devstack/lib/freezer | 102 ++++++++++++++++++++++++++++++++++++ devstack/local.conf.example | 31 +++++++++++ devstack/plugin.sh | 37 +++++++++++++ devstack/settings | 28 ++++++++++ tests/post_test_hook.sh | 24 +++++++++ 7 files changed, 265 insertions(+) create mode 100644 devstack/README.rst create mode 100755 devstack/gate_hook.sh create mode 100644 devstack/lib/freezer create mode 100644 devstack/local.conf.example create mode 100755 devstack/plugin.sh create mode 100644 devstack/settings create mode 100755 tests/post_test_hook.sh diff --git a/devstack/README.rst b/devstack/README.rst new file mode 100644 index 00000000..0bc54da4 --- /dev/null +++ b/devstack/README.rst @@ -0,0 +1,22 @@ +This directory contains the Freezer DevStack plugin. + +To configure the Freezer scheduler and agent with DevStack, you will need to +enable this plugin by adding one line to the [[local|localrc]] +section of your local.conf file. + +To enable the plugin, add a line of the form:: + + enable_plugin freezer [GITREF] + +where:: + + is the URL of a freezer repository + [GITREF] is an optional git ref (branch/ref/tag). The default is master. + +For example:: + + enable_plugin freezer https://git.openstack.org/openstack/freezer.git master + + +For more information, see: + http://docs.openstack.org/developer/devstack/plugins.html diff --git a/devstack/gate_hook.sh b/devstack/gate_hook.sh new file mode 100755 index 00000000..f3daf834 --- /dev/null +++ b/devstack/gate_hook.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# 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. + +set -ex + +# Install freezer devstack integration +export DEVSTACK_LOCAL_CONFIG="enable_plugin freezer https://git.openstack.org/openstack/freezer" + +$BASE/new/devstack-gate/devstack-vm-gate.sh diff --git a/devstack/lib/freezer b/devstack/lib/freezer new file mode 100644 index 00000000..8c185da8 --- /dev/null +++ b/devstack/lib/freezer @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# 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. + +# Install and start Freezer service + +# add the following to localrc: +# enable_service freezer +# +# Dependencies: +# - functions +# - OS_AUTH_URL for auth in api +# - DEST set to the destination directory +# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api +# - STACK_USER service user + +# functions called by the plugin.sh script +# source plugin.sh [phase] +# --------- +# - +# - [pre-install] +# - [install] +# - install_freezer +# - [extra] +# - init_freezer_scheduler +# - start_freezer_scheduler +# - +# - stop_freezer_scheduler +# - +# - cleanup_freezer_scheduler + +# Save trace setting +XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Functions +# --------- + +function is_freezer_enabled { + [[ ,${ENABLED_SERVICES} =~ ,"freezer" ]] && return 0 +} + + +# executed during: stack install +function install_freezer{ + + git_clone $FREEZER_REPO $FREEZER_DIR $FREEZER_BRANCH + setup_develop $FREEZER_DIR +} + +# executed during: stack post-config +function configure_freezer_scheduler { + + [ ! -d $FREEZER_CONF_DIR ] && sudo mkdir -m 755 -p $FREEZER_CONF_DIR + sudo chown $USER $FREEZER_CONF_DIR + + [ ! -d $FREEZER_LOG_DIR ] && sudo mkdir -m 755 -p $FREEZER_LOG_DIR + sudo chown $USER $FREEZER_LOG_DIR + +} + + +# executed during: stack extra +function init_freezer_scheduler { +# Add scheduler settings here + : +} + + +# executed during: stack extra +function start_freezer_scheduler { +# Add scheduler starts here + : +} + + +# executed during: stop +function stop_freezer_scheduler { + stop_process freezer-scheduler +} + + +# utility function +function get_id { + echo `"$@" | awk '/ id / { print $4 }'` +} + +# Restore xtrace +$XTRACE diff --git a/devstack/local.conf.example b/devstack/local.conf.example new file mode 100644 index 00000000..6f7bf69f --- /dev/null +++ b/devstack/local.conf.example @@ -0,0 +1,31 @@ +# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# 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. + +[[local|localrc]] +disable_all_services + +enable_plugin freezer https://git.openstack.org/openstack/freezer master + +enable_service rabbit mysql key + +# This is to keep the token small for testing +KEYSTONE_TOKEN_FORMAT=UUID + +# Modify passwords as needed +DATABASE_PASSWORD=secretdatabase +RABBIT_PASSWORD=secretrabbit +ADMIN_PASSWORD=secretadmin +SERVICE_PASSWORD=secretservice +SERVICE_TOKEN=111222333444 + diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100755 index 00000000..d308fccf --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,37 @@ +# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# 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. + +# check for service enabled +if is_service_enabled freezer; then + if [[ "$1" == "source" || "`type -t install_freezer`" != 'function' ]]; then + # Initial source + source $FREEZER_DIR/devstack/lib/freezer + fi + + if [[ "$1" == "stack" && "$2" == "install" ]]; then + echo_summary "Installing Freezer" + install_freezer + elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then + echo_summary "Configuring Freezer" + configure_freezer + elif [[ "$1" == "stack" && "$2" == "extra" ]]; then + echo_summary "Initializing Freezer Scheduler" + init_freezer_scheduler + start_freezer_scheduler + fi + + if [[ "$1" == "unstack" ]]; then + stop_freezer_scheduler + fi +fi diff --git a/devstack/settings b/devstack/settings new file mode 100644 index 00000000..99c84323 --- /dev/null +++ b/devstack/settings @@ -0,0 +1,28 @@ +# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# 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. + +# Defaults +# -------- + +# Set up default directories +FREEZER_DIR=$DEST/freezer +FREEZER_FILES=${FREEZER_API_DIR}/devstack/files +FREEZER_CONF_DIR=${FREEZER_CONF_DIR:-/etc} +FREEZER_LOG_DIR=$DEST/logs + +# Freezer API repository +FREEZER_REPO=${FREEZER_REPO:-${GIT_BASE}/stackforge/freezer.git} +FREEZER_BRANCH=${FREEZER_BRANCH:-master} + +enable_service freezer diff --git a/tests/post_test_hook.sh b/tests/post_test_hook.sh new file mode 100755 index 00000000..2ff9d87d --- /dev/null +++ b/tests/post_test_hook.sh @@ -0,0 +1,24 @@ +#!/bin/bash +#(c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# 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. + +# This script is executed inside post_test_hook function in devstack gate. + +# Install packages from test-requirements.txt +sudo pip install -r /opt/stack/new/freezer-api/test-requirements.txt + +cd /opt/stack/new/freezer-api/tests +echo 'Running freezer integration tests' +# Here it goes the command to execute integration tests +# sudo ./run_tests.sh