openshift-origin-controller 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openshift-origin-controller might be problematic. Click here for more details.
- data/COPYRIGHT +1 -0
- data/Gemfile +4 -0
- data/LICENSE +12 -0
- data/README.md +3 -0
- data/Rakefile +9 -0
- data/app/controllers/app_events_controller.rb +115 -0
- data/app/controllers/application_templates_controller.rb +19 -0
- data/app/controllers/applications_controller.rb +214 -0
- data/app/controllers/base_controller.rb +367 -0
- data/app/controllers/cartridges_controller.rb +48 -0
- data/app/controllers/descriptors_controller.rb +23 -0
- data/app/controllers/dns_resolvable_controller.rb +35 -0
- data/app/controllers/domains_controller.rb +156 -0
- data/app/controllers/emb_cart_controller.rb +276 -0
- data/app/controllers/emb_cart_events_controller.rb +52 -0
- data/app/controllers/environment_controller.rb +11 -0
- data/app/controllers/estimates_controller.rb +71 -0
- data/app/controllers/gear_groups_controller.rb +53 -0
- data/app/controllers/gears_controller.rb +70 -0
- data/app/controllers/keys_controller.rb +96 -0
- data/app/controllers/legacy_broker_controller.rb +510 -0
- data/app/controllers/quickstarts_controller.rb +29 -0
- data/app/controllers/user_controller.rb +38 -0
- data/app/helpers/cartridge_helper.rb +25 -0
- data/app/helpers/legacy_broker_helper.rb +21 -0
- data/app/helpers/user_action_logger.rb +38 -0
- data/app/models/application.rb +1718 -0
- data/app/models/application_template.rb +27 -0
- data/app/models/cartridge_cache.rb +51 -0
- data/app/models/cloud_user.rb +334 -0
- data/app/models/component_instance.rb +228 -0
- data/app/models/connection_endpoint.rb +10 -0
- data/app/models/district.rb +210 -0
- data/app/models/domain.rb +234 -0
- data/app/models/gear.rb +376 -0
- data/app/models/group_instance.rb +306 -0
- data/app/models/key.rb +20 -0
- data/app/models/legacy_reply.rb +15 -0
- data/app/models/legacy_request.rb +126 -0
- data/app/models/link.rb +11 -0
- data/app/models/message.rb +10 -0
- data/app/models/name_server_cache.rb +46 -0
- data/app/models/optional_param.rb +12 -0
- data/app/models/param.rb +13 -0
- data/app/models/remote_job.rb +57 -0
- data/app/models/rest_application.rb +126 -0
- data/app/models/rest_application10.rb +106 -0
- data/app/models/rest_application12.rb +124 -0
- data/app/models/rest_application_estimate.rb +12 -0
- data/app/models/rest_application_template.rb +20 -0
- data/app/models/rest_cartridge10.rb +41 -0
- data/app/models/rest_cartridge11.rb +151 -0
- data/app/models/rest_domain.rb +43 -0
- data/app/models/rest_domain10.rb +42 -0
- data/app/models/rest_estimates.rb +16 -0
- data/app/models/rest_gear.rb +14 -0
- data/app/models/rest_gear_group.rb +26 -0
- data/app/models/rest_key.rb +24 -0
- data/app/models/rest_reply.rb +31 -0
- data/app/models/rest_user.rb +43 -0
- data/app/models/result_io.rb +67 -0
- data/app/models/usage_record.rb +37 -0
- data/app/models/validators/app_validator.rb +30 -0
- data/app/models/validators/key_validator.rb +30 -0
- data/app/models/validators/namespace_validator.rb +18 -0
- data/config/routes.rb +36 -0
- data/lib/controller_engine.rb +7 -0
- data/lib/openshift-origin-controller.rb +14 -0
- data/lib/openshift/application_container_proxy.rb +241 -0
- data/lib/openshift/auth_service.rb +101 -0
- data/lib/openshift/data_store.rb +33 -0
- data/lib/openshift/dns_service.rb +41 -0
- data/lib/openshift/mongo_data_store.rb +671 -0
- data/openshift-origin-controller.gemspec +42 -0
- data/rubygem-openshift-origin-controller.spec +274 -0
- data/test/cucumber/application-estimate.feature +25 -0
- data/test/cucumber/cartridge-10gen-mms-agent.feature +28 -0
- data/test/cucumber/cartridge-cron.feature +32 -0
- data/test/cucumber/cartridge-haproxy.feature +31 -0
- data/test/cucumber/cartridge-jenkins-build.feature +12 -0
- data/test/cucumber/cartridge-jenkins-client.feature +10 -0
- data/test/cucumber/cartridge-lifecycle-diy.feature +21 -0
- data/test/cucumber/cartridge-lifecycle-jbossas.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jbosseap.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jbossews10.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jenkins.feature +41 -0
- data/test/cucumber/cartridge-lifecycle-nodejs.feature +59 -0
- data/test/cucumber/cartridge-lifecycle-perl.feature +40 -0
- data/test/cucumber/cartridge-lifecycle-php.feature +106 -0
- data/test/cucumber/cartridge-lifecycle-python.feature +40 -0
- data/test/cucumber/cartridge-lifecycle-ruby18.feature +49 -0
- data/test/cucumber/cartridge-lifecycle-ruby19.feature +41 -0
- data/test/cucumber/cartridge-mongodb.feature +31 -0
- data/test/cucumber/cartridge-mysql.feature +30 -0
- data/test/cucumber/cartridge-php.feature +14 -0
- data/test/cucumber/cartridge-phpmyadmin.feature +32 -0
- data/test/cucumber/cartridge-postgresql.feature +32 -0
- data/test/cucumber/cartridge-runtime-extended-db.feature +64 -0
- data/test/cucumber/cartridge-runtime-extended-jboss.feature +24 -0
- data/test/cucumber/cartridge-runtime-extended-nodejs.feature +21 -0
- data/test/cucumber/cartridge-runtime-extended-perl.feature +18 -0
- data/test/cucumber/cartridge-runtime-extended-php.feature +19 -0
- data/test/cucumber/cartridge-runtime-extended-python.feature +18 -0
- data/test/cucumber/cartridge-runtime-extended-ruby.feature +22 -0
- data/test/cucumber/cartridge-runtime-standard-diy.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-jbossas.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jbosseap.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jbossews10.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jenkins.feature +8 -0
- data/test/cucumber/cartridge-runtime-standard-nodejs.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-perl.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-php.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-python.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-ruby.feature +19 -0
- data/test/cucumber/cartridge-switchyard.feature +36 -0
- data/test/cucumber/descriptor.feature +40 -0
- data/test/cucumber/embedded.feature +44 -0
- data/test/cucumber/idler.feature +75 -0
- data/test/cucumber/misc/descriptor/manifest.yml +22 -0
- data/test/cucumber/misc/php/db_test.php +21 -0
- data/test/cucumber/openshift-node.feature +21 -0
- data/test/cucumber/rest-application-templates.feature +31 -0
- data/test/cucumber/rest-applications.feature +431 -0
- data/test/cucumber/rest-cartridge-types.feature +16 -0
- data/test/cucumber/rest-domains.feature +276 -0
- data/test/cucumber/rest-gears.feature +38 -0
- data/test/cucumber/rest-keys.feature +247 -0
- data/test/cucumber/rest-quickstarts.feature +27 -0
- data/test/cucumber/rest-workflow.feature +64 -0
- data/test/cucumber/step_definitions/api_steps.rb +369 -0
- data/test/cucumber/step_definitions/application-estimate-steps.rb +51 -0
- data/test/cucumber/step_definitions/application_steps.rb +215 -0
- data/test/cucumber/step_definitions/cartridge-10gen-mms-agent_steps.rb +11 -0
- data/test/cucumber/step_definitions/cartridge-cron_steps.rb +51 -0
- data/test/cucumber/step_definitions/cartridge-haproxy_steps.rb +30 -0
- data/test/cucumber/step_definitions/cartridge-jenkins_steps.rb +93 -0
- data/test/cucumber/step_definitions/cartridge-lifecycle-nodejs_steps.rb +30 -0
- data/test/cucumber/step_definitions/cartridge-mongodb_steps.rb +60 -0
- data/test/cucumber/step_definitions/cartridge-mysql_steps.rb +56 -0
- data/test/cucumber/step_definitions/cartridge-php_steps.rb +72 -0
- data/test/cucumber/step_definitions/cartridge-postgresql_steps.rb +59 -0
- data/test/cucumber/step_definitions/cartridge-switchyard_steps.rb +29 -0
- data/test/cucumber/step_definitions/client_steps.rb +12 -0
- data/test/cucumber/step_definitions/descriptor_step.rb +32 -0
- data/test/cucumber/step_definitions/idler_steps.rb +37 -0
- data/test/cucumber/step_definitions/node_steps.rb +203 -0
- data/test/cucumber/step_definitions/runtime_steps.rb +547 -0
- data/test/cucumber/step_definitions/runtime_url_steps.rb +46 -0
- data/test/cucumber/step_definitions/trap-user-extended_steps.rb +14 -0
- data/test/cucumber/step_definitions/trap-user_steps.rb +58 -0
- data/test/cucumber/support/00_setup_helper.rb +106 -0
- data/test/cucumber/support/app_helper.rb +243 -0
- data/test/cucumber/support/assertions.rb +52 -0
- data/test/cucumber/support/command_helper.rb +453 -0
- data/test/cucumber/support/dns_helper.rb +54 -0
- data/test/cucumber/support/env.rb +5 -0
- data/test/cucumber/support/process_helper.rb +44 -0
- data/test/cucumber/support/runtime_support.rb +440 -0
- data/test/cucumber/support/unused.rb +27 -0
- data/test/cucumber/support/user_helper.rb +37 -0
- data/test/cucumber/trap-user-extended.feature +53 -0
- data/test/cucumber/trap-user.feature +34 -0
- data/test/ddns/1.168.192-rev.db.init +13 -0
- data/test/ddns/HOWTO.txt +207 -0
- data/test/ddns/Kexample.com.+157+06142.key +1 -0
- data/test/ddns/Kexample.com.+157+06142.private +7 -0
- data/test/ddns/authconfig.rb +14 -0
- data/test/ddns/example.com.db.init +23 -0
- data/test/ddns/example.com.key +4 -0
- data/test/ddns/named.ca +52 -0
- data/test/ddns/named.conf +48 -0
- data/test/ddns/named.empty +10 -0
- data/test/ddns/named.localhost +10 -0
- data/test/ddns/named.loopback +11 -0
- data/test/ddns/named.rfc1912.zones +42 -0
- data/test/ddns/named.root.key +5 -0
- data/test/ddns/named_service.rb +127 -0
- data/test/unit/bind_dns_service_test.rb +167 -0
- data/test/unit/broker_auth_test.rb +28 -0
- metadata +545 -0
@@ -0,0 +1,547 @@
|
|
1
|
+
# Support steps for runtime-centric tests.
|
2
|
+
#
|
3
|
+
# IMPORTANT: The steps defined here are for basic sanity checks of a
|
4
|
+
# SINGLE application with a SINGLE gear and cartridge, and all work
|
5
|
+
# in the context of these assumptions. If your test needs more complex
|
6
|
+
# setups, write some more steps which are more flexible.
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
# These are provided to reduce duplication of code in feature files.
|
11
|
+
# Scenario Outlines are not used as they interfer with the devenv retry logic (whole feature is retried no example line)
|
12
|
+
Given /^a new ([^ ]+) application, verify it using ([^ ]+)$/ do |cart_name, proc_name|
|
13
|
+
steps %Q{
|
14
|
+
Given a new #{cart_name} type application
|
15
|
+
Then the application http proxy file will exist
|
16
|
+
And a #{proc_name} process will be running
|
17
|
+
And the application git repo will exist
|
18
|
+
And the application source tree will exist
|
19
|
+
And the application log files will exist
|
20
|
+
When I stop the application
|
21
|
+
Then a #{proc_name} process will not be running
|
22
|
+
When I start the application
|
23
|
+
Then a #{proc_name} process will be running
|
24
|
+
When I status the application
|
25
|
+
Then a #{proc_name} process will be running
|
26
|
+
When I restart the application
|
27
|
+
Then a #{proc_name} process will be running
|
28
|
+
When I destroy the application
|
29
|
+
Then the application http proxy file will not exist
|
30
|
+
And a #{proc_name} process will not be running
|
31
|
+
And the application git repo will not exist
|
32
|
+
And the application source tree will not exist
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
Given /^a new ([^ ]+) application, verify create and delete using ([^ ]+)$/ do |cart_name, proc_name|
|
37
|
+
steps %Q{
|
38
|
+
Given a new #{cart_name} type application
|
39
|
+
Then the application http proxy file will exist
|
40
|
+
And a #{proc_name} process will be running
|
41
|
+
And the application git repo will exist
|
42
|
+
And the application source tree will exist
|
43
|
+
And the application log files will exist
|
44
|
+
When I destroy the application
|
45
|
+
Then the application http proxy file will not exist
|
46
|
+
And a #{proc_name} process will not be running
|
47
|
+
And the application git repo will not exist
|
48
|
+
And the application source tree will not exist
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
Given /^a new ([^ ]+) application, verify start, stop, restart using ([^ ]+)$/ do |cart_name, proc_name|
|
53
|
+
steps %Q{
|
54
|
+
Given a new #{cart_name} type application
|
55
|
+
Then a #{proc_name} process will be running
|
56
|
+
When I stop the application
|
57
|
+
Then a #{proc_name} process will not be running
|
58
|
+
When I start the application
|
59
|
+
Then a #{proc_name} process will be running
|
60
|
+
When I status the application
|
61
|
+
Then a #{proc_name} process will be running
|
62
|
+
When I restart the application
|
63
|
+
Then a #{proc_name} process will be running
|
64
|
+
When I destroy the application
|
65
|
+
Then the application http proxy file will not exist
|
66
|
+
And a #{proc_name} process will not be running
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
# Creates a new account, application, gear, and cartridge in one shot.
|
71
|
+
# The cartridge is then configured. After running this step, subsequent
|
72
|
+
# steps will have access to three pieces of state:
|
73
|
+
#
|
74
|
+
# @account: a TestAccount instance with randomly generated properties
|
75
|
+
# @app: a TestApplication instance associated with @account
|
76
|
+
# @gear: a TestGear instance associated with @app
|
77
|
+
# @cart: a TestCartridge instance associated with @gear
|
78
|
+
#
|
79
|
+
# The type of cartridge created will be of type cart_name from the step
|
80
|
+
# matcher.
|
81
|
+
Given /^a(n additional)? new ([^ ]+) type application$/ do | additional, cart_name |
|
82
|
+
record_measure("Runtime Benchmark: Creating cartridge #{cart_name}") do
|
83
|
+
if additional
|
84
|
+
assert_not_nil @account, 'You must create a new application before an additional application can be created'
|
85
|
+
else
|
86
|
+
@account = OpenShift::TestAccount.new
|
87
|
+
@app = @account.create_app
|
88
|
+
end
|
89
|
+
|
90
|
+
@gear = @app.create_gear
|
91
|
+
|
92
|
+
@cart = @gear.add_cartridge(cart_name)
|
93
|
+
@cart.configure
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Invokes destroy on the current application.
|
98
|
+
When /^I destroy the application$/ do
|
99
|
+
record_measure("Runtime Benchmark: Destroying cartridge #{@cart.name}") do
|
100
|
+
@app.destroy
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Embeds a new cartridge to the current application's gear
|
105
|
+
# Calls configure on the embedded cartridge.
|
106
|
+
When /^I (fail to )?embed a ([^ ]+) cartridge into the application$/ do | negate, cart_name |
|
107
|
+
record_measure("Runtime Benchmark: Configure #{cart_name} cartridge in cartridge #{@cart.name}") do
|
108
|
+
cart = @gear.add_cartridge(cart_name, OpenShift::TestCartridge::Embedded)
|
109
|
+
|
110
|
+
if negate
|
111
|
+
assert_raise(RuntimeError) do
|
112
|
+
exit_code = cart.configure
|
113
|
+
end
|
114
|
+
else
|
115
|
+
exit_code = cart.configure
|
116
|
+
assert_equal 0, exit_code
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# Un-embeds a cartridge from the current application's gear by
|
123
|
+
# invoking deconfigure on the named cartridge.
|
124
|
+
When /^I remove the ([^ ]+) cartridge from the application$/ do | cart_name |
|
125
|
+
record_measure("Runtime Benchmark: Deconfigure #{cart_name} cartridge in cartridge #{@cart.name}") do
|
126
|
+
raise "No embedded cart named #{cart_name} associated with gear #{gear.uuid}" unless @gear.carts.has_key?(cart_name)
|
127
|
+
|
128
|
+
embedded_cart = @gear.carts[cart_name]
|
129
|
+
|
130
|
+
exit_code = embedded_cart.deconfigure
|
131
|
+
assert_equal 0, exit_code
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
# Verifies the existence of httpd proxy files associated with
|
137
|
+
# the current application.
|
138
|
+
Then /^the application http proxy file will( not)? exist$/ do | negate |
|
139
|
+
conf_file_name = "#{@gear.uuid}_#{@account.domain}_#{@app.name}.conf"
|
140
|
+
conf_file_path = "#{$libra_httpd_conf_d}/#{conf_file_name}"
|
141
|
+
|
142
|
+
$logger.info("Checking for #{negate} proxy file at #{conf_file_path}")
|
143
|
+
if negate
|
144
|
+
assert_file_not_exists conf_file_path
|
145
|
+
else
|
146
|
+
assert_file_exists conf_file_path
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
# Verifies the existence of an httpd proxy file for the given embedded
|
152
|
+
# cartridge associated with the current application.
|
153
|
+
Then /^the embedded ([^ ]+) cartridge http proxy file will( not)? exist$/ do | cart_name, negate |
|
154
|
+
conf_file_name = "#{@gear.uuid}_#{@account.domain}_#{@app.name}/#{cart_name}.conf"
|
155
|
+
conf_file_path = "#{$libra_httpd_conf_d}/#{conf_file_name}"
|
156
|
+
|
157
|
+
$logger.info("Checking for #{negate} embedded cartridge proxy file at #{conf_file_path}")
|
158
|
+
if negate
|
159
|
+
assert_file_not_exists conf_file_path
|
160
|
+
else
|
161
|
+
assert_file_exists conf_file_path
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
# Verifies the existence of a git repo associated with the current
|
167
|
+
# application.
|
168
|
+
Then /^the application git repo will( not)? exist$/ do | negate |
|
169
|
+
git_repo = "#{$home_root}/#{@gear.uuid}/git/#{@app.name}.git"
|
170
|
+
|
171
|
+
# TODO - need to check permissions and SELinux labels
|
172
|
+
|
173
|
+
$logger.info("Checking for #{negate} git repo at #{git_repo}")
|
174
|
+
if negate
|
175
|
+
assert_directory_not_exists git_repo
|
176
|
+
else
|
177
|
+
assert_directory_exists git_repo
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
# Verifies the existence of an exported source tree associated with
|
183
|
+
# the current application.
|
184
|
+
Then /^the application source tree will( not)? exist$/ do | negate |
|
185
|
+
app_root = "#{$home_root}/#{@gear.uuid}/#{@cart.name}"
|
186
|
+
|
187
|
+
# TODO - need to check permissions and SELinux labels
|
188
|
+
|
189
|
+
$logger.info("Checking for app root at #{app_root}")
|
190
|
+
if negate
|
191
|
+
assert_directory_not_exists app_root
|
192
|
+
else
|
193
|
+
assert_directory_exists app_root
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
# Verifies the existence of application log files associated with the
|
199
|
+
# current application.
|
200
|
+
Then /^the application log files will( not)? exist$/ do | negate |
|
201
|
+
log_dir_path = "#{$home_root}/#{@gear.uuid}/#{@cart.name}/logs"
|
202
|
+
|
203
|
+
$logger.info("Checking for log dir at #{log_dir_path}")
|
204
|
+
|
205
|
+
begin
|
206
|
+
log_dir = Dir.new log_dir_path
|
207
|
+
status = (log_dir.count > 2)
|
208
|
+
rescue
|
209
|
+
status = false
|
210
|
+
end
|
211
|
+
|
212
|
+
if not negate
|
213
|
+
status.should be_true
|
214
|
+
else
|
215
|
+
status.should be_false
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
# Ensures that the root directory exists for the given embedded cartridge.
|
221
|
+
Then /^the embedded ([^ ]+) cartridge directory will( not)? exist$/ do | cart_name, negate |
|
222
|
+
user_root = "#{$home_root}/#{@gear.uuid}/#{cart_name}"
|
223
|
+
|
224
|
+
$logger.info("Checking for #{negate} cartridge root dir at #{user_root}")
|
225
|
+
if negate
|
226
|
+
assert_directory_not_exists user_root
|
227
|
+
else
|
228
|
+
assert_directory_exists user_root
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
# Ensures that more than zero log files exist in the given embedded cartridge
|
234
|
+
# log directory.
|
235
|
+
Then /^the embedded ([^ ]+) cartridge log files will( not)? exist$/ do | cart_name, negate |
|
236
|
+
log_dir_path = "#{$home_root}/#{@gear.uuid}/#{cart_name}/logs"
|
237
|
+
|
238
|
+
$logger.info("Checking for #{negate} cartridge log dir at #{log_dir_path}")
|
239
|
+
if negate
|
240
|
+
assert_directory_not_exists log_dir_path
|
241
|
+
else
|
242
|
+
assert_directory_exists log_dir_path
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
|
247
|
+
# Simple verification of arbitrary cartridge directory existence.
|
248
|
+
Then /^the embedded ([^ ]+) cartridge subdirectory named ([^ ]+) will( not)? exist$/ do | cart_name, dir_name, negate |
|
249
|
+
dir_path = "#{$home_root}/#{@gear.uuid}/#{cart_name}/#{dir_name}"
|
250
|
+
|
251
|
+
$logger.info("Checking for #{negate} cartridge subdirectory at #{dir_path}")
|
252
|
+
if negate
|
253
|
+
assert_directory_not_exists dir_path
|
254
|
+
else
|
255
|
+
assert_directory_exists dir_path
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
# Ensures that the named control script exists for the given embedded cartridge of the
|
261
|
+
# current application.
|
262
|
+
Then /^the embedded ([^ ]+)\-([\d\.]+) cartridge control script will( not)? exist$/ do |cart_type, cart_version, negate|
|
263
|
+
# rewrite for 10gen-mms-agent
|
264
|
+
cooked = cart_type.gsub('-', '_')
|
265
|
+
startup_file = File.join($home_root,
|
266
|
+
@gear.uuid,
|
267
|
+
"#{cart_type}-#{cart_version}",
|
268
|
+
"#{@app.name}_#{cooked}_ctl.sh")
|
269
|
+
|
270
|
+
$logger.info("Checking for #{negate} cartridge control script at #{startup_file}")
|
271
|
+
if negate
|
272
|
+
assert_file_not_exists startup_file
|
273
|
+
else
|
274
|
+
assert_file_exists startup_file
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
|
279
|
+
# Used to control the runtime state of the current application.
|
280
|
+
#
|
281
|
+
# IMPORTANT: As mentioned in the general comments, this step assumes
|
282
|
+
# a single application/gear/cartridge, and does its work by controlling
|
283
|
+
# the single cartridge directly. There will be no recursive actions for
|
284
|
+
# multiple carts associated with an app/gear.
|
285
|
+
When /^I (start|stop|status|restart) the application$/ do |action|
|
286
|
+
OpenShift::timeout(60) do
|
287
|
+
record_measure("Runtime Benchmark: Hook #{action} on application #{@cart.name}") do
|
288
|
+
@cart.run_hook(action)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
# Controls carts within the current gear directly, by cartridge name.
|
295
|
+
# The same comments from the similar matcher apply.
|
296
|
+
When /^I (start|stop|status|restart) the ([^ ]+) cartridge$/ do |action, cart_name|
|
297
|
+
record_measure("Runtime Benchmark: Hook #{action} on cart #{@cart.name}") do
|
298
|
+
@gear.carts[cart_name].run_hook(action)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
|
303
|
+
# Verifies that a process named proc_name and associated with the current
|
304
|
+
# application will be running (or not). The step will retry up to max_tries
|
305
|
+
# times to verify the expectations, as some cartridge stop hooks are
|
306
|
+
# asynchronous. This doesn't outright eliminate timing issues, but it helps.
|
307
|
+
Then /^a (.+) process will( not)? be running$/ do | proc_name, negate |
|
308
|
+
exit_test = negate ? lambda { |tval| tval == 0 } : lambda { |tval| tval > 0 }
|
309
|
+
exit_test_desc = negate ? "0" : ">0"
|
310
|
+
|
311
|
+
num_node_processes = num_procs @gear.uuid, proc_name
|
312
|
+
$logger.info("Expecting #{exit_test_desc} pid(s) named #{proc_name}, found #{num_node_processes}")
|
313
|
+
OpenShift::timeout(20) do
|
314
|
+
while (not exit_test.call(num_node_processes))
|
315
|
+
$logger.info("Waiting for #{proc_name} process count to be #{exit_test_desc}")
|
316
|
+
sleep 1
|
317
|
+
num_node_processes = num_procs @gear.uuid, proc_name
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
if not negate
|
322
|
+
num_node_processes.should be > 0
|
323
|
+
else
|
324
|
+
num_node_processes.should be == 0
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
# Verifies that a process named proc_name and associated with the current
|
330
|
+
# application will be running (or not). The step will retry up to max_tries
|
331
|
+
# times to verify the expectations, as some cartridge stop hooks are
|
332
|
+
# asynchronous. This doesn't outright eliminate timing issues, but it helps.
|
333
|
+
Then /^a (.+) process for ([^ ]+) will( not)? be running$/ do | proc_name, label, negate |
|
334
|
+
exit_test = negate ? lambda { |tval| tval == 0 } : lambda { |tval| tval > 0 }
|
335
|
+
exit_test_desc = negate ? "0" : ">0"
|
336
|
+
|
337
|
+
num_node_processes = num_procs @gear.uuid, proc_name, label
|
338
|
+
$logger.info("Expecting #{exit_test_desc} pid(s) named #{proc_name}, found #{num_node_processes}")
|
339
|
+
OpenShift::timeout(20) do
|
340
|
+
while (not exit_test.call(num_node_processes))
|
341
|
+
$logger.info("Waiting for #{proc_name} process count to be #{exit_test_desc}")
|
342
|
+
sleep 1
|
343
|
+
num_node_processes = num_procs @gear.uuid, proc_name, label
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
if not negate
|
348
|
+
num_node_processes.should be > 0
|
349
|
+
else
|
350
|
+
num_node_processes.should be == 0
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
# Verifies that exactly the specified number of the named processes
|
355
|
+
# are currently running.
|
356
|
+
#
|
357
|
+
# Could maybe be consolidated with the other similar step with some
|
358
|
+
# good refactoring.
|
359
|
+
Then /^(\d+) process(es)? named ([^ ]+) will be running$/ do | proc_count, junk, proc_name |
|
360
|
+
proc_count = proc_count.to_i
|
361
|
+
|
362
|
+
num_node_processes = num_procs @gear.uuid, proc_name
|
363
|
+
$logger.info("Expecting #{proc_count} pid(s) named #{proc_name}, found #{num_node_processes}")
|
364
|
+
OpenShift::timeout(20) do
|
365
|
+
while (num_node_processes != proc_count)
|
366
|
+
$logger.info("Waiting for #{proc_name} process count to equal #{proc_count}")
|
367
|
+
sleep 1
|
368
|
+
num_node_processes = num_procs @gear.uuid, proc_name
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
num_node_processes.should be == proc_count
|
373
|
+
end
|
374
|
+
|
375
|
+
# Verifies that exactly the specified number of the named processes
|
376
|
+
# with arguments matching 'label' are currently running.
|
377
|
+
#
|
378
|
+
# Could maybe be consolidated with the other similar step with some
|
379
|
+
# good refactoring.
|
380
|
+
Then /^(\d+) process(es)? named ([^ ]+) for ([^ ]+) will be running$/ do | proc_count, junk, proc_name, label |
|
381
|
+
proc_count = proc_count.to_i
|
382
|
+
|
383
|
+
num_node_processes = num_procs @gear.uuid, proc_name, label
|
384
|
+
$logger.info("Expecting #{proc_count} pid(s) named #{proc_name}, found #{num_node_processes}")
|
385
|
+
OpenShift::timeout(20) do
|
386
|
+
while (num_node_processes != proc_count)
|
387
|
+
$logger.info("Waiting for #{proc_name} process count to equal #{proc_count}")
|
388
|
+
sleep 1
|
389
|
+
num_node_processes = num_procs @gear.uuid, proc_name, label
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
num_node_processes.should be == proc_count
|
394
|
+
end
|
395
|
+
|
396
|
+
|
397
|
+
# Makes the application publicly accessible.
|
398
|
+
#
|
399
|
+
# - Adds an /etc/hosts entry for the application to work around
|
400
|
+
# the lack of DNS
|
401
|
+
# - Adds the test pubkey to the authorized key list for the host
|
402
|
+
# - Disables strict host key checking for the host to suppress
|
403
|
+
# interactive prompts on push
|
404
|
+
#
|
405
|
+
# This is not pretty. If it can be made less hackish and faster, it
|
406
|
+
# could be moved into the generic application setup step.
|
407
|
+
When /^the application is made publicly accessible$/ do
|
408
|
+
ssh_key = IO.read($test_pub_key).chomp.split[1]
|
409
|
+
run "echo \"127.0.0.1 #{@app.name}-#{@account.domain}.dev.rhcloud.com # Added by cucumber\" >> /etc/hosts"
|
410
|
+
run "oo-authorized-ssh-key-add -a #{@gear.uuid} -c #{@gear.uuid} -s #{ssh_key} -t ssh-rsa -m default"
|
411
|
+
run "echo -e \"Host #{@app.name}-#{@account.domain}.dev.rhcloud.com\n\tStrictHostKeyChecking no\n\" >> ~/.ssh/config"
|
412
|
+
end
|
413
|
+
|
414
|
+
|
415
|
+
# Captures the current cartridge PID hash for the test application and
|
416
|
+
# makes it accessible to other steps via @current_cart_pids.
|
417
|
+
When /^the application cartridge PIDs are tracked$/ do
|
418
|
+
@current_cart_pids = @app.current_cart_pids
|
419
|
+
|
420
|
+
$logger.info("Tracking current cartridge pids for application #{@app.name}: #{@current_cart_pids.inspect}")
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
# Toggles hot deployment for the current application.
|
425
|
+
When /^hot deployment is( not)? enabled for the application$/ do |negate|
|
426
|
+
@app.hot_deploy_enabled = negate ? false : true
|
427
|
+
$logger.info("Hot deployment #{@app.hot_deploy_enabled ? 'enabled' : 'disabled'} for application #{@app.name}")
|
428
|
+
end
|
429
|
+
|
430
|
+
|
431
|
+
# Performs a trivial update to the test application source by appending
|
432
|
+
# some random stuff to a dummy file. The change is then committed and
|
433
|
+
# pushed to the app's Git repo.
|
434
|
+
When /^an update (is|has been) pushed to the application repo$/ do |junk|
|
435
|
+
record_measure("Runtime Benchmark: Updating #{$temp}/#{@account.name}-#{@app.name} source") do
|
436
|
+
tmp_git_root = "#{$temp}/#{@account.name}-#{@app.name}-clone"
|
437
|
+
|
438
|
+
run "git clone ssh://#{@gear.uuid}@#{@app.name}-#{@account.domain}.dev.rhcloud.com/~/git/#{@app.name}.git #{tmp_git_root}"
|
439
|
+
|
440
|
+
marker_file = File.join(tmp_git_root, '.openshift', 'markers', 'hot_deploy')
|
441
|
+
|
442
|
+
if @app.hot_deploy_enabled
|
443
|
+
FileUtils.touch(marker_file)
|
444
|
+
else
|
445
|
+
FileUtils.rm_f(marker_file)
|
446
|
+
end
|
447
|
+
|
448
|
+
Dir.chdir(tmp_git_root) do
|
449
|
+
# Make a change to the app repo
|
450
|
+
run "echo $RANDOM >> cucumber_update_test"
|
451
|
+
run "git add ."
|
452
|
+
run "git commit -m 'Test change'"
|
453
|
+
run "git push"
|
454
|
+
end
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
# Adds/removes aliases from the application
|
459
|
+
When /^I add an alias to the application/ do
|
460
|
+
server_alias = "#{@app.name}.#{$alias_domain}"
|
461
|
+
|
462
|
+
@gear.add_alias(server_alias)
|
463
|
+
end
|
464
|
+
|
465
|
+
|
466
|
+
# Adds/removes aliases from the application
|
467
|
+
When /^I remove an alias from the application/ do
|
468
|
+
server_alias = "#{@app.name}.#{$alias_domain}"
|
469
|
+
|
470
|
+
@gear.remove_alias(server_alias)
|
471
|
+
end
|
472
|
+
|
473
|
+
|
474
|
+
# Asserts the 'cucumber_update_test' file exists after an update
|
475
|
+
Then /^the application repo has been updated$/ do
|
476
|
+
assert_file_exist File.join($home_root,
|
477
|
+
@gear.uuid,
|
478
|
+
'app-root',
|
479
|
+
'runtime',
|
480
|
+
'repo',
|
481
|
+
'cucumber_update_test')
|
482
|
+
end
|
483
|
+
|
484
|
+
# Compares the current PID set for the test application to whatever state
|
485
|
+
# was last captured and stored in @current_cart_pids. Raises exceptions
|
486
|
+
# depending on the expectations configured by the matcher.
|
487
|
+
Then /^the tracked application cartridge PIDs should( not)? be changed$/ do |negate|
|
488
|
+
diff_expected = !negate # better way to do this?
|
489
|
+
|
490
|
+
new_cart_pids = @app.current_cart_pids
|
491
|
+
|
492
|
+
$logger.info("Comparing old and new PIDs for #{@app.name}, diffs are #{diff_expected ? 'expected' : 'unexpected' }." \
|
493
|
+
" Old PIDs: #{@current_cart_pids.inspect}, new PIDs: #{new_cart_pids.inspect}")
|
494
|
+
|
495
|
+
diffs = []
|
496
|
+
|
497
|
+
@current_cart_pids.each do |proc_name, old_pid|
|
498
|
+
new_pid = new_cart_pids[proc_name]
|
499
|
+
|
500
|
+
if !new_pid || (new_pid != old_pid)
|
501
|
+
diffs << proc_name
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
if !diff_expected && diffs.length > 0
|
506
|
+
raise "Expected no PID differences, but found #{diffs.length}. Old PIDs: #{@current_cart_pids.inspect},"\
|
507
|
+
" new PIDs: #{new_cart_pids.inspect}"
|
508
|
+
end
|
509
|
+
|
510
|
+
if diff_expected && diffs.length == 0
|
511
|
+
raise "Expected PID differences, but found none. Old PIDs: #{@current_cart_pids.inspect},"\
|
512
|
+
" new PIDs: #{new_cart_pids.inspect}"
|
513
|
+
end
|
514
|
+
|
515
|
+
# verify BZ852268 fix
|
516
|
+
state_file = File.join($home_root, @gear.uuid, 'app-root', 'runtime', '.state')
|
517
|
+
state = File.read(state_file).chomp
|
518
|
+
assert_equal 'started', state
|
519
|
+
end
|
520
|
+
|
521
|
+
Then /^the web console for the ([^ ]+)\-([\d\.]+) cartridge at ([^ ]+) is( not)? accessible$/ do |cart_type, version, uri, negate|
|
522
|
+
conf_file = File.join($libra_httpd_conf_d,
|
523
|
+
"#{@gear.uuid}_#{@account.domain}_#{@app.name}",
|
524
|
+
"#{cart_type}-#{version}.conf")
|
525
|
+
|
526
|
+
# The URL segment for the cart lives in the proxy conf
|
527
|
+
cart_path = `/bin/awk '/ProxyPassReverse/ {printf "%s", $2;}' #{conf_file}`
|
528
|
+
url = "https://127.0.0.1#{cart_path}#{uri}"
|
529
|
+
|
530
|
+
finished = negate ? lambda { |s| s == "503" } : lambda { |s| s == "200"}
|
531
|
+
cmd = "curl -L -k -w %{http_code} -s -o /dev/null -H 'Host: #{@app.name}-#{@account.domain}.#{$domain}' #{url}"
|
532
|
+
res = `#{cmd}`
|
533
|
+
OpenShift::timeout(300) do
|
534
|
+
while not finished.call res
|
535
|
+
res = `#{cmd}`
|
536
|
+
$logger.debug { "Waiting on #{cart_type} to#{negate} be accessible: status #{res}" }
|
537
|
+
sleep 1
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
msg = "Unexpected response from #{cmd}"
|
542
|
+
if negate
|
543
|
+
assert_equal "503", res, msg
|
544
|
+
else
|
545
|
+
assert_equal "200", res, msg
|
546
|
+
end
|
547
|
+
end
|