prof 0.30.9 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/prof/environment/pcf_drinks.rb +17 -51
  3. data/lib/prof/external_spec/helpers/capybara.rb +5 -0
  4. data/lib/prof/external_spec/helpers/file_helper.rb +3 -9
  5. data/lib/prof/external_spec/spec_helper.rb +11 -6
  6. data/lib/prof/ops_manager.rb +35 -109
  7. data/lib/prof/version.rb +1 -1
  8. metadata +6 -24
  9. data/lib/prof/external_spec/helpers/debug.rb +0 -53
  10. data/lib/prof/ops_manager/rails_500_error.rb +0 -15
  11. data/lib/prof/ops_manager/web_app_internals/page/checkbox_field.rb +0 -38
  12. data/lib/prof/ops_manager/web_app_internals/page/click_field.rb +0 -40
  13. data/lib/prof/ops_manager/web_app_internals/page/dashboard.rb +0 -100
  14. data/lib/prof/ops_manager/web_app_internals/page/flash_message.rb +0 -53
  15. data/lib/prof/ops_manager/web_app_internals/page/form.rb +0 -130
  16. data/lib/prof/ops_manager/web_app_internals/page/form_error.rb +0 -43
  17. data/lib/prof/ops_manager/web_app_internals/page/form_field.rb +0 -51
  18. data/lib/prof/ops_manager/web_app_internals/page/form_fields.rb +0 -35
  19. data/lib/prof/ops_manager/web_app_internals/page/installation_progress.rb +0 -149
  20. data/lib/prof/ops_manager/web_app_internals/page/login.rb +0 -83
  21. data/lib/prof/ops_manager/web_app_internals/page/modal.rb +0 -85
  22. data/lib/prof/ops_manager/web_app_internals/page/rails_500.rb +0 -41
  23. data/lib/prof/ops_manager/web_app_internals/page/select_field.rb +0 -27
  24. data/lib/prof/ops_manager/web_app_internals/page/tile_settings.rb +0 -105
  25. data/lib/prof/ops_manager/web_app_internals.rb +0 -63
  26. data/lib/prof/ops_manager_log_fetcher.rb +0 -30
@@ -1,85 +0,0 @@
1
- # Copyright (c) 2014-2015 Pivotal Software, Inc.
2
- # All rights reserved.
3
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
4
- # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
5
- # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
7
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- #
10
-
11
- module Prof
12
- class OpsManager
13
- class WebAppInternals
14
- module Page
15
- class Modal
16
-
17
- ModalStillPresent = Class.new(StandardError)
18
-
19
- def initialize(page:)
20
- @page = page
21
- end
22
-
23
- def confirm
24
- # We have spent a long time trying to debug unreliable clicking of confirm
25
- # in both Selenium and Poltegeist. The box is animated which we think is causing
26
- # issues with where the browser is clicking. A sleep will resolve this, and has
27
- # lowest complexity.
28
- Kernel.sleep(3)
29
-
30
- confirm_button.click
31
-
32
- await_modal_disappearance!
33
- true
34
- end
35
-
36
- def success?
37
- /success/ =~ modal['id']
38
- end
39
-
40
- def failure?
41
- /failure/ =~ modal['id']
42
- end
43
-
44
- def message
45
- modal.find('.modal-body').text
46
- end
47
-
48
- def present?
49
- page.all(modal_css_selector).any? || page.all('.modal-backdrop').any?
50
- rescue Capybara::Poltergeist::ObsoleteNode
51
- false
52
- end
53
-
54
- private
55
-
56
- attr_reader :page
57
-
58
- def await_modal_disappearance!
59
- # Modal takes a long time to disappear as the next page can take a
60
- # long time to load
61
- page.document.synchronize(60, errors: [ModalStillPresent]) do
62
- raise ModalStillPresent if present?
63
- end
64
- end
65
-
66
- def modal_css_selector
67
- '.modal.in'
68
- end
69
-
70
- def modal
71
- page.find(modal_css_selector)
72
- end
73
-
74
- def confirm_button
75
- modal.find('.modal-footer .btn-primary')
76
- end
77
-
78
- def poltergeist?
79
- page.driver.class.to_s == 'Capybara::Poltergeist::Driver'
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
@@ -1,41 +0,0 @@
1
- # Copyright (c) 2014-2015 Pivotal Software, Inc.
2
- # All rights reserved.
3
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
4
- # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
5
- # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
7
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- #
10
-
11
- require 'prof/ops_manager/rails_500_error'
12
-
13
- module Prof
14
- class OpsManager
15
- class WebAppInternals
16
- module Page
17
- class Rails500
18
- def initialize(page:)
19
- @page = page
20
- end
21
-
22
- def matches?
23
- page.all('.error-page.rails-env-production').any?
24
- end
25
-
26
- def error
27
- Rails500Error.new(message)
28
- end
29
-
30
- private
31
-
32
- attr_reader :page
33
-
34
- def message
35
- page.all('.error').map(&:text).join("\n")
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,27 +0,0 @@
1
- # Copyright (c) 2014-2015 Pivotal Software, Inc.
2
- # All rights reserved.
3
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
4
- # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
5
- # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
7
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- #
10
-
11
- require 'prof/ops_manager/web_app_internals/page/form_field'
12
-
13
- module Prof
14
- class OpsManager
15
- class WebAppInternals
16
- module Page
17
- class SelectField < FormField
18
- private
19
-
20
- def set_value(field)
21
- field.find(:option, value).select_option
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,105 +0,0 @@
1
- # Copyright (c) 2014-2015 Pivotal Software, Inc.
2
- # All rights reserved.
3
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
4
- # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
5
- # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
7
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- #
10
-
11
- require 'prof/ops_manager/web_app_internals/page/dashboard'
12
- require 'prof/ops_manager/web_app_internals/page/form'
13
- require 'uri'
14
-
15
- module Prof
16
- class OpsManager
17
- class WebAppInternals
18
- module Page
19
- class TileSettings
20
- def initialize(opts = {})
21
- @page = opts.fetch(:page)
22
-
23
- check_on_settings!
24
- end
25
-
26
- def setting_names
27
- page.all('.sidebar li').map(&:text)
28
- end
29
-
30
- def set_field_value(setting_name, field_name, field_value)
31
- sidebar(setting_name)
32
- update(field_name => field_value)
33
- end
34
-
35
- def settings_for(setting_name)
36
- sidebar(setting_name)
37
-
38
- config = {}
39
- page.all(".content #{fields_selector}").each do |input|
40
- config[input['name']] = if config[input['name']]
41
- [input.value] + Array(config[input['name']])
42
- else
43
- input.value
44
- end
45
- end
46
- config
47
- end
48
-
49
- def configure(configuration)
50
- configuration.each { |sidebar_name, config| sidebar(sidebar_name).update(config) }
51
- return_to_dashboard
52
- end
53
-
54
- def update(config = {}, &block)
55
- form.update config, &block
56
- self
57
- end
58
-
59
- def sidebar(next_settings_name, &_block)
60
- return self if next_settings_name == current_setting_name
61
-
62
- page.find('.sidebar li a', text: /^\s*#{next_settings_name}\s*$/).click
63
-
64
- if block_given?
65
- yield page
66
- return_to_dashboard
67
- else
68
- TileSettings.new(page: page)
69
- end
70
- end
71
-
72
- def return_to_dashboard
73
- page.click_on 'Installation Dashboard'
74
- Dashboard.new(page: page)
75
- end
76
-
77
- def current_uri
78
- URI(page.current_url)
79
- end
80
-
81
- private
82
-
83
- attr_reader :page
84
-
85
- def current_setting_name
86
- page.find('.sidebar li.active').text
87
- end
88
-
89
- def fields_selector
90
- 'input[type="text"],textarea,input[type="checkbox"][checked],input[type="radio"][selected],select'
91
- end
92
-
93
- def form
94
- @form ||= Form.new(page: page, form_element: page.find('.content form'))
95
- end
96
-
97
- def check_on_settings!
98
- return if current_uri.path.end_with?('edit')
99
- raise "Expected to be on a settings page, but am on #{page.current_url}"
100
- end
101
- end
102
- end
103
- end
104
- end
105
- end
@@ -1,63 +0,0 @@
1
- # Copyright (c) 2014-2015 Pivotal Software, Inc.
2
- # All rights reserved.
3
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
4
- # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
5
- # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
7
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- #
10
-
11
- require 'prof/ops_manager/web_app_internals/page/dashboard'
12
- require 'prof/ops_manager/web_app_internals/page/flash_message'
13
- require 'prof/ops_manager/web_app_internals/page/login'
14
- require 'prof/tile'
15
-
16
- module Prof
17
- class OpsManager
18
- class WebAppInternals
19
- def initialize(dashboard, opsmanager_client, page, url)
20
- @dashboard = dashboard
21
- @page = page
22
- @opsmanager_client = opsmanager_client
23
- @url = url
24
- end
25
-
26
- def apply_changes
27
- visit
28
- check_nothing_in_progress!
29
- return unless dashboard.pending_changes?
30
- raise 'Could not apply changes' unless dashboard.apply_changes.install_successful?
31
- end
32
-
33
- def tile_uninstall(tile)
34
- return unless opsmanager_client.product_type_installed?(tile)
35
- visit
36
- check_nothing_in_progress!
37
- raise 'Uninstall was not successful' unless dashboard.tile_uninstall(tile)
38
- end
39
-
40
- private
41
-
42
- attr_reader :dashboard, :page, :opsmanager_client, :url
43
-
44
- def visit
45
- page.visit(url) unless page.current_url == url
46
- end
47
-
48
- def flash_message
49
- Page::FlashMessage.new(page: page)
50
- end
51
-
52
- def check_nothing_in_progress!
53
- raise 'Installation already in progress' if flash_message.installation_in_progress?
54
- end
55
-
56
- def add_cf_tile_if_needed
57
- unless page.has_selector?("a[id='show-cf-configure-action']")
58
- page.find('#add-cf', visible: false).trigger('click')
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,30 +0,0 @@
1
- # Copyright (c) 2014-2015 Pivotal Software, Inc.
2
- # All rights reserved.
3
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
4
- # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
5
- # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
7
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8
- # USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- #
10
-
11
- module Prof
12
- class OpsManagerLogFetcher
13
- def initialize(ssh_gateway:, host:, username:, password:)
14
- @ssh_gateway = ssh_gateway
15
- @host = host
16
- @username = username
17
- @password = password
18
- end
19
-
20
- def fetch_logs(log_name, lines_from_tail = 0)
21
- read_command = lines_from_tail > 0 ? "tail -n #{lines_from_tail}" : 'cat'
22
- command = "#{read_command} /tmp/logs/#{log_name}"
23
- ssh_gateway.execute_on(host, command, user: username, password: password)
24
- end
25
-
26
- private
27
-
28
- attr_reader :ssh_gateway, :host, :username, :password
29
- end
30
- end