/
git-viewer.labs.theodi.org.feature
169 lines (140 loc) · 6.37 KB
/
git-viewer.labs.theodi.org.feature
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
@git-data-viewer
Feature: Build a fully-operational battlestation^W git-viewer.labs.theodi.org node from scratch
In order to run the git data viewer app
As the ODI
I want to install and configure many things
Background:
* I have a server called "git-data-viewer"
* "git-data-viewer" is running "ubuntu" "precise"
* "git-data-viewer" should be persistent
* the following environment has been uploaded:
| environment | environment_path |
| cucumber.rb | ./environments/ |
* the following roles have been uploaded:
| role | role_path |
| *.rb | ./roles/ |
* "git-data-viewer" is in the "cucumber" environment
* "git-data-viewer" has been provisioned
* all of the cookbooks in "./cookbooks" have been uploaded
* all of the cookbooks in "./site-cookbooks" have been uploaded
* the following databags have been updated:
| databag | databag_path |
| envs | ./data_bags/envs |
| git-data-viewer | ./data_bags/git-data-viewer |
* the "chef-client::cron" recipe has been added to the "git-data-viewer" run list
* the "git-data-viewer" role has been added to the "git-data-viewer" run list
* the chef-client has been run on "git-data-viewer"
* I ssh to "git-data-viewer" with the following credentials:
| username | keyfile |
| $lxc$ | $lxc$ |
Scenario: Can connect to the provisioned server via SSH authentication
When I run "hostname"
Then I should see "git-data-viewer" in the output
Scenario: Core dependencies are installed
* package "build-essential" should be installed
* package "git" should be installed
* package "curl" should be installed
Scenario: User 'git-data-viewer' exists
* I run "su - git-data-viewer -c 'echo ${SHELL}'"
* I should see "/bin/bash" in the output
Scenario: User can sudo with no password
# we cannot test this properly on Vagrant!
# * I run "su - git-data-viewer -c 'sudo bash'"
# * I should not see "password for git-data-viewer" in the output
# So we compromise with this
* file "/etc/sudoers.d/git-data-viewer" should exist
* file "/etc/sudoers.d/git-data-viewer" should contain
"""
git-data-viewer ALL=NOPASSWD:ALL
"""
* file "/etc/sudoers" should contain
"""
#includedir /etc/sudoers.d
"""
* I run "stat -c %a /etc/sudoers.d/git-data-viewer"
* I should see "440" in the output
Scenario: Ruby 2.0.0-p0 is installed
* I run "su - git-data-viewer -c 'ruby -v'"
* I should see "2.0.0p0" in the output
Scenario: Gem dependencies are installed
* package "libxml2-dev" should be installed
* package "libxslt1-dev" should be installed
* package "libcurl4-openssl-dev" should be installed
* package "libmysqlclient-dev" should be installed
When I run "node -h"
Then I should not see "command not found" in the output
Scenario: nginx is installed
* package "nginx" should be installed
@envfile
Scenario: The env file exists
* file "/var/www/git-viewer.labs.theodi.org/shared/config/env" should exist
Scenario: The env file contains the correct stuff
When I run "cat /var/www/git-viewer.labs.theodi.org/shared/config/env"
Then I should see "GITHUB_OAUTH_TOKEN: " in the output
Scenario: Code is deployed
* directory "/var/www/git-viewer.labs.theodi.org" should exist
* directory "/var/www/git-viewer.labs.theodi.org/releases" should exist
* directory "/var/www/git-viewer.labs.theodi.org/shared" should exist
* directory "/var/www/git-viewer.labs.theodi.org/shared/config" should exist
* directory "/var/www/git-viewer.labs.theodi.org/shared/pid" should exist
* directory "/var/www/git-viewer.labs.theodi.org/shared/log" should exist
* directory "/var/www/git-viewer.labs.theodi.org/shared/system" should exist
@configurationstuff
Scenario: configuration stuff is correct
* file "/var/www/git-viewer.labs.theodi.org/current/config/database.yml" should exist
* file "/var/www/git-viewer.labs.theodi.org/current/config/database.yml" should be owned by "git-data-viewer:git-data-viewer"
* symlink "/var/www/git-viewer.labs.theodi.org/current/.env" should exist
When I run "stat -c %N /var/www/git-viewer.labs.theodi.org/current/.env"
Then I should see "../../shared/config/env" in the output
When I run "cat /var/www/git-viewer.labs.theodi.org/current/config/database.yml"
Then I should see "production:" in the output
And I should see "adapter: mysql2" in the output
And I should see "port: 3306" in the output
Scenario: Assets have been compiled
* directory "/var/www/git-viewer.labs.theodi.org/current/public/assets/" should exist
@startup
Scenario: Startup scripts are in play
* file "/etc/init/git-data-viewer.conf" should exist
* file "/etc/init/git-data-viewer-thin.conf" should exist
* file "/etc/init/git-data-viewer-thin-1.conf" should exist
When I run "cat /etc/init/git-data-viewer-thin-1.conf"
Then I should see "exec su - git-data-viewer" in the output
And I should see "export PORT=3000" in the output
# And I should see "RACK_ENV=production" in the output
And I should see "/var/log/git-data-viewer/thin-1.log" in the output
@nginx
Scenario: nginx virtualhosts are correct
* symlink "/etc/nginx/sites-enabled/default" should not exist
* file "/etc/nginx/sites-available/git-viewer.labs.theodi.org" should exist
@nginx @vhost
Scenario: virtualhost should contain correct stuff
* file "/etc/nginx/sites-available/git-viewer.labs.theodi.org" should contain
"""
upstream git-data-viewer {
server 127.0.0.1:3000;
}
server {
listen 80 default;
server_name git-viewer.labs.theodi.org;
access_log /var/log/nginx/git-viewer.labs.theodi.org.log;
error_log /var/log/nginx/git-viewer.labs.theodi.org.err;
location / {
try_files $uri @backend;
}
location ~ ^/(assets)/ {
root /var/www/git-viewer.labs.theodi.org/current/public/;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
location @backend {
proxy_set_header X-Forwarded-Proto 'http';
proxy_set_header Host $server_name;
proxy_pass http://git-data-viewer;
}
}
"""
Scenario: virtualhost should be symlinked
* symlink "/etc/nginx/sites-enabled/git-viewer.labs.theodi.org" should exist
Scenario: nginx should be restarted
# we can't really test this