/
package.bom
304 lines (297 loc) · 10.3 KB
/
package.bom
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
brooklyn.catalog:
version: "1.1.0-SNAPSHOT" # BROOKLYN_VERSION
items:
- id: systemd-brooklyn
item:
type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
brooklyn.config:
launch.command: |
sudo systemctl start brooklyn
checkRunning.command: |
sudo systemctl status brooklyn
stop.command: |
sudo systemctl stop brooklyn
- id: upstart-brooklyn
item:
type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
brooklyn.config:
launch.command: |
sudo status brooklyn | grep running || sudo start brooklyn
checkRunning.command: |
sudo status brooklyn | grep running
stop.command: |
sudo stop brooklyn
- id: apt-systemd-brooklyn
item:
type: systemd-brooklyn
id: brooklyn
brooklyn.config:
files.preinstall:
$brooklyn:config("package.file") : brooklyn-package.deb
install.command: |
sudo apt-get update
sudo apt-get install -y default-jre-headless
sudo dpkg -i brooklyn-package.deb
sudo systemctl start brooklyn
- id: apt-upstart-brooklyn
item:
type: upstart-brooklyn
id: brooklyn
brooklyn.config:
files.preinstall:
$brooklyn:config("package.file"): brooklyn-package.deb
install.command: |
sudo apt-get update
sudo apt-get install -y default-jre-headless
sudo dpkg -i brooklyn-package.deb
sudo initctl start brooklyn
- id: yum-systemd-brooklyn
item:
type: systemd-brooklyn
id: brooklyn
brooklyn.config:
files.preinstall:
$brooklyn:config("package.file"): brooklyn-package.rpm
install.command: |
if sudo iptables -L | grep REJECT; then
# Only for CentOS 6
sudo iptables -I INPUT -p tcp -m tcp --dport 8081 -j ACCEPT
sudo service iptables save
fi
sudo yum -y install brooklyn-package.rpm
sudo systemctl start brooklyn
- id: yum-upstart-brooklyn
item:
type: upstart-brooklyn
id: brooklyn
brooklyn.config:
files.preinstall:
$brooklyn:config("package.file") : brooklyn-package.rpm
install.command: |
if sudo iptables -L | grep REJECT; then
# Only for CentOS 6
sudo iptables -I INPUT -p tcp -m tcp --dport 8081 -j ACCEPT
sudo service iptables save
fi
sudo yum -y install brooklyn-package.rpm
sudo initctl start brooklyn
### Tests ###
- id: test-is-up
item:
type: org.apache.brooklyn.test.framework.TestSensor
name: Check server is up
sensor: service.isUp
assert:
- equals: true
- id: test-is-not-up
item:
type: org.apache.brooklyn.test.framework.TestSensor
name: Check server is up
sensor: service.isUp
assert:
- equals: false
- id: test-process-running
item:
type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
name: Check process has started
# The brackets prevent grep from matching its own process
command: ps ax | grep "[/]opt/brooklyn/bin/karaf"
assertStatus:
equals: 0
assertOut:
isEmpty: false
assertErr:
isEmpty: true
- id: test-process-not-running
item:
type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
name: Check process is not started
# The brackets prevent grep from matching its own process
command: ps ax | grep "[/]opt/brooklyn/bin/karaf"
assertStatus:
equals: 1
assertOut:
isEmpty: true
assertErr:
isEmpty: true
- id: test-process-user
item:
type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
name: Check user the process is running under
# The brackets prevent grep from matching its own process
command: ps -fu brooklyn | grep "[/]opt/brooklyn/bin/karaf"
assertStatus:
equals: 0
assertOut:
isEmpty: false
assertErr:
isEmpty: true
- id: test-port-reachable
item:
type: org.apache.brooklyn.test.framework.TestHttpCall
name: Check HTTP Response Status Code
url:
$brooklyn:formatString:
- "http://%s:8081/"
- $brooklyn:entity("brooklyn").attributeWhenReady("host.address")
applyAssertionTo: status
assert:
- isEqualTo: 401
- id: test-path-permissions
item:
type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
name: Check paths permissions
command: |
BROOKLYN_DIRECTORIES="/opt/brooklyn/ /etc/brooklyn/ /var/lib/brooklyn/ /var/log/brooklyn/"
[ "$(sudo stat -c "%A" /opt/brooklyn)" = "lrwxrwxrwx" ]
[ "$(sudo stat -c "%A %U %G" /etc/init)" = "drwxr-xr-x root root" ]
[ "$(sudo stat -c "%A %U %G" /lib/systemd/system/)" = "drwxr-xr-x root root" ]
[ "$(sudo stat -c "%A %U %G" /etc/init/brooklyn.conf)" = "-rw-rw-r-- root root" ]
[ "$(sudo stat -c "%A %U %G" /lib/systemd/system/brooklyn.service)" = "-rw-rw-r-- root root" ]
if hash systemctl ; then
[ "$(sudo stat -c "%A %U %G" /etc/systemd/system/multi-user.target.wants/brooklyn.service)" = "-rw-rw-r-- root root" ]
fi
! sudo ls -d /opt/brooklyn-* | xargs stat -c "%F %a %U %G" | grep -v -E "^directory\s[7][4,5][0,5]\sbrooklyn\sbrooklyn$"
! sudo find ${BROOKLYN_DIRECTORIES} -type f | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,4,6][0]\sbrooklyn\s(brooklyn|wheel)"
! sudo find ${BROOKLYN_DIRECTORIES} -type d | xargs sudo stat -c "%a %U %G" | grep -v -E "^[6,7][0,1,4,5][0,1,5]\sbrooklyn\s(brooklyn|wheel)"
assertStatus:
equals: 0
- id: test-log-files-exist
item:
type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
name: Check log files created at expected location
command: sudo ls /opt/brooklyn/data/log/brooklyn.{debug,info}.log | wc -l
assertOut:
equals: "2"
- id: test-healthy
item:
type: org.apache.brooklyn.test.framework.TestCase
name: Check entity is healthy
brooklyn.children:
- type: test-is-up
name: 001. Test isUp
- type: test-process-running
name: 002. Test process is running
- type: test-port-reachable
name: 003. Test port is reachable
- id: test-start
item:
type: org.apache.brooklyn.test.framework.TestEffector
name: Invoke start Effector
effector: start
- id: test-stop
item:
type: org.apache.brooklyn.test.framework.TestEffector
name: Invoke stop Effector
effector: stop
params:
stopMachineMode: NEVER
- id: test-restart
item:
type: org.apache.brooklyn.test.framework.TestEffector
name: Invoke restart Effector
effector: restart
params:
restartMachine: false
- id: test-restart-machine
item:
type: org.apache.brooklyn.test.framework.SimpleShellCommandTest
name: Restart the machine
command: sudo shutdown -r now
assertStatus:
# Replacement for anything accepted
# Could be 0 or -1, depending on whether the socket closes before restart takes place
notNull: true
- id: packaging-asserts
item:
type: org.apache.brooklyn.test.framework.TestCase
brooklyn.config:
targetId: brooklyn
timeout: 1m
brooklyn.children:
- type: test-is-up
name: 01. Block until started
brooklyn.config:
timeout: 10m
- type: test-healthy
name: 02. Check healthy
- type: test-process-user
name: 03. Test process user
- type: test-path-permissions
name: 04. Test paths permissions
- type: test-log-files-exist
name: 05. Check log files created
- type: test-stop
name: 06. Test stop effector
- type: test-is-not-up
name: 07. Check not running
- type: test-process-not-running
name: 08. Check process not running
- type: test-start
name: 09. Test start effector
- type: test-healthy
name: 10. Check healthy
- type: test-restart
name: 11. Test restart effector
- type: test-healthy
name: 12. Check healthy
- type: test-restart-machine
name: 13. Restart machine
- type: test-is-not-up
name: 14. Check not running while restarting
- type: test-is-up
name: 15. Wait for machine to fully restart
brooklyn.config:
timeout: 10m
- type: test-healthy
name: 16. Check healthy
### Combined tests with target entity - system specific ###
- id: test-yum-upstart-brooklyn
item:
type: org.apache.brooklyn.entity.stock.BasicApplication
brooklyn.children:
- type: yum-upstart-brooklyn
- type: packaging-asserts
- id: test-yum-systemd-brooklyn
item:
type: org.apache.brooklyn.entity.stock.BasicApplication
brooklyn.children:
- type: yum-systemd-brooklyn
- type: packaging-asserts
- id: test-apt-upstart-brooklyn
item:
type: org.apache.brooklyn.entity.stock.BasicApplication
brooklyn.children:
- type: apt-upstart-brooklyn
- type: packaging-asserts
- id: test-apt-systemd-brooklyn
item:
type: org.apache.brooklyn.entity.stock.BasicApplication
brooklyn.children:
- type: apt-systemd-brooklyn
- type: packaging-asserts
### How to use in a blueprint:
### location: xxx
### services:
### - type: test-apt-systemd-brooklyn
### brooklyn.config:
### files.preinstall:
### <path to package>: brooklyn-package.{deb, rpm}