This repository has been archived by the owner on Jul 28, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
config_spec.rb
203 lines (164 loc) · 5.83 KB
/
config_spec.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
require 'spec_helper'
describe 'stackstorm::config' do
before do
global_stubs_include_recipe
end
let(:st2_conf) do
%(# System-wide configuration
[api]
# Host and port to bind the API server.
host = 127.0.0.1
port = 9101
logging = /etc/st2/logging.api.conf
mask_secrets = True
# allow_origin is required for handling CORS in st2 web UI.
# allow_origin = http://myhost1.example.com:3000,http://myhost2.example.com:3000
allow_origin = *
[stream]
logging = /etc/st2/logging.stream.conf
[sensorcontainer]
logging = /etc/st2/logging.sensorcontainer.conf
[rulesengine]
logging = /etc/st2/logging.rulesengine.conf
[actionrunner]
logging = /etc/st2/logging.actionrunner.conf
virtualenv_opts = --always-copy
[resultstracker]
logging = /etc/st2/logging.resultstracker.conf
[notifier]
logging = /etc/st2/logging.notifier.conf
[exporter]
logging = /etc/st2/logging.exporter.conf
[garbagecollector]
logging = /etc/st2/logging.garbagecollector.conf
[timersengine]
logging = /etc/st2/logging.timersengine.conf
[workflow_engine]
logging = /etc/st2/logging.workflowengine.conf
[auth]
host = 127.0.0.1
port = 9100
use_ssl = False
debug = False
enable = True
logging = /etc/st2/logging.auth.conf
mode = standalone
# Note: Settings bellow are only used in "standalone" mode
backend = flat_file
backend_kwargs = {"file_path": "/etc/st2/htpasswd"}
# Base URL to the API endpoint excluding the version (e.g. http://myhost.net:9101/)
api_url = http://127.0.0.1:9101
[system]
base_path = /opt/stackstorm
# [webui]
# webui_base_url = https://mywebhost.domain
[log]
excludes = requests,paramiko
redirect_stderr = False
mask_secrets = True
[system_user]
user = stanley
ssh_key_file = /home/stanley/.ssh/stanley_rsa
[messaging]
url = amqp://guest:guest@127.0.0.1:5672/
[ssh_runner]
remote_dir = /tmp
[action_sensor]
triggers_base_url = http://127.0.0.1:9101/v1/triggertypes/
[database]
host = 127.0.0.1
port = 27017
db_name = st2
)
end
platforms = {
'ubuntu' => ['14.04'],
'centos' => ['7.5'],
}
platforms.each do |platform, versions|
versions.each do |version|
context "Using #{platform} #{version} with default node attributes" do
let(:chef_run) { ChefSpec::SoloRunner.new(platform: platform, version: version).converge(described_recipe) }
it 'should create /etc/st2 directory with attributes' do
expect(chef_run).to create_directory('/etc/st2').with(
user: 'root',
group: 'root',
mode: '0755'
)
end
it 'should include recipe stackstorm::user' do
expect_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('stackstorm::user')
chef_run
end
it 'should not create file ":backup StackStorm dist configuration" if st2.conf does not exist' do
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with('/etc/st2/st2.conf').and_return(false)
expect(chef_run).to_not create_file(':backup StackStorm dist configuration').with(
path: '/etc/st2/st2.conf.dist'
)
end
it 'should not create file ":backup StackStorm dist configuration" if st2.conf.dist exists' do
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with('/etc/st2/st2.conf.dist').and_return(true)
expect(chef_run).to_not create_file(':backup StackStorm dist configuration').with(
path: '/etc/st2/st2.conf.dist'
)
end
it 'should create file ":backup StackStorm dist configuration" if conditions are met' do
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with('/etc/st2/st2.conf').and_return(true)
allow(IO).to receive(:read).and_call_original
allow(IO).to receive(:read).with('/etc/st2/st2.conf').and_return(st2_conf)
expect(chef_run).to create_file(':backup StackStorm dist configuration').with(
path: '/etc/st2/st2.conf.dist',
content: st2_conf
)
end
it 'should create template ":create StackStorm configuration"' do
expect(chef_run).to create_template(':create StackStorm configuration').with(
path: '/etc/st2/st2.conf',
owner: 'root',
group: 'root',
mode: 0644,
source: 'st2.conf.erb',
# Config options ordered as they appear in original `st2.conf`:
# https://github.com/StackStorm/st2/blob/master/conf/st2.package.conf
variables: {
'api_url' => 'http://127.0.0.1:9101',
'api_host' => '127.0.0.1',
'api_port' => 9101,
'api_mask_secrets' => true,
'api_allow_origin' => '*',
'auth_host' => '127.0.0.1',
'auth_port' => 9100,
'auth_use_ssl' => false,
'auth_debug' => false,
'auth_enable' => true,
'auth_mode' => 'standalone',
'auth_backend' => 'flat_file',
'auth_backend_kwargs' => { 'file_path' => '/etc/st2/htpasswd' },
'syslog_enabled' => false,
'syslog_host' => '127.0.0.1',
'syslog_port' => 514,
'syslog_facility' => 'local7',
'syslog_protocol' => 'udp',
'log_mask_secrets' => true,
'system_user' => 'stanley',
'ssh_key_file' => '/home/stanley/.ssh/stanley_rsa',
'rmq_host' => '127.0.0.1',
'rmq_vhost' => nil,
'rmq_username' => 'guest',
'rmq_password' => 'guest',
'rmq_port' => 5672,
'db_host' => '127.0.0.1',
'db_port' => 27017,
'db_name' => 'st2',
'db_username' => nil,
'db_password' => nil,
}
)
end
end
end
end
end