summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-03-31 10:52:07 -0700
committerelijah <elijah@riseup.net>2015-03-31 10:52:07 -0700
commite4679c66565d0ccae54ffc58a23083841e5585e7 (patch)
tree2cc7fbb5d3e6a48d21a605a8411da38ea8c999e3
parent2365129a1dcbb1231f0ac22d4bf975007a0c460d (diff)
fix travis: use couchdb.admin.yml and pin travis ruby version to one that is installed on travis-ci.org
-rw-r--r--.travis.yml13
-rw-r--r--DEPLOY.md28
-rw-r--r--README.md12
-rw-r--r--lib/tasks/leap_web_core_tasks.rake31
-rw-r--r--test/config/couchdb.admin.yml (renamed from test/config/couchdb.yml.admin)0
-rw-r--r--test/config/couchdb.yml (renamed from test/config/couchdb.yml.user)0
-rw-r--r--test/travis/ruby-version1
-rwxr-xr-xtest/travis/setup_couch.sh (renamed from test/setup_couch.sh)0
8 files changed, 56 insertions, 29 deletions
diff --git a/.travis.yml b/.travis.yml
index 90822f3..189a4c3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,10 +3,13 @@ services:
notifications:
email: false
before_script:
- - "test/setup_couch.sh"
- - "mv test/config/couchdb.yml.admin config/couchdb.yml"
- - "bundle exec rake RAILS_ENV=test couchrest:migrate_with_proxies"
- - "mv test/config/couchdb.yml.user config/couchdb.yml"
+ - "rm .ruby-version"
+ - "mv test/travis/ruby-version .ruby-version"
+ - "test/travis/setup_couch.sh"
+ - "mv test/config/couchdb.admin.yml config/couchdb.admin.yml"
+ - "mv test/config/couchdb.yml config/couchdb.yml"
+ - "bundle exec rake RAILS_ENV=test db:rotate"
+ - "bundle exec rake RAILS_ENV=test db:migrate"
after_script:
- "cat tmp/*.test*.log" # printing logs from the failed integration tests
-bundler_args: --without development debug \ No newline at end of file
+bundler_args: --without development debug
diff --git a/DEPLOY.md b/DEPLOY.md
index 05d97cb..33d5598 100644
--- a/DEPLOY.md
+++ b/DEPLOY.md
@@ -1,6 +1,7 @@
# Deployment #
-These instructions are targeting a Debian GNU/Linux system. You might need to change the commands to match your own needs.
+These instructions are targeting a Debian GNU/Linux system. You might need to
+change the commands to match your own needs.
## Server Preperation ##
@@ -15,7 +16,9 @@ The following packages need to be installed:
### Setup Capistrano ###
-We use puppet to deploy. But we also ship an example deploy.rb in config/deploy.rb.example. Edit it to match your needs if you want to use capistrano.
+We use puppet to deploy. But we also ship an example deploy.rb in
+config/deploy.rb.example. Edit it to match your needs if you want to use
+capistrano.
run `cap deploy:setup` to create the directory structure.
@@ -31,12 +34,15 @@ Please make sure your deploy includes the following files:
## Couch Security ##
-We recommend against using an admin user for running the webapp. To avoid this couch design documents need to be created ahead of time and the auto update mechanism needs to be disabled.
-Take a look at test/setup_couch.sh for an example of securing the couch.
+We recommend against using an admin user for running the webapp. To avoid this
+couch design documents need to be created ahead of time and the auto update
+mechanism needs to be disabled. Take a look at `test/travis/setup_couch.sh`
+for an example of securing the couch.
### DESIGN DOCUMENTS ###
-After securing the couch design documents need to be deployed with admin permissions. There are two ways of doing this:
+After securing the couch design documents need to be deployed with admin
+permissions. There are two ways of doing this:
* rake couchrest:migrate_with_proxies
* dump the documents as files with `rake couchrest:dump` and deploy them
to the couch by hand or with puppet.
@@ -46,10 +52,10 @@ After securing the couch design documents need to be deployed with admin permiss
The before_script block in .travis.yml illustrates how to do this:
```bash
-mv test/config/couchdb.yml.admin config/couchdb.yml # use admin privileges
-bundle exec rake couchrest:migrate_with_proxies # run the migrations
-bundle exec rake couchrest:migrate_with_proxies # looks like this needs to run twice
-mv test/config/couchdb.yml.user config/couchdb.yml # drop admin privileges
+mv test/config/couchdb.yml config/couchdb.yml
+mv test/config/couchdb.admin.yml config/couchdb.admin.yml
+bundle exec rake db:rotate # create dbs
+bundle exec rake couchrest:migrate # run migrations
```
#### Deploy design docs from CouchRest::Dump ####
@@ -61,4 +67,6 @@ First of all we get the design docs as files:
bundle exec rake couchrest:dump
```
-Then we add them to files/design in the site_couchdb module in leap_platform so they get deployed with the couch. You could also upload them using curl or sth. similar.
+Then we add them to files/design in the site_couchdb module in leap_platform
+so they get deployed with the couch. You could also upload them using curl or
+sth. similar.
diff --git a/README.md b/README.md
index e399ee2..f2d69ca 100644
--- a/README.md
+++ b/README.md
@@ -113,7 +113,8 @@ Running
To run leap_web:
cd leap_web
- bin/rake couchrest:migrate
+ bin/rake db:rotate
+ bin/rake db:migrate
bin/rails server
Then open http://localhost:3000 in your web browser.
@@ -124,12 +125,19 @@ powers by creating an account with username 'staff', 'blue', or 'red'
To peruse the database, visit http://localhost:5984/_utils/
+The task `db:rotate` must come before `db:migrate`, in order to assure that
+the special rotating databases get created.
+
+Do not run the normal CouchRest task 'couchrest:migrate'. Instead, use
+'db:rotate' since the latter will correctly use the couchdb.admin.yml file.
+
Testing
--------------------------------
To run all tests
- bin/rake couchrest:migrate # if not already run
+ bin/rake RAILS_ENV=test db:rotate # if not already run
+ bin/rake RAILS_ENV=test db:migrate # if not already run
bin/rake test
To run an individual test:
diff --git a/lib/tasks/leap_web_core_tasks.rake b/lib/tasks/leap_web_core_tasks.rake
index e446f93..6f5ea4e 100644
--- a/lib/tasks/leap_web_core_tasks.rake
+++ b/lib/tasks/leap_web_core_tasks.rake
@@ -22,7 +22,21 @@ namespace :cleanup do
end
end
+def use_admin_conf(couchrest_model_class)
+ couchrest_model_class.configure do |conf|
+ conf.environment = Rails.env
+ conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml')
+ end
+end
+
namespace :db do
+ desc "Migrate all design documents (using couchdb.admin.yml)"
+ task :migrate => :environment do
+ use_admin_conf(CouchRest::Model::Base)
+ CouchRest::Model::Utils::Migrate.load_all_models
+ CouchRest::Model::Utils::Migrate.all_models
+ end
+
desc "Rotate the databases, as needed."
task :rotate => :environment do
#
@@ -31,26 +45,19 @@ namespace :db do
# override the default config twice.
#
- CouchRest::Model::Base.configure do |conf|
- conf.environment = Rails.env
- conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml')
- end
+ use_admin_conf(CouchRest::Model::Base)
Token.rotate_database_now(:window => 1.day)
+ User.create_tmp_database!
+ User.design_doc.sync!(User.tmp_database)
- CouchRest::Session::Document.configure do |conf|
- conf.environment = Rails.env
- conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml')
- end
+ use_admin_conf(CouchRest::Session::Document)
CouchRest::Session::Document.rotate_database_now(:window => 1.day)
end
desc "Delete and recreate temporary databases."
task :deletetmp => :environment do
# db deletion and creation must be performed by admin
- CouchRest::Model::Base.configure do |conf|
- conf.environment = Rails.env
- conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.admin.yml')
- end
+ use_admin_conf(CouchRest::Model::Base)
User.tmp_database.recreate!
User.design_doc.sync!(User.tmp_database)
end
diff --git a/test/config/couchdb.yml.admin b/test/config/couchdb.admin.yml
index 0988bc1..0988bc1 100644
--- a/test/config/couchdb.yml.admin
+++ b/test/config/couchdb.admin.yml
diff --git a/test/config/couchdb.yml.user b/test/config/couchdb.yml
index 9c8b67b..9c8b67b 100644
--- a/test/config/couchdb.yml.user
+++ b/test/config/couchdb.yml
diff --git a/test/travis/ruby-version b/test/travis/ruby-version
new file mode 100644
index 0000000..68b3a4c
--- /dev/null
+++ b/test/travis/ruby-version
@@ -0,0 +1 @@
+1.9.3-p551
diff --git a/test/setup_couch.sh b/test/travis/setup_couch.sh
index 0502c12..0502c12 100755
--- a/test/setup_couch.sh
+++ b/test/travis/setup_couch.sh