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.

Files changed (180) hide show
  1. data/COPYRIGHT +1 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +12 -0
  4. data/README.md +3 -0
  5. data/Rakefile +9 -0
  6. data/app/controllers/app_events_controller.rb +115 -0
  7. data/app/controllers/application_templates_controller.rb +19 -0
  8. data/app/controllers/applications_controller.rb +214 -0
  9. data/app/controllers/base_controller.rb +367 -0
  10. data/app/controllers/cartridges_controller.rb +48 -0
  11. data/app/controllers/descriptors_controller.rb +23 -0
  12. data/app/controllers/dns_resolvable_controller.rb +35 -0
  13. data/app/controllers/domains_controller.rb +156 -0
  14. data/app/controllers/emb_cart_controller.rb +276 -0
  15. data/app/controllers/emb_cart_events_controller.rb +52 -0
  16. data/app/controllers/environment_controller.rb +11 -0
  17. data/app/controllers/estimates_controller.rb +71 -0
  18. data/app/controllers/gear_groups_controller.rb +53 -0
  19. data/app/controllers/gears_controller.rb +70 -0
  20. data/app/controllers/keys_controller.rb +96 -0
  21. data/app/controllers/legacy_broker_controller.rb +510 -0
  22. data/app/controllers/quickstarts_controller.rb +29 -0
  23. data/app/controllers/user_controller.rb +38 -0
  24. data/app/helpers/cartridge_helper.rb +25 -0
  25. data/app/helpers/legacy_broker_helper.rb +21 -0
  26. data/app/helpers/user_action_logger.rb +38 -0
  27. data/app/models/application.rb +1718 -0
  28. data/app/models/application_template.rb +27 -0
  29. data/app/models/cartridge_cache.rb +51 -0
  30. data/app/models/cloud_user.rb +334 -0
  31. data/app/models/component_instance.rb +228 -0
  32. data/app/models/connection_endpoint.rb +10 -0
  33. data/app/models/district.rb +210 -0
  34. data/app/models/domain.rb +234 -0
  35. data/app/models/gear.rb +376 -0
  36. data/app/models/group_instance.rb +306 -0
  37. data/app/models/key.rb +20 -0
  38. data/app/models/legacy_reply.rb +15 -0
  39. data/app/models/legacy_request.rb +126 -0
  40. data/app/models/link.rb +11 -0
  41. data/app/models/message.rb +10 -0
  42. data/app/models/name_server_cache.rb +46 -0
  43. data/app/models/optional_param.rb +12 -0
  44. data/app/models/param.rb +13 -0
  45. data/app/models/remote_job.rb +57 -0
  46. data/app/models/rest_application.rb +126 -0
  47. data/app/models/rest_application10.rb +106 -0
  48. data/app/models/rest_application12.rb +124 -0
  49. data/app/models/rest_application_estimate.rb +12 -0
  50. data/app/models/rest_application_template.rb +20 -0
  51. data/app/models/rest_cartridge10.rb +41 -0
  52. data/app/models/rest_cartridge11.rb +151 -0
  53. data/app/models/rest_domain.rb +43 -0
  54. data/app/models/rest_domain10.rb +42 -0
  55. data/app/models/rest_estimates.rb +16 -0
  56. data/app/models/rest_gear.rb +14 -0
  57. data/app/models/rest_gear_group.rb +26 -0
  58. data/app/models/rest_key.rb +24 -0
  59. data/app/models/rest_reply.rb +31 -0
  60. data/app/models/rest_user.rb +43 -0
  61. data/app/models/result_io.rb +67 -0
  62. data/app/models/usage_record.rb +37 -0
  63. data/app/models/validators/app_validator.rb +30 -0
  64. data/app/models/validators/key_validator.rb +30 -0
  65. data/app/models/validators/namespace_validator.rb +18 -0
  66. data/config/routes.rb +36 -0
  67. data/lib/controller_engine.rb +7 -0
  68. data/lib/openshift-origin-controller.rb +14 -0
  69. data/lib/openshift/application_container_proxy.rb +241 -0
  70. data/lib/openshift/auth_service.rb +101 -0
  71. data/lib/openshift/data_store.rb +33 -0
  72. data/lib/openshift/dns_service.rb +41 -0
  73. data/lib/openshift/mongo_data_store.rb +671 -0
  74. data/openshift-origin-controller.gemspec +42 -0
  75. data/rubygem-openshift-origin-controller.spec +274 -0
  76. data/test/cucumber/application-estimate.feature +25 -0
  77. data/test/cucumber/cartridge-10gen-mms-agent.feature +28 -0
  78. data/test/cucumber/cartridge-cron.feature +32 -0
  79. data/test/cucumber/cartridge-haproxy.feature +31 -0
  80. data/test/cucumber/cartridge-jenkins-build.feature +12 -0
  81. data/test/cucumber/cartridge-jenkins-client.feature +10 -0
  82. data/test/cucumber/cartridge-lifecycle-diy.feature +21 -0
  83. data/test/cucumber/cartridge-lifecycle-jbossas.feature +61 -0
  84. data/test/cucumber/cartridge-lifecycle-jbosseap.feature +61 -0
  85. data/test/cucumber/cartridge-lifecycle-jbossews10.feature +61 -0
  86. data/test/cucumber/cartridge-lifecycle-jenkins.feature +41 -0
  87. data/test/cucumber/cartridge-lifecycle-nodejs.feature +59 -0
  88. data/test/cucumber/cartridge-lifecycle-perl.feature +40 -0
  89. data/test/cucumber/cartridge-lifecycle-php.feature +106 -0
  90. data/test/cucumber/cartridge-lifecycle-python.feature +40 -0
  91. data/test/cucumber/cartridge-lifecycle-ruby18.feature +49 -0
  92. data/test/cucumber/cartridge-lifecycle-ruby19.feature +41 -0
  93. data/test/cucumber/cartridge-mongodb.feature +31 -0
  94. data/test/cucumber/cartridge-mysql.feature +30 -0
  95. data/test/cucumber/cartridge-php.feature +14 -0
  96. data/test/cucumber/cartridge-phpmyadmin.feature +32 -0
  97. data/test/cucumber/cartridge-postgresql.feature +32 -0
  98. data/test/cucumber/cartridge-runtime-extended-db.feature +64 -0
  99. data/test/cucumber/cartridge-runtime-extended-jboss.feature +24 -0
  100. data/test/cucumber/cartridge-runtime-extended-nodejs.feature +21 -0
  101. data/test/cucumber/cartridge-runtime-extended-perl.feature +18 -0
  102. data/test/cucumber/cartridge-runtime-extended-php.feature +19 -0
  103. data/test/cucumber/cartridge-runtime-extended-python.feature +18 -0
  104. data/test/cucumber/cartridge-runtime-extended-ruby.feature +22 -0
  105. data/test/cucumber/cartridge-runtime-standard-diy.feature +6 -0
  106. data/test/cucumber/cartridge-runtime-standard-jbossas.feature +7 -0
  107. data/test/cucumber/cartridge-runtime-standard-jbosseap.feature +7 -0
  108. data/test/cucumber/cartridge-runtime-standard-jbossews10.feature +7 -0
  109. data/test/cucumber/cartridge-runtime-standard-jenkins.feature +8 -0
  110. data/test/cucumber/cartridge-runtime-standard-nodejs.feature +7 -0
  111. data/test/cucumber/cartridge-runtime-standard-perl.feature +6 -0
  112. data/test/cucumber/cartridge-runtime-standard-php.feature +6 -0
  113. data/test/cucumber/cartridge-runtime-standard-python.feature +6 -0
  114. data/test/cucumber/cartridge-runtime-standard-ruby.feature +19 -0
  115. data/test/cucumber/cartridge-switchyard.feature +36 -0
  116. data/test/cucumber/descriptor.feature +40 -0
  117. data/test/cucumber/embedded.feature +44 -0
  118. data/test/cucumber/idler.feature +75 -0
  119. data/test/cucumber/misc/descriptor/manifest.yml +22 -0
  120. data/test/cucumber/misc/php/db_test.php +21 -0
  121. data/test/cucumber/openshift-node.feature +21 -0
  122. data/test/cucumber/rest-application-templates.feature +31 -0
  123. data/test/cucumber/rest-applications.feature +431 -0
  124. data/test/cucumber/rest-cartridge-types.feature +16 -0
  125. data/test/cucumber/rest-domains.feature +276 -0
  126. data/test/cucumber/rest-gears.feature +38 -0
  127. data/test/cucumber/rest-keys.feature +247 -0
  128. data/test/cucumber/rest-quickstarts.feature +27 -0
  129. data/test/cucumber/rest-workflow.feature +64 -0
  130. data/test/cucumber/step_definitions/api_steps.rb +369 -0
  131. data/test/cucumber/step_definitions/application-estimate-steps.rb +51 -0
  132. data/test/cucumber/step_definitions/application_steps.rb +215 -0
  133. data/test/cucumber/step_definitions/cartridge-10gen-mms-agent_steps.rb +11 -0
  134. data/test/cucumber/step_definitions/cartridge-cron_steps.rb +51 -0
  135. data/test/cucumber/step_definitions/cartridge-haproxy_steps.rb +30 -0
  136. data/test/cucumber/step_definitions/cartridge-jenkins_steps.rb +93 -0
  137. data/test/cucumber/step_definitions/cartridge-lifecycle-nodejs_steps.rb +30 -0
  138. data/test/cucumber/step_definitions/cartridge-mongodb_steps.rb +60 -0
  139. data/test/cucumber/step_definitions/cartridge-mysql_steps.rb +56 -0
  140. data/test/cucumber/step_definitions/cartridge-php_steps.rb +72 -0
  141. data/test/cucumber/step_definitions/cartridge-postgresql_steps.rb +59 -0
  142. data/test/cucumber/step_definitions/cartridge-switchyard_steps.rb +29 -0
  143. data/test/cucumber/step_definitions/client_steps.rb +12 -0
  144. data/test/cucumber/step_definitions/descriptor_step.rb +32 -0
  145. data/test/cucumber/step_definitions/idler_steps.rb +37 -0
  146. data/test/cucumber/step_definitions/node_steps.rb +203 -0
  147. data/test/cucumber/step_definitions/runtime_steps.rb +547 -0
  148. data/test/cucumber/step_definitions/runtime_url_steps.rb +46 -0
  149. data/test/cucumber/step_definitions/trap-user-extended_steps.rb +14 -0
  150. data/test/cucumber/step_definitions/trap-user_steps.rb +58 -0
  151. data/test/cucumber/support/00_setup_helper.rb +106 -0
  152. data/test/cucumber/support/app_helper.rb +243 -0
  153. data/test/cucumber/support/assertions.rb +52 -0
  154. data/test/cucumber/support/command_helper.rb +453 -0
  155. data/test/cucumber/support/dns_helper.rb +54 -0
  156. data/test/cucumber/support/env.rb +5 -0
  157. data/test/cucumber/support/process_helper.rb +44 -0
  158. data/test/cucumber/support/runtime_support.rb +440 -0
  159. data/test/cucumber/support/unused.rb +27 -0
  160. data/test/cucumber/support/user_helper.rb +37 -0
  161. data/test/cucumber/trap-user-extended.feature +53 -0
  162. data/test/cucumber/trap-user.feature +34 -0
  163. data/test/ddns/1.168.192-rev.db.init +13 -0
  164. data/test/ddns/HOWTO.txt +207 -0
  165. data/test/ddns/Kexample.com.+157+06142.key +1 -0
  166. data/test/ddns/Kexample.com.+157+06142.private +7 -0
  167. data/test/ddns/authconfig.rb +14 -0
  168. data/test/ddns/example.com.db.init +23 -0
  169. data/test/ddns/example.com.key +4 -0
  170. data/test/ddns/named.ca +52 -0
  171. data/test/ddns/named.conf +48 -0
  172. data/test/ddns/named.empty +10 -0
  173. data/test/ddns/named.localhost +10 -0
  174. data/test/ddns/named.loopback +11 -0
  175. data/test/ddns/named.rfc1912.zones +42 -0
  176. data/test/ddns/named.root.key +5 -0
  177. data/test/ddns/named_service.rb +127 -0
  178. data/test/unit/bind_dns_service_test.rb +167 -0
  179. data/test/unit/broker_auth_test.rb +28 -0
  180. metadata +545 -0
@@ -0,0 +1,51 @@
1
+ When /^I provide application descriptor with name '([^\']*)' and dependencies:'([^\']*)' and groups:'([^\']*)'$/ do |app_name, dependencies, groups|
2
+ requires = "Requires:\n"
3
+ dependencies.split(",").each do |dep|
4
+ requires += " - #{dep}\n"
5
+ end
6
+ if !groups.empty?
7
+ groups = groups.split(";").map{ |grp| " - [#{grp}]"}
8
+ groups = groups.join("\n")
9
+ end
10
+ descriptor = "--- \nName: #{app_name}\n#{requires}"
11
+ descriptor += "GroupOverrides: \n#{groups}\n" if !groups.empty?
12
+
13
+ payload = {"descriptor" => descriptor}
14
+ url = @base_url + "/estimates/application"
15
+ @request = RestClient::Request.new(:method => :get, :url => url,
16
+ :user => @username, :password => @password, :headers => @headers,
17
+ :payload => payload)
18
+
19
+ begin
20
+ @response = @request.execute()
21
+ rescue => e
22
+ @response = e.response
23
+ end
24
+ end
25
+
26
+ Then /^should get (\d) gears$/ do |num_gears|
27
+ page = JSON.parse(@response.body)
28
+ @gears = page["data"]
29
+ @gears.size.should be == num_gears.to_i
30
+ end
31
+
32
+ Then /^should get (\d) gear with '([^\']*)' component(s)?$/ do |num_gears, components, skip|
33
+ components = components.split(',')
34
+ matched_gears = 0
35
+
36
+ @gears.each do |g|
37
+ comps = []
38
+ g["components"].each do |comp|
39
+ comps.push comp['Name']
40
+ end
41
+
42
+ match = 0
43
+ components.each do |c|
44
+ break if !comps.include?(c)
45
+ match += 1
46
+ end
47
+ matched_gears += 1 if match == components.size
48
+ end if @gears
49
+
50
+ matched_gears.should be == num_gears.to_i
51
+ end
@@ -0,0 +1,215 @@
1
+ require 'rubygems'
2
+ require 'uri'
3
+ require 'fileutils'
4
+
5
+ include AppHelper
6
+
7
+ Given /^an existing (.+) application with an embedded (.*) cartridge$/ do |type, embed|
8
+ TestApp.find_on_fs.each do |app|
9
+ if app.type == type and app.embed.include?(embed)
10
+ @app = app
11
+ break
12
+ end
13
+ end
14
+
15
+ @app.should_not be_nil
16
+ end
17
+
18
+ Given /^an existing (.+) application( without an embedded cartridge)?$/ do |type, ignore|
19
+ TestApp.find_on_fs.each do |app|
20
+ if app.type == type and app.embed.empty?
21
+ @app = app
22
+ @app.update_jenkins_info if type.start_with?("jenkins")
23
+ break
24
+ end
25
+ end
26
+
27
+ @app.should_not be_nil
28
+ end
29
+
30
+ Given /^a new client created (.+) application$/ do |type|
31
+ @app = TestApp.create_unique(type)
32
+ register_user(@app.login, @app.password) if $registration_required
33
+ if rhc_create_domain(@app)
34
+ rhc_create_app(@app)
35
+ end
36
+ raise "Could not create domain: #{@app.create_domain_code}" unless @app.create_domain_code == 0
37
+ raise "Could not create application #{@app.create_app_code}" unless @app.create_app_code == 0
38
+ end
39
+
40
+ When /^(\d+) (.+) applications are created$/ do |app_count, type|
41
+ # Create our domain and apps
42
+ @apps = app_count.to_i.times.collect do
43
+ app = TestApp.create_unique(type)
44
+ register_user(app.login, app.password) if $registration_required
45
+ if rhc_create_domain(app)
46
+ rhc_create_app(app)
47
+ app.update_jenkins_info if type.start_with?("jenkins")
48
+ end
49
+ raise "Could not create domain: #{app.create_domain_code}" unless app.create_domain_code == 0
50
+ raise "Could not create application #{app.create_app_code}" unless app.create_app_code == 0
51
+ app
52
+ end
53
+ end
54
+
55
+ When /^the submodule is added$/ do
56
+ Dir.chdir(@app.repo) do
57
+ # Add a submodule created in devenv and link the index file
58
+ run("git submodule add /root/submodule_test_repo")
59
+ run("REPLACE=`cat submodule_test_repo/index`; sed -i \"s/OpenShift/${REPLACE}/\" #{@app.get_index_file}")
60
+ run("git commit -a -m 'Test submodule change'")
61
+ run("git push >> " + @app.get_log("git_push") + " 2>&1")
62
+ end
63
+ end
64
+
65
+ When /^the embedded (.*) cartridge is added$/ do |type|
66
+ rhc_embed_add(@app, type)
67
+ end
68
+
69
+ When /^the embedded (.*) cartridge is removed$/ do |type|
70
+ rhc_embed_remove(@app, type)
71
+ end
72
+
73
+ When /^the application is changed$/ do
74
+ Dir.chdir(@app.repo) do
75
+ @update = "TEST"
76
+
77
+ # Make a change to the app index file
78
+ run("sed -i 's/Welcome/#{@update}/' #{@app.get_index_file}")
79
+ run("git commit -a -m 'Test change'")
80
+ run("git push >> " + @app.get_log("git_push") + " 2>&1")
81
+ end
82
+ end
83
+
84
+ When /^the application uses mysql$/ do
85
+ # the mysql file path is NOT relative to the app repo
86
+ # so, fetch the mysql file before the Dir.chdir
87
+ mysql_file = @app.get_mysql_file
88
+
89
+ Dir.chdir(@app.repo) do
90
+ # Copy the MySQL file over the index and replace the variables
91
+ FileUtils.cp mysql_file, @app.get_index_file
92
+
93
+ # Make a change to the app index file
94
+ run("sed -i 's/HOSTNAME/#{@app.mysql_hostname}/' #{@app.get_index_file}")
95
+ run("sed -i 's/USER/#{@app.mysql_user}/' #{@app.get_index_file}")
96
+ run("sed -i 's/PASSWORD/#{@app.mysql_password}/' #{@app.get_index_file}")
97
+ run("git commit -a -m 'Test change'")
98
+ run("git push >> " + @app.get_log("git_push_mysql") + " 2>&1")
99
+ end
100
+ end
101
+
102
+ When /^the application is stopped$/ do
103
+ rhc_ctl_stop(@app)
104
+ end
105
+
106
+ When /^the application is started$/ do
107
+ rhc_ctl_start(@app)
108
+ end
109
+
110
+ When /^the application is aliased$/ do
111
+ rhc_add_alias(@app)
112
+ end
113
+
114
+ When /^the application is unaliased$/ do
115
+ rhc_remove_alias(@app)
116
+ end
117
+
118
+ When /^the application is restarted$/ do
119
+ rhc_ctl_restart(@app)
120
+ end
121
+
122
+ When /^the application is destroyed$/ do
123
+ rhc_ctl_destroy(@app)
124
+ end
125
+
126
+ When /^the application namespace is updated$/ do
127
+ rhc_update_namespace(@app)
128
+ end
129
+
130
+ When /^I snapshot the application$/ do
131
+ rhc_snapshot(@app)
132
+ File.exist?(@app.snapshot).should be_true
133
+ File.size(@app.snapshot).should > 0
134
+ end
135
+
136
+ When /^I tidy the application$/ do
137
+ rhc_tidy(@app)
138
+ end
139
+
140
+ When /^I restore the application$/ do
141
+ assert_file_exists @app.snapshot
142
+ File.size(@app.snapshot).should > 0
143
+
144
+ file_list = `tar ztf #{@app.snapshot}`
145
+ ["#{@app.name}_ctl.sh", "openshift.conf", "httpd.pid"].each {|file|
146
+ assert ! file_list.include?(file), "Found illegal file \'#{file} in snapshot"
147
+ }
148
+ assert file_list.include?('app-root/runtime'), "Snapshot missing required files"
149
+
150
+ rhc_restore(@app)
151
+ end
152
+
153
+ Then /^the application should respond to the alias$/ do
154
+ @app.is_accessible?(false, 120, "#{@app.name}-#{@app.namespace}.#{$alias_domain}").should be_true
155
+ end
156
+
157
+ Then /^the applications should be accessible?$/ do
158
+ @apps.each do |app|
159
+ app.is_accessible?.should be_true
160
+ app.is_accessible?(true).should be_true
161
+ end
162
+ end
163
+
164
+ Then /^the applications should be temporarily unavailable$/ do
165
+ @apps.each do |app|
166
+ app.is_temporarily_unavailable?.should be_true
167
+ end
168
+ end
169
+
170
+ Then /^the mysql response is successful$/ do
171
+ 60.times do |i|
172
+ body = @app.connect
173
+ break if body and body =~ /Success/
174
+ sleep 1
175
+ end
176
+
177
+ # Check for Success
178
+ body = @app.connect
179
+ body.should match(/Success/)
180
+ end
181
+
182
+ Then /^it should be updated successfully$/ do
183
+ 60.times do |i|
184
+ body = @app.connect
185
+ break if body and body =~ /#{@update}/
186
+ sleep 1
187
+ end
188
+
189
+ # Make sure the update is present
190
+ body = @app.connect
191
+ body.should_not be_nil
192
+ body.should match(/#{@update}/)
193
+ end
194
+
195
+ Then /^the submodule should be deployed successfully$/ do
196
+ 60.times do |i|
197
+ body = @app.connect
198
+ break if body and body =~ /Submodule/
199
+ sleep 1
200
+ end
201
+
202
+ # Make sure the update is present
203
+ body = @app.connect
204
+ body.should_not be_nil
205
+ body.should match(/Submodule/)
206
+ end
207
+
208
+ Then /^the application should be accessible$/ do
209
+ @app.is_accessible?.should be_true
210
+ @app.is_accessible?(true).should be_true
211
+ end
212
+
213
+ Then /^the application should not be accessible$/ do
214
+ @app.is_inaccessible?.should be_true
215
+ end
@@ -0,0 +1,11 @@
1
+ require 'fileutils'
2
+
3
+ Given /^an agent settings.py file is created$/ do
4
+ filepath = "/var/lib/openshift/#{@gear.uuid}/app-root/repo/.openshift/mms/settings.py"
5
+
6
+ system("mkdir -p /var/lib/openshift/#{@gear.uuid}/app-root/repo/.openshift/mms > /dev/null")
7
+ system("cp /usr/local/share/mms-agent/settings.py #{filepath} > /dev/null")
8
+ system("chown -R #{@gear.container.user.uid}:#{@gear.container.user.uid} /var/lib/openshift/#{@gear.uuid}/app-root/repo/.openshift/mms/")
9
+
10
+ assert_file_exists filepath
11
+ end
@@ -0,0 +1,51 @@
1
+ require 'fileutils'
2
+
3
+ Given /^cron is (running|stopped)$/ do | status |
4
+ cron_cart = @gear.carts['cron-1.4']
5
+
6
+ cron_user_root = "#{$home_root}/#{@gear.uuid}/#{cron_cart.name}"
7
+ jobs_enabled_file = "#{cron_user_root}/run/jobs.enabled"
8
+
9
+ mark_exists = File.exists? jobs_enabled_file
10
+ $logger.info("Checking for cron jobs marker file at #{jobs_enabled_file}: #{mark_exists}")
11
+
12
+ if 'running' == status
13
+ if not mark_exists
14
+ cron_cart.start
15
+ end
16
+ exit_test = lambda {|f| ! File.exists? f}
17
+ else
18
+ if mark_exists
19
+ cron_cart.stop
20
+ end
21
+ exit_test = lambda {|f| File.exists? f}
22
+ end
23
+
24
+ $logger.info("Checking for cron jobs marker file at #{jobs_enabled_file}")
25
+ OpenShift::timeout(30) do
26
+ while exit_test.call(jobs_enabled_file)
27
+ sleep 1
28
+ $logger.info("Waiting for marker file to exist at #{marker_file}")
29
+ end
30
+ end
31
+
32
+ if 'running' == status
33
+ assert_file_exists jobs_enabled_file
34
+ else
35
+ assert_file_not_exists jobs_enabled_file
36
+ end
37
+ end
38
+
39
+ Then /^cron jobs will( not)? be enabled$/ do | negate |
40
+ cron_cart = @gear.carts['cron-1.4']
41
+
42
+ cron_user_root = "#{$home_root}/#{@gear.uuid}/#{cron_cart.name}"
43
+ jobs_enabled_file = "#{cron_user_root}/run/jobs.enabled"
44
+
45
+ $logger.info("Checking for cron jobs marker at #{jobs_enabled_file}")
46
+ if negate
47
+ assert_file_not_exists jobs_enabled_file
48
+ else
49
+ assert_file_exists jobs_enabled_file
50
+ end
51
+ end
@@ -0,0 +1,30 @@
1
+ # step descriptions for HAProxy cartridge behavior.
2
+
3
+ require 'fileutils'
4
+
5
+ # Hack to ensure haproxy_ctld_daemon continues to work
6
+ ENV['BUNDLE_GEMFILE'] = nil
7
+
8
+
9
+ Then /^the haproxy PATH override will( not)? exist$/ do |negate|
10
+ path_location = "#{$home_root}/#{@gear.uuid}/.env/PATH"
11
+
12
+ path_override = open(path_location).grep(/haproxy-1.4/)[0]
13
+
14
+ unless negate
15
+ path_override.should be_a(String)
16
+ else
17
+ path_override.should be_nil
18
+ end
19
+ end
20
+
21
+ Then /^the haproxy configuration file will( not)? exist$/ do |negate|
22
+ haproxy_user_root = "#{$home_root}/#{@gear.uuid}/haproxy-1.4"
23
+ haproxy_config_file = "#{haproxy_user_root}/conf/haproxy.cfg.template"
24
+
25
+ if negate
26
+ assert_file_not_exists haproxy_config_file
27
+ else
28
+ assert_file_exists haproxy_config_file
29
+ end
30
+ end
@@ -0,0 +1,93 @@
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+ require 'json'
4
+ require 'logger'
5
+ require 'open4'
6
+ require 'pp'
7
+ require 'rest-client'
8
+
9
+ include AppHelper
10
+
11
+ When /^I configure a hello_world diy application with jenkins enabled$/ do
12
+ @app = TestApp.create_unique('diy-0.1', 'diy')
13
+ run "echo -e \"Host #{@app.hostname}\n\tStrictHostKeyChecking no\n\" >> ~/.ssh/config"
14
+
15
+ register_user(@app.login, @app.password) if $registration_required
16
+ if rhc_create_domain(@app)
17
+ @diy_app = rhc_create_app(@app, false, '--enable-jenkins --timeout=120')
18
+ @diy_app.create_app_code.should be == 0
19
+ else
20
+ raise "Failed to create domain: #{@app}"
21
+ end
22
+
23
+ @app.update_jenkins_info
24
+
25
+ response = `#{@app.jenkins_build}`
26
+ $logger.debug "@jenkins_build response = [#{response}]"
27
+
28
+ job = JSON.parse(response)
29
+
30
+ job.should_not be_nil
31
+ job['name'].should be == 'diy-build', "#{job['name']} not equal to diy-build"
32
+ job['color'].should be == 'grey', "job #{job['name']} has already been run."
33
+ end
34
+
35
+ When /^I push an update to the diy application$/ do
36
+ output = `awk <#{$temp}/cucumber.log '/^ *Git URL.*diy.git.$/ {print $NF}'`.split("\n")
37
+ @diy_git_url = output[-1]
38
+ $logger.debug "git url: #{@diy_git_url}"
39
+ assert_not_nil @diy_git_url, "Failed to find Git URL for diy application"
40
+
41
+ FileUtils.rm_rf 'diy' if File.exists? 'diy'
42
+ assert_directory_not_exists 'diy'
43
+
44
+ exit_code = run "git clone #{@diy_git_url} diy"
45
+ assert_equal 0, exit_code, "Failed to clone diy repo"
46
+
47
+ Dir.chdir("diy") do
48
+ exit_code = run "sed -i 's/Welcome to OpenShift/Jenkins Builder Testing/' diy/index.html"
49
+ assert_equal 0, exit_code, "Failed to update diy/index.html"
50
+
51
+ exit_code = run "git commit -a -m 'force build'"
52
+ assert_equal 0, exit_code, "Failed to commit update to diy/index.html"
53
+
54
+ exit_code = -1
55
+ begin
56
+ Timeout::timeout(300) do
57
+ exit_code = run "git push"
58
+ end
59
+ rescue Timeout::Error
60
+ $logger.warn "Timed out during git push. Usually means jenkins cartridge failing"
61
+ raise
62
+ rescue => e
63
+ $logger.error "Unexpected exception #{e.class} during git push: #{e.message}\n#{e.backtrace.join("\n")}"
64
+ raise
65
+ end
66
+ assert_equal 0, exit_code, "Failed to push update to diy/index.html"
67
+ end
68
+ end
69
+
70
+ Then /^the application will be updated$/ do
71
+ # wait for ball to change blue...
72
+ job = {'color' => 'purple'}
73
+ OpenShift::timeout(300) do
74
+ begin
75
+ sleep 1
76
+ response = `#{@app.jenkins_build}`
77
+ $logger.debug "@jenkins_build response = #{response}"
78
+
79
+ job = JSON.parse(response)
80
+ end while job['color'] != 'blue'
81
+ end
82
+ job['color'].should be == 'blue'
83
+
84
+ app_uuid = @diy_git_url.match(TestApp::SSH_OUTPUT_PATTERN)[1]
85
+ path = "/var/lib/openshift/#{app_uuid}/app-root/repo/#{@app.name}/index.html"
86
+ $logger.debug "jenkins built application path = #{path}"
87
+ `grep 'Jenkins Builder Testing' "#{path}"`
88
+ $?.to_i.should be == 0
89
+ end
90
+
91
+ Then /^I deconfigure the diy application with jenkins enabled$/ do
92
+ rhc_ctl_destroy(@app, false)
93
+ end