gridium 1.1.39 → 1.1.42
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.
- checksums.yaml +4 -4
- data/docker-compose.yml +9 -1
- data/lib/driver.rb +23 -18
- data/lib/s3.rb +63 -61
- data/lib/testrail.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f26680684a7be03d71d24283694c5fdf8e091d63
|
|
4
|
+
data.tar.gz: 269bc03184b510b21ea7d09aa0c982e347029879
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 320b3b36f28fc2785d3279595e0445f9ca67d4943d63fc79ca9fdcc0c28856c3d957cec333634d38659fd616483a290fa9dcc7b85e0d9c91880193aebae9ad58
|
|
7
|
+
data.tar.gz: 5a3f4adea5579fd9d6c9382292eb2dfa3a16f4c6c5a461e3ad60453fe470419c6e7d14e1216ec874aec5f2a7fbf09d22324f2f2d8b3b8440982ff122cce48e01
|
data/docker-compose.yml
CHANGED
|
@@ -5,7 +5,9 @@ services:
|
|
|
5
5
|
ports:
|
|
6
6
|
- "4444"
|
|
7
7
|
environment:
|
|
8
|
-
-
|
|
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:
|
data/lib/driver.rb
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
data/lib/testrail.rb
CHANGED
|
@@ -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
|
|
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.
|
|
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-
|
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|