gridium 1.1.39 → 1.1.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c87afa06bbdeefbfd41eee62c6cc5a5af18698a6
4
- data.tar.gz: 4ff0a6d5254bb94cab3325975384e6f0ec20faf6
3
+ metadata.gz: f26680684a7be03d71d24283694c5fdf8e091d63
4
+ data.tar.gz: 269bc03184b510b21ea7d09aa0c982e347029879
5
5
  SHA512:
6
- metadata.gz: e58e927badaab9547d7564c86db383ef913290db08cb41c4595fbc5b683a0e15fed521d34440032e547304699a1d587a38c9b28f64c5606a73dafc229a392799
7
- data.tar.gz: 45839f28c4a1ff4972fe5ca5c20aed05481fd07466292302f1dddfae09dc9793c4b329d39841015982a63ad525ca9a8c026d80a3e0903c4dfb4cdb65695dd92f
6
+ metadata.gz: 320b3b36f28fc2785d3279595e0445f9ca67d4943d63fc79ca9fdcc0c28856c3d957cec333634d38659fd616483a290fa9dcc7b85e0d9c91880193aebae9ad58
7
+ data.tar.gz: 5a3f4adea5579fd9d6c9382292eb2dfa3a16f4c6c5a461e3ad60453fe470419c6e7d14e1216ec874aec5f2a7fbf09d22324f2f2d8b3b8440982ff122cce48e01
@@ -5,7 +5,9 @@ services:
5
5
  ports:
6
6
  - "4444"
7
7
  environment:
8
- - GRID_BROWSER_TIMEOUT=30
8
+ SE_OPTS: -browserTimeout 30
9
+ JAVA_OPTS: -Xmx1024m
10
+
9
11
  chrome:
10
12
  image: selenium/node-chrome-debug:3.1.0
11
13
  depends_on:
@@ -15,16 +17,22 @@ services:
15
17
  - HUB_PORT_4444_TCP_PORT=4444
16
18
  - no_proxy=localhost
17
19
  - HUB_ENV_no_proxy=localhost
20
+ shm_size: 2048M
21
+ volumes:
22
+ - /dev/shm:/dev/shm
18
23
  ports:
19
24
  - "5900:5900"
25
+
20
26
  mustadio:
21
27
  image: yetanotherlucas/mustadio
22
28
  ports:
23
29
  - "3000"
30
+
24
31
  the-internet:
25
32
  image: gprestes/the-internet
26
33
  ports:
27
34
  - "5000"
35
+
28
36
  gridium:
29
37
  build: .
30
38
  environment:
@@ -4,6 +4,7 @@ require 'spec_data'
4
4
 
5
5
  class Driver
6
6
  @@driver = nil
7
+ @@s3 = nil
7
8
 
8
9
  def self.reset
9
10
  Log.debug("[Gridium::Driver] Driver.reset: #{@@driver}")
@@ -14,15 +15,33 @@ class Driver
14
15
  # Ensure the browser is maximized to maximize visibility of element
15
16
  # Currently doesn't work with chromedriver, but the following workaround does:
16
17
  if @browser_type.eql?(:chrome)
18
+ driver.manage.window.move_to(0, 0)
17
19
  width = driver.execute_script("return screen.width;")
18
20
  height = driver.execute_script("return screen.height;")
19
- driver.manage.window.move_to(0, 0)
20
21
  driver.manage.window.resize_to(width, height)
22
+ driver.manage.window.move_to(0, 0)
21
23
  else
22
24
  driver.manage.window.maximize
23
25
  end
24
26
  end
25
27
 
28
+ def self.s3
29
+ unless @@s3
30
+ if Gridium.config.screenshots_to_s3
31
+ #do stuff
32
+ s3_project_folder = Gridium.config.project_name_for_s3
33
+ s3_subfolder = Gridium.config.subdirectory_name_for_s3
34
+ Log.debug("[Gridium::Driver] configuring s3 to save files to this directory: #{s3_project_folder} in addition to being saved locally")
35
+ @@s3 = Gridium::GridiumS3.new(s3_project_folder, s3_subfolder)
36
+ Log.debug("[Gridium::Driver] s3 is #{@@s3}")
37
+ else
38
+ Log.debug("[Gridium::Driver] s3 screenshots not enabled in spec_helper; they will be only be saved locally")
39
+ end
40
+ end
41
+
42
+ @@s3
43
+ end
44
+
26
45
  def self.driver
27
46
  unless @@driver
28
47
  Log.debug("[Gridium::Driver] Driver.driver: instantiating new driver")
@@ -40,19 +59,10 @@ class Driver
40
59
  else
41
60
  @@driver = Selenium::WebDriver.for(Gridium.config.browser, desired_capabilities: _set_capabilities)
42
61
  end
43
- if Gridium.config.screenshots_to_s3
44
- #do stuff
45
- s3_project_folder = Gridium.config.project_name_for_s3
46
- s3_subfolder = Gridium.config.subdirectory_name_for_s3
47
- Log.debug("[Gridium::Driver] configuring s3 to save files to this directory: #{s3_project_folder} in addition to being saved locally")
48
- @s3 = Gridium::GridiumS3.new(s3_project_folder, s3_subfolder)
49
- Log.debug("[Gridium::Driver] s3 is #{@s3}")
50
- else
51
- Log.debug("[Gridium::Driver] s3 screenshots not enabled in spec_helper; they will be only be saved locally")
52
- @s3 = nil
53
- end
62
+
54
63
  reset
55
64
  end
65
+
56
66
  _log_shart #push out logs before doing something with selenium
57
67
  @@driver
58
68
  rescue StandardError => e
@@ -103,11 +113,6 @@ class Driver
103
113
  )
104
114
  end
105
115
 
106
- def self.s3
107
- #TODO figure out why I can't just use attr_reader :s3
108
- @s3
109
- end
110
-
111
116
  def self.driver= driver
112
117
  @@driver.quit if @@driver
113
118
  @@driver = driver
@@ -264,7 +269,7 @@ class Driver
264
269
 
265
270
  # Push the screenshot up to S3?
266
271
  if Gridium.config.screenshots_to_s3
267
- screenshot_path = @s3.save_file(local_path)
272
+ screenshot_path = s3.save_file(local_path)
268
273
  Log.info("[Gridium::Driver] #{filename} uploaded to S3 at '#{screenshot_path}'")
269
274
  end
270
275
 
data/lib/s3.rb CHANGED
@@ -1,72 +1,74 @@
1
1
  require 'aws-sdk'
2
- module Gridium
3
-
4
- class GridiumS3
5
2
 
6
- DELIMITER = "/"
3
+ module Gridium
4
+ class GridiumS3
5
+ def initialize(project_name, subdirectory_path='screenshots')
6
+ Log.debug("[GRIDIUM::S3] initializing GridiumS3 with #{project_name} and #{subdirectory_path}")
7
+ Aws.config.update({ credentials: Aws::Credentials.new(ENV['S3_ACCESS_KEY_ID'], ENV['S3_SECRET_ACCESS_KEY']) , region: ENV['S3_DEFAULT_REGION']})
8
+ _validate_string(project_name)
9
+ _validate_string(subdirectory_path)
7
10
 
8
- def initialize(project_name, subdirectory_name='screenshots')
9
- Log.debug("[GRIDIUM::S3] initializing GridiumS3 with #{project_name} and #{subdirectory_name}")
10
- Aws.config.update({ credentials: Aws::Credentials.new(ENV['S3_ACCESS_KEY_ID'], ENV['S3_SECRET_ACCESS_KEY']) , region: ENV['S3_DEFAULT_REGION']})
11
- _validate_string(project_name)
12
- _validate_string(subdirectory_name)
13
- @project_name = _sanitize_string(project_name)
14
- @subdirectory_name = _sanitize_string(subdirectory_name)
15
- @bucket = Aws::S3::Resource.new().bucket(ENV['S3_ROOT_BUCKET'])
16
- end
11
+ @project_name = _sanitize_string(project_name)
12
+ @subdirectory_path = _sanitize_string(subdirectory_path)
13
+ @bucket = Aws::S3::Resource.new.bucket(ENV['S3_ROOT_BUCKET'])
14
+ end
17
15
 
18
- def save_file(absolute_path_of_file)
19
- Log.debug("[GRIDIUM::S3] attempting to save #{absolute_path_of_file} to s3")
20
- _validate_path(absolute_path_of_file)
21
- file_name = File.basename(absolute_path_of_file)
22
- destination_name = create_s3_name(file_name)
23
- begin
24
- @bucket.object(destination_name).upload_file(absolute_path_of_file)
25
- @bucket.object(destination_name).wait_until_exists
26
- _verify_upload(destination_name, absolute_path_of_file)
27
- # @bucket.object(s3_name).presigned_url(:get, expires_in: 3600) #uncomment this if public url ends up not working out OPREQ-83850
28
- return @bucket.object(destination_name).public_url
29
- rescue Aws::S3::Errors::InvalidAccessKeyId
30
- Log.error("[GRIDIUM::S3] unable to save file to s3 due to Aws::S3::Errors::InvalidAccessKeyId")
31
- rescue Seahorse::Client::NetworkingError => error
32
- Log.error("[GRIDIUM::S3] unable to save file to s3 due to underlying network error: #{error}")
33
- rescue StandardErrer => error
34
- Log.error("[GRIDIUM::S3] unable to save file to s3 due to unexpected error: #{error}")
35
- end
36
- end
16
+ # Save local file to S3 bucket
17
+ # @param [String] local_path
18
+ # @return [String] s3 public url
19
+ def save_file(local_path)
20
+ Log.debug("[GRIDIUM::S3] attempting to save '#{local_path}' to s3")
21
+ _validate_path(local_path)
22
+ file_name = File.basename(local_path)
23
+ destination_name = create_s3_name(file_name)
24
+ begin
25
+ @bucket.object(destination_name).upload_file(local_path)
26
+ @bucket.object(destination_name).wait_until_exists
27
+ _verify_upload(destination_name, local_path)
28
+ # @bucket.object(s3_name).presigned_url(:get, expires_in: 3600) #uncomment this if public url ends up not working out OPREQ-83850
29
+ return @bucket.object(destination_name).public_url
30
+ rescue Aws::S3::Errors::InvalidAccessKeyId
31
+ Log.error("[GRIDIUM::S3] unable to save file to s3 due to Aws::S3::Errors::InvalidAccessKeyId")
32
+ rescue Seahorse::Client::NetworkingError => error
33
+ Log.error("[GRIDIUM::S3] unable to save file to s3 due to underlying network error: #{error}")
34
+ rescue StandardErrer => error
35
+ Log.error("[GRIDIUM::S3] unable to save file to s3 due to unexpected error: #{error}")
36
+ end
37
+ end
37
38
 
38
- def create_s3_name(file_name)
39
- _validate_string(file_name)
40
- file_name = _sanitize_string(file_name)
41
- joined_name = [@project_name, @subdirectory_name, file_name].join(DELIMITER)
42
- joined_name
43
- end
39
+ def create_s3_name(file_name)
40
+ _validate_string(file_name)
41
+ file_name = _sanitize_string(file_name)
42
+ [@project_name, @subdirectory_path, file_name].join("/")
43
+ end
44
44
 
45
- def _sanitize_string(input_string)
46
- #remove left/right whitespace, split and join to collapse contiguous white space, replace whitespace and non-period special chars with underscore
47
- input_string = input_string.strip().split.join(" ").gsub(/[^\w.]/i, '_')
48
- input_string
49
- end
45
+ #
46
+ # @note Strips whitespace, split and join to collapse contiguous white space,
47
+ # replace whitespace and special chars (not '.', '/') with an underscore
48
+ #
49
+ def _sanitize_string(input_string)
50
+ input_string.strip.split.join(" ").gsub(/[^\w.\/]/i, '_')
51
+ end
50
52
 
51
- def _validate_string(input_string)
52
- Log.debug("[GRIDIUM::S3] attempting to validate #{input_string} for use as a name")
53
- if input_string.empty? or input_string.strip().empty? then
54
- raise(ArgumentError, "[GRIDIUM::S3] empty and/or whitespace file names are not wanted here.")
55
- end
56
- end
53
+ def _validate_string(input_string)
54
+ Log.debug("[GRIDIUM::S3] attempting to validate #{input_string} for use as a name")
55
+ if input_string.empty? || input_string.strip.empty?
56
+ raise(ArgumentError, "[GRIDIUM::S3] empty and/or whitespace file names are not wanted here.")
57
+ end
58
+ end
57
59
 
58
- def _validate_path(path_to_file)
59
- Log.debug("[GRIDIUM::S3] attempting to validate #{path_to_file} as a legitimate path")
60
- if not File.exist? path_to_file then
61
- raise(ArgumentError, "[GRIDIUM::S3] this path doesn't resolve #{path_to_file}")
62
- end
63
- end
60
+ def _validate_path(path_to_file)
61
+ Log.debug("[GRIDIUM::S3] attempting to validate #{path_to_file} as a legitimate path")
62
+ unless File.exist? path_to_file
63
+ raise(ArgumentError, "[GRIDIUM::S3] this path doesn't resolve #{path_to_file}")
64
+ end
65
+ end
64
66
 
65
- def _verify_upload(s3_name, local_absolute_path)
66
- upload_size = @bucket.object(s3_name).content_length
67
- local_size = File.size local_absolute_path
68
- Log.debug("[GRIDIUM::S3] file upload verified: #{upload_size == local_size}. upload size is #{upload_size} and local size is #{local_size}")
69
- upload_size == local_size
70
- end
67
+ def _verify_upload(s3_name, local_absolute_path)
68
+ upload_size = @bucket.object(s3_name).content_length
69
+ local_size = File.size local_absolute_path
70
+ Log.debug("[GRIDIUM::S3] file upload verified: #{upload_size == local_size}. upload size is #{upload_size} and local size is #{local_size}")
71
+ upload_size == local_size
71
72
  end
73
+ end
72
74
  end
@@ -65,13 +65,17 @@ module Gridium
65
65
  message = rspec_test.exception.message
66
66
  screenshot_url = rspec_test.metadata[:screenshot_url]
67
67
  if screenshot_url
68
- message << "\n - Screenshot: #{screenshot_url}"
68
+ message << "\n - Screenshot: #{screenshot_url}\n"
69
69
  end
70
70
 
71
71
  # add backtrace to test case
72
72
  bt_search_re = rspec_test.metadata[:backtrace_regex] || 'sitetestui'
73
73
  bt = rspec_test.exception.backtrace.grep(/#{bt_search_re}/)
74
- message << "\n\n # " + bt.join("\n # ") unless bt.empty?
74
+ message << "\n\n -> " + bt.join("\n -> ") unless bt.empty?
75
+
76
+ # replace rspec backtick (`): special formatting for TestRail
77
+ # http://docs.gurock.com/testrail-userguide/userguide-editor
78
+ message.gsub!('`', "'")
75
79
  else
76
80
  status = CONFIG[:pass]
77
81
  message = 'Test Passed.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.39
4
+ version: 1.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-13 00:00:00.000000000 Z
11
+ date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler