-
Notifications
You must be signed in to change notification settings - Fork 1
/
balanced.rb
120 lines (101 loc) · 4 KB
/
balanced.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# Author:: Noah Kantrowitz <noah@coderanger.net>
#
# Copyright 2013-2014, Balanced, Inc.
#
# 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.
#
balanced_ci_pipeline 'balanced' do
repository 'git@github.com:balanced/balanced.git'
# this should really be called the "acceptance cookbook"
cookbook_repository 'git@github.com:balanced-cookbooks/acceptance.git'
pipeline %w{test quality build acceptance}
project_url 'https://github.com/balanced/balanced'
python_package 'balanced_service'
test_db_user 'balanced'
test_db_name 'balanced'
test_db_host 'localhost'
branch 'omnibussed'
test_command "pip install --no-use-wheel -e .[tests] && CONF=#{node['ci']['path']}/balanced.conf nosetests --processes=#{node['ci']['balanced']['parallelisms']} -sv --with-xunitmp --with-cov --cov=balanced_service --cov-report term-missing"
quality_command 'coverage.py coverage.xml balanced_service.models:91 balanced_service.resources:92'
job 'test' do |new_resource|
builder_recipe do
package 'libxml2-dev'
package 'libxslt1-dev'
pg_user new_resource.test_db_user do
privileges superuser: true, createdb: true, login: true
password new_resource.test_db_user
end
pg_database new_resource.test_db_name do
owner new_resource.test_db_user
end
pg_database_extensions new_resource.test_db_name do
extensions ['hstore']
end
directory node['ci']['path'] do
owner node['jenkins']['node']['user']
group node['jenkins']['node']['group']
end
directory "#{node['ci']['path']}/.pip" do
owner node['jenkins']['node']['user']
group node['jenkins']['node']['group']
mode '700'
end
file "#{node['ci']['path']}/.pip/pip.conf" do
owner node['jenkins']['node']['user']
group node['jenkins']['node']['group']
mode '600'
content "[global]\nindex-url = https://omnibus:#{citadel['omnibus/devpi_password'].strip}@pypi.vandelay.io/balanced/prod/+simple/\n"
end
file "#{node['ci']['path']}/.pydistutils.cfg" do
owner node['jenkins']['node']['user']
group node['jenkins']['node']['group']
mode '600'
content "[easy_install]\nindex_url = https://omnibus:#{citadel['omnibus/devpi_password'].strip}@pypi.vandelay.io/balanced/prod/+simple/\n"
end
# HACK: override the meta db for the balanced service. we need to figure
# out a better strategy than this.
file "#{node['ci']['path']}/balanced.conf" do
owner node['jenkins']['node']['user']
group node['jenkins']['node']['group']
mode '644'
content <<-EOH
from balanced_service.settings import DATABASES
DATABASES['meta_masters'] = [
"postgresql://balanced:#{citadel['balanced/meta_db_password']}@#{citadel['balanced/meta_db_host']}:5432/balanced_meta_test"
]
EOH
end
file "/etc/profile.d/balanced-test.sh" do
owner 'root'
group 'root'
mode '644'
content <<-EOH
export BALANCED_CONF=#{node['ci']['path']}/balanced.conf
EOH
end
include_recipe 'git'
include_recipe 'python'
include_recipe 'rsyslog'
include_recipe 'balanced-postgresql'
include_recipe 'balanced-postgresql::server'
include_recipe 'balanced-postgresql::client'
include_recipe 'balanced-rabbitmq'
include_recipe 'balanced-elasticsearch'
include_recipe 'balanced-mongodb'
include_recipe 'redisio::install'
include_recipe 'redisio::enable'
end
end
end
include_recipe 'balanced-ci'