Added storyboard API to webclient venv
This change adds the storyboard API as a dependency for the virtual environment so we can run integration and functional tests with a live API. It also sets up the grunt development server with a local proxy so that we don't have to worry about implementing CORS immediately. Change-Id: I4835649630ef69f13d73ef2a10dff860aceb1f49
This commit is contained in:
parent
3d304bf7fe
commit
2153ac56e5
20
Gruntfile.js
20
Gruntfile.js
@ -34,6 +34,7 @@ var mountFolder = function (connect, dir) {
|
||||
'use strict';
|
||||
return connect.static(require('path').resolve(dir));
|
||||
};
|
||||
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
|
||||
|
||||
|
||||
module.exports = function (grunt) {
|
||||
@ -405,12 +406,21 @@ module.exports = function (grunt) {
|
||||
port: 9000,
|
||||
hostname: 'localhost'
|
||||
},
|
||||
proxies: [
|
||||
{
|
||||
context: '/v1',
|
||||
host: 'localhost',
|
||||
port: 8080,
|
||||
https: false
|
||||
}
|
||||
],
|
||||
livereload: {
|
||||
options: {
|
||||
middleware: function (connect) {
|
||||
return [
|
||||
lrSnippet,
|
||||
mountFolder(connect, dir.output)
|
||||
mountFolder(connect, dir.output),
|
||||
proxySnippet
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -420,7 +430,8 @@ module.exports = function (grunt) {
|
||||
keepalive: true,
|
||||
middleware: function (connect) {
|
||||
return [
|
||||
mountFolder(connect, dir.output)
|
||||
mountFolder(connect, dir.output),
|
||||
proxySnippet
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -429,7 +440,8 @@ module.exports = function (grunt) {
|
||||
options: {
|
||||
middleware: function (connect) {
|
||||
return [
|
||||
mountFolder(connect, dir.output)
|
||||
mountFolder(connect, dir.output),
|
||||
proxySnippet
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -524,6 +536,7 @@ module.exports = function (grunt) {
|
||||
'compile',
|
||||
'package',
|
||||
'open',
|
||||
'configureProxies:server',
|
||||
'connect:dist'
|
||||
]);
|
||||
|
||||
@ -535,6 +548,7 @@ module.exports = function (grunt) {
|
||||
grunt.registerTask('server', [
|
||||
'clean',
|
||||
'compile',
|
||||
'configureProxies:server',
|
||||
'connect:livereload',
|
||||
'open',
|
||||
'watch'
|
||||
|
18
README.md
18
README.md
@ -39,6 +39,8 @@ A WebClient for the OpenStack Storyboard project.
|
||||
|
||||
* `source .tox/node/bin/activate`
|
||||
|
||||
#### Within the virtual environment, you have the following options
|
||||
|
||||
**Update/refresh the javascript build and runtime dependencies**
|
||||
|
||||
* `npm prune`
|
||||
@ -57,3 +59,19 @@ A WebClient for the OpenStack Storyboard project.
|
||||
**Package the distro**
|
||||
|
||||
`grunt build`
|
||||
|
||||
**Bootstrap your database**
|
||||
|
||||
`./bin/api.sh create-db`
|
||||
|
||||
**Migrate the database**
|
||||
|
||||
`./bin/api.sh migrate-db`
|
||||
|
||||
**Start the API**
|
||||
|
||||
`./bin/api.sh start`
|
||||
|
||||
**Stop the API**
|
||||
|
||||
`./bin/api.sh stop`
|
100
bin/api.sh
Executable file
100
bin/api.sh
Executable file
@ -0,0 +1,100 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script simplifies the migration of the storyboard database for testing
|
||||
# and development purposes.
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
WORKSPACE="$(dirname "$SCRIPT_DIR")"
|
||||
ACTION=$1
|
||||
DB_USER='openstack_citest'
|
||||
DB_PASSWORD='openstack_citest'
|
||||
|
||||
# First we need to ensure that storyboard has been installed and is on our
|
||||
# path.
|
||||
command -v storyboard-api >/dev/null 2>&1 || {
|
||||
echo >&2 "Could not find Storyboard. Exiting.";
|
||||
exit 1;
|
||||
}
|
||||
command -v storyboard-db-manage >/dev/null 2>&1 || {
|
||||
echo >&2 "Could not find Storyboard. Exiting.";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# This method creates the database.
|
||||
function create_db() {
|
||||
# drop and recreate the database
|
||||
echo 'Creating database...'
|
||||
mysql -u $DB_USER -p$DB_PASSWORD -e 'DROP DATABASE IF EXISTS storyboard;'
|
||||
mysql -u $DB_USER -p$DB_PASSWORD -e 'CREATE DATABASE storyboard;'
|
||||
}
|
||||
|
||||
# This method migrates the configured database.
|
||||
function migrate_db() {
|
||||
local config_path=$(detect_storyboard_config)
|
||||
|
||||
echo 'Running migration...'
|
||||
storyboard-db-manage --config-file $config_path upgrade head
|
||||
}
|
||||
|
||||
# Starts storyboard as a background service.
|
||||
function start_service() {
|
||||
echo 'Starting storyboard-api...'
|
||||
local config_path=$(detect_storyboard_config)
|
||||
local config_dir=$( dirname "$config_path" )
|
||||
local log_path="$WORKSPACE/reports/storyboard.log"
|
||||
|
||||
# Delete and clear any previous logs
|
||||
mkdir -p $WORKSPACE/reports
|
||||
rm $log_path
|
||||
storyboard-api --config-dir $config_dir > $log_path 2>&1 &
|
||||
echo "Started, logging to $log_path..."
|
||||
}
|
||||
|
||||
# Stops storyboard.
|
||||
function stop_service() {
|
||||
echo 'Killing storyboard-api...'
|
||||
killall storyboard-api
|
||||
}
|
||||
|
||||
# This method detects the location of the storyboard configuration file.
|
||||
function detect_storyboard_config() {
|
||||
local global_config_path='/etc/storyboard/storyboard.conf'
|
||||
local test_config_path="$WORKSPACE/bin/storyboard_test.conf"
|
||||
local config_path="$WORKSPACE/.tox/node/etc/storyboard/storyboard.conf"
|
||||
|
||||
local source_config_path
|
||||
|
||||
if [ -f $global_config_path ];
|
||||
then
|
||||
# If there's a global config, source our config from there...
|
||||
source_config_path=$global_config_path
|
||||
else
|
||||
source_config_path=$test_config_path
|
||||
fi
|
||||
|
||||
cp $source_config_path $config_path
|
||||
echo $config_path
|
||||
}
|
||||
|
||||
# Switch based on what the user wants to do.
|
||||
case $ACTION in
|
||||
'migrate-db')
|
||||
migrate_db
|
||||
;;
|
||||
'create-db')
|
||||
create_db
|
||||
migrate_db
|
||||
;;
|
||||
'start')
|
||||
start_service
|
||||
;;
|
||||
'stop')
|
||||
stop_service
|
||||
;;
|
||||
*)
|
||||
echo 'Usage: api.sh [create-db|migrate-db|start|stop]'
|
||||
exit 0;
|
||||
;;
|
||||
esac
|
||||
|
||||
echo 'Done!'
|
75
bin/storyboard_test.conf
Executable file
75
bin/storyboard_test.conf
Executable file
@ -0,0 +1,75 @@
|
||||
[DEFAULT]
|
||||
# Default log level is INFO
|
||||
# verbose and debug has the same result.
|
||||
# One of them will set DEBUG log level output
|
||||
# debug = False
|
||||
# verbose = False
|
||||
|
||||
# Where to store lock files
|
||||
lock_path = $state_path/lock
|
||||
|
||||
# log_format = %(asctime)s %(levelname)8s [%(name)s] %(message)s
|
||||
# log_date_format = %Y-%m-%d %H:%M:%S
|
||||
|
||||
# use_syslog -> syslog
|
||||
# log_file and log_dir -> log_dir/log_file
|
||||
# (not log_file) and log_dir -> log_dir/{binary_name}.log
|
||||
# use_stderr -> stderr
|
||||
# (not user_stderr) and (not log_file) -> stdout
|
||||
# publish_errors -> notification system
|
||||
|
||||
# use_syslog = False
|
||||
# syslog_log_facility = LOG_USER
|
||||
|
||||
# use_stderr = True
|
||||
# log_file =
|
||||
# log_dir =
|
||||
|
||||
# publish_errors = False
|
||||
|
||||
# Address to bind the API server
|
||||
# bind_host = 0.0.0.0
|
||||
|
||||
# Port the bind the API server to
|
||||
# bind_port = 9696
|
||||
|
||||
[database]
|
||||
# This line MUST be changed to actually run storyboard
|
||||
# Example:
|
||||
connection=mysql://openstack_citest:openstack_citest@127.0.0.1:3306/storyboard
|
||||
|
||||
# The SQLAlchemy connection string used to connect to the slave database
|
||||
# slave_connection =
|
||||
|
||||
# Database reconnection retry times - in event connectivity is lost
|
||||
# set to -1 implies an infinite retry count
|
||||
# max_retries = 10
|
||||
|
||||
# Database reconnection interval in seconds - if the initial connection to the
|
||||
# database fails
|
||||
# retry_interval = 10
|
||||
|
||||
# Minimum number of SQL connections to keep open in a pool
|
||||
# min_pool_size = 1
|
||||
|
||||
# Maximum number of SQL connections to keep open in a pool
|
||||
# max_pool_size = 10
|
||||
|
||||
# Timeout in seconds before idle sql connections are reaped
|
||||
# idle_timeout = 3600
|
||||
|
||||
# If set, use this value for max_overflow with sqlalchemy
|
||||
# max_overflow = 20
|
||||
|
||||
# Verbosity of SQL debugging information. 0=None, 100=Everything
|
||||
# connection_debug = 0
|
||||
|
||||
# Add python stack traces to SQL as comment strings
|
||||
# connection_trace = False
|
||||
|
||||
# If set, use this value for pool_timeout with sqlalchemy
|
||||
# pool_timeout = 10
|
||||
|
||||
[api]
|
||||
host="127.0.0.1"
|
||||
port=8080
|
@ -52,6 +52,7 @@
|
||||
"protractor": "0.15.0",
|
||||
"grunt-protractor-runner": "0.2.0",
|
||||
"selenium-standalone": "2.39.0-2.7.0",
|
||||
"karma-html-reporter": "~0.1.1"
|
||||
"karma-html-reporter": "~0.1.1",
|
||||
"grunt-connect-proxy": "~0.1.7"
|
||||
}
|
||||
}
|
||||
|
7
tox.ini
7
tox.ini
@ -4,12 +4,14 @@ envlist = node
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
whitelist_externals = /bin/bash
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
LANG=en_US.UTF-8
|
||||
LANGUAGE=en_US:en
|
||||
LC_ALL=C
|
||||
deps = nodeenv
|
||||
http://tarballs.openstack.org/storyboard/storyboard-master.tar.gz
|
||||
|
||||
[testenv:node]
|
||||
commands =
|
||||
@ -17,4 +19,7 @@ commands =
|
||||
npm install -g bower@1.2.8 grunt@0.4.2 grunt-cli@0.1.11
|
||||
npm install
|
||||
bower install
|
||||
grunt {posargs}
|
||||
bash ./bin/api.sh create-db
|
||||
bash ./bin/api.sh start
|
||||
grunt {posargs}
|
||||
bash ./bin/api.sh stop
|
||||
|
Loading…
Reference in New Issue
Block a user