Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
32da5296
Commit
32da5296
authored
Feb 07, 2022
by
Sofia Vistas
Committed by
Ramya Authappan
Feb 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format QA logger and add colorised logs
parent
1ba3d52a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
33 additions
and
14 deletions
+33
-14
qa/Gemfile
qa/Gemfile
+1
-0
qa/qa/resource/base.rb
qa/qa/resource/base.rb
+3
-2
qa/qa/resource/clusters/agent.rb
qa/qa/resource/clusters/agent.rb
+0
-1
qa/qa/resource/clusters/agent_token.rb
qa/qa/resource/clusters/agent_token.rb
+0
-1
qa/qa/runtime/env.rb
qa/qa/runtime/env.rb
+4
-0
qa/qa/runtime/logger.rb
qa/qa/runtime/logger.rb
+10
-0
qa/qa/service/cluster_provider/gcloud.rb
qa/qa/service/cluster_provider/gcloud.rb
+1
-1
qa/qa/service/shellout.rb
qa/qa/service/shellout.rb
+2
-1
qa/qa/support/page/logging.rb
qa/qa/support/page/logging.rb
+7
-5
qa/qa/support/repeater.rb
qa/qa/support/repeater.rb
+3
-2
qa/qa/tools/initialize_gitlab_auth.rb
qa/qa/tools/initialize_gitlab_auth.rb
+1
-1
qa/spec/spec_helper.rb
qa/spec/spec_helper.rb
+1
-0
No files found.
qa/Gemfile
View file @
32da5296
...
@@ -20,6 +20,7 @@ gem 'parallel_tests', '~> 2.29'
...
@@ -20,6 +20,7 @@ gem 'parallel_tests', '~> 2.29'
gem
'rotp'
,
'~> 3.1.0'
gem
'rotp'
,
'~> 3.1.0'
gem
'timecop'
,
'~> 0.9.1'
gem
'timecop'
,
'~> 0.9.1'
gem
'parallel'
,
'~> 1.19'
gem
'parallel'
,
'~> 1.19'
gem
'rainbow'
,
'~> 3.0.0'
gem
'rspec-parameterized'
,
'~> 0.4.2'
gem
'rspec-parameterized'
,
'~> 0.4.2'
gem
'octokit'
,
'~> 4.21'
gem
'octokit'
,
'~> 4.21'
gem
'webdrivers'
,
'~> 5.0'
gem
'webdrivers'
,
'~> 5.0'
...
...
qa/qa/resource/base.rb
View file @
32da5296
...
@@ -8,6 +8,7 @@ module QA
...
@@ -8,6 +8,7 @@ module QA
class
Base
class
Base
include
ApiFabricator
include
ApiFabricator
extend
Capybara
::
DSL
extend
Capybara
::
DSL
using
Rainbow
NoValueError
=
Class
.
new
(
RuntimeError
)
NoValueError
=
Class
.
new
(
RuntimeError
)
...
@@ -102,7 +103,7 @@ module QA
...
@@ -102,7 +103,7 @@ module QA
Runtime
::
Logger
.
debug
do
Runtime
::
Logger
.
debug
do
msg
=
[
"==
#{
'='
*
parents
.
size
}
>"
]
msg
=
[
"==
#{
'='
*
parents
.
size
}
>"
]
msg
<<
"
#{
fabrication_http_method
}
a
#{
name
}
"
msg
<<
"
#{
fabrication_http_method
}
a
#{
Rainbow
(
name
).
black
.
bg
(
:white
)
}
"
msg
<<
identifier
msg
<<
identifier
msg
<<
"as a dependency of
#{
parents
.
last
}
"
if
parents
.
any?
msg
<<
"as a dependency of
#{
parents
.
last
}
"
if
parents
.
any?
msg
<<
"via
#{
fabrication_method
}
"
msg
<<
"via
#{
fabrication_method
}
"
...
@@ -182,7 +183,7 @@ module QA
...
@@ -182,7 +183,7 @@ module QA
end
end
def
visit!
(
skip_resp_code_check:
false
)
def
visit!
(
skip_resp_code_check:
false
)
Runtime
::
Logger
.
debug
(
%(Visiting #{self.class.name} at "#{web_url}")
)
Runtime
::
Logger
.
debug
(
"Visiting
#{
Rainbow
(
self
.
class
.
name
).
black
.
bg
(
:white
)
}
at
#{
web_url
}
"
)
# Just in case an async action is not yet complete
# Just in case an async action is not yet complete
Support
::
WaitForRequests
.
wait_for_requests
(
skip_resp_code_check:
skip_resp_code_check
)
Support
::
WaitForRequests
.
wait_for_requests
(
skip_resp_code_check:
skip_resp_code_check
)
...
...
qa/qa/resource/clusters/agent.rb
View file @
32da5296
...
@@ -17,7 +17,6 @@ module QA
...
@@ -17,7 +17,6 @@ module QA
end
end
def
fabricate!
def
fabricate!
puts
'TODO: FABRICATE VIA UI'
end
end
def
resource_web_url
(
resource
)
def
resource_web_url
(
resource
)
...
...
qa/qa/resource/clusters/agent_token.rb
View file @
32da5296
...
@@ -11,7 +11,6 @@ module QA
...
@@ -11,7 +11,6 @@ module QA
end
end
def
fabricate!
def
fabricate!
puts
'TODO: FABRICATE VIA UI'
end
end
def
resource_web_url
(
resource
)
def
resource_web_url
(
resource
)
...
...
qa/qa/runtime/env.rb
View file @
32da5296
...
@@ -65,6 +65,10 @@ module QA
...
@@ -65,6 +65,10 @@ module QA
ENV
[
'QA_LOG_PATH'
]
||
$stdout
ENV
[
'QA_LOG_PATH'
]
||
$stdout
end
end
def
colorized_logs?
enabled?
(
ENV
[
'COLORIZED_LOGS'
],
default:
false
)
end
# set to 'false' to have the browser run visibly instead of headless
# set to 'false' to have the browser run visibly instead of headless
def
webdriver_headless?
def
webdriver_headless?
if
ENV
.
key?
(
'CHROME_HEADLESS'
)
if
ENV
.
key?
(
'CHROME_HEADLESS'
)
...
...
qa/qa/runtime/logger.rb
View file @
32da5296
...
@@ -2,11 +2,13 @@
...
@@ -2,11 +2,13 @@
require
'logger'
require
'logger'
require
'forwardable'
require
'forwardable'
require
'rainbow/refinement'
module
QA
module
QA
module
Runtime
module
Runtime
module
Logger
module
Logger
extend
SingleForwardable
extend
SingleForwardable
using
Rainbow
def_delegators
:logger
,
:debug
,
:info
,
:warn
,
:error
,
:fatal
,
:unknown
def_delegators
:logger
,
:debug
,
:info
,
:warn
,
:error
,
:fatal
,
:unknown
...
@@ -14,8 +16,16 @@ module QA
...
@@ -14,8 +16,16 @@ module QA
attr_writer
:logger
attr_writer
:logger
def
logger
def
logger
Rainbow
.
enabled
=
Runtime
::
Env
.
colorized_logs?
@logger
||=
::
Logger
.
new
(
Runtime
::
Env
.
log_destination
).
tap
do
|
logger
|
@logger
||=
::
Logger
.
new
(
Runtime
::
Env
.
log_destination
).
tap
do
|
logger
|
logger
.
level
=
Runtime
::
Env
.
debug?
?
::
Logger
::
DEBUG
:
::
Logger
::
ERROR
logger
.
level
=
Runtime
::
Env
.
debug?
?
::
Logger
::
DEBUG
:
::
Logger
::
ERROR
logger
.
formatter
=
proc
do
|
severity
,
datetime
,
progname
,
msg
|
date_format
=
datetime
.
strftime
(
"%Y-%m-%d %H:%M:%S"
)
"[date=
#{
date_format
}
from=QA Tests]
#{
severity
.
ljust
(
5
)
}
-- "
.
yellow
+
"
#{
msg
}
\n
"
end
end
end
end
end
end
end
...
...
qa/qa/service/cluster_provider/gcloud.rb
View file @
32da5296
...
@@ -49,7 +49,7 @@ module QA
...
@@ -49,7 +49,7 @@ module QA
if
account
.
empty?
if
account
.
empty?
raise
"Failed to login to gcloud. No credentials provided in environment and no credentials found locally."
raise
"Failed to login to gcloud. No credentials provided in environment and no credentials found locally."
else
else
puts
"gcloud account found. Using:
#{
account
}
for creating K8s cluster."
QA
::
Runtime
::
Logger
.
debug
(
"gcloud account found. Using:
#{
account
}
for creating K8s cluster."
)
end
end
end
end
end
end
...
...
qa/qa/service/shellout.rb
View file @
32da5296
...
@@ -5,6 +5,7 @@ require 'open3'
...
@@ -5,6 +5,7 @@ require 'open3'
module
QA
module
QA
module
Service
module
Service
module
Shellout
module
Shellout
using
Rainbow
CommandError
=
Class
.
new
(
StandardError
)
CommandError
=
Class
.
new
(
StandardError
)
module_function
module_function
...
@@ -14,7 +15,7 @@ module QA
...
@@ -14,7 +15,7 @@ module QA
# as a library - gitlab-org/gitlab-qa#94
# as a library - gitlab-org/gitlab-qa#94
#
#
def
shell
(
command
,
stdin_data:
nil
,
fail_on_exception:
true
)
def
shell
(
command
,
stdin_data:
nil
,
fail_on_exception:
true
)
puts
"Executing `
#{
command
}
`"
QA
::
Runtime
::
Logger
.
info
(
"Executing `
#{
command
}
`"
.
cyan
)
Open3
.
popen2e
(
*
command
)
do
|
stdin
,
out
,
wait
|
Open3
.
popen2e
(
*
command
)
do
|
stdin
,
out
,
wait
|
stdin
.
puts
(
stdin_data
)
if
stdin_data
stdin
.
puts
(
stdin_data
)
if
stdin_data
...
...
qa/qa/support/page/logging.rb
View file @
32da5296
...
@@ -4,6 +4,8 @@ module QA
...
@@ -4,6 +4,8 @@ module QA
module
Support
module
Support
module
Page
module
Page
module
Logging
module
Logging
using
Rainbow
def
assert_no_element
(
name
)
def
assert_no_element
(
name
)
log
(
"asserting no element :
#{
name
}
"
)
log
(
"asserting no element :
#{
name
}
"
)
...
@@ -17,7 +19,7 @@ module QA
...
@@ -17,7 +19,7 @@ module QA
end
end
def
scroll_to
(
selector
,
text:
nil
)
def
scroll_to
(
selector
,
text:
nil
)
msg
=
"scrolling to :
#{
selector
}
"
msg
=
"scrolling to :
#{
Rainbow
(
selector
).
underline
.
bright
}
"
msg
+=
" with text:
#{
text
}
"
if
text
msg
+=
" with text:
#{
text
}
"
if
text
log
(
msg
)
log
(
msg
)
...
@@ -37,7 +39,7 @@ module QA
...
@@ -37,7 +39,7 @@ module QA
element
=
super
element
=
super
log
(
"found :
#{
name
}
"
)
if
element
log
(
"found :
#{
Rainbow
(
name
).
underline
.
bright
}
"
)
element
element
end
end
...
@@ -47,7 +49,7 @@ module QA
...
@@ -47,7 +49,7 @@ module QA
elements
=
super
elements
=
super
log
(
"found
#{
elements
.
size
}
:
#{
name
}
"
)
if
elements
log
(
"found
#{
elements
.
size
}
:
#{
Rainbow
(
name
).
underline
.
bright
}
"
)
if
elements
elements
elements
end
end
...
@@ -71,7 +73,7 @@ module QA
...
@@ -71,7 +73,7 @@ module QA
end
end
def
click_element
(
name
,
page
=
nil
,
**
kwargs
)
def
click_element
(
name
,
page
=
nil
,
**
kwargs
)
msg
=
[
"clicking :
#{
name
}
"
]
msg
=
[
"clicking :
#{
Rainbow
(
name
).
underline
.
bright
}
"
]
msg
<<
", expecting to be at
#{
page
.
class
}
"
if
page
msg
<<
", expecting to be at
#{
page
.
class
}
"
if
page
msg
<<
"with args
#{
kwargs
}
"
msg
<<
"with args
#{
kwargs
}
"
...
@@ -170,7 +172,7 @@ module QA
...
@@ -170,7 +172,7 @@ module QA
end
end
def
log_has_element_or_not
(
method
,
name
,
found
,
**
kwargs
)
def
log_has_element_or_not
(
method
,
name
,
found
,
**
kwargs
)
msg
=
[
"
#{
method
}
:
#{
name
}
"
]
msg
=
[
"
#{
method
}
:
#{
Rainbow
(
name
).
underline
.
bright
}
"
]
msg
<<
%Q(with text "
#{
kwargs
[
:text
]
}
")
if
kwargs
[
:text
]
msg
<<
%Q(with text "
#{
kwargs
[
:text
]
}
")
if
kwargs
[
:text
]
msg
<<
"class:
#{
kwargs
[
:class
]
}
"
if
kwargs
[
:class
]
msg
<<
"class:
#{
kwargs
[
:class
]
}
"
if
kwargs
[
:class
]
msg
<<
"(wait:
#{
kwargs
[
:wait
]
||
Capybara
.
default_max_wait_time
}
)"
msg
<<
"(wait:
#{
kwargs
[
:wait
]
||
Capybara
.
default_max_wait_time
}
)"
...
...
qa/qa/support/repeater.rb
View file @
32da5296
# frozen_string_literal: true
# frozen_string_literal: true
require
'active_support/inflector'
require
'active_support/inflector'
require
'rainbow/refinement'
module
QA
module
QA
module
Support
module
Support
module
Repeater
module
Repeater
using
Rainbow
DEFAULT_MAX_WAIT_TIME
=
60
DEFAULT_MAX_WAIT_TIME
=
60
RepeaterConditionExceededError
=
Class
.
new
(
RuntimeError
)
RepeaterConditionExceededError
=
Class
.
new
(
RuntimeError
)
...
@@ -39,7 +40,7 @@ module QA
...
@@ -39,7 +40,7 @@ module QA
QA
::
Runtime
::
Logger
.
debug
(
msg
.
join
(
' '
))
QA
::
Runtime
::
Logger
.
debug
(
msg
.
join
(
' '
))
end
end
QA
::
Runtime
::
Logger
.
debug
(
"Attempt number
#{
attempts
+
1
}
"
)
if
log
&&
max_attempts
&&
attempts
>
0
QA
::
Runtime
::
Logger
.
debug
(
"Attempt number
#{
attempts
+
1
}
"
.
bg
(
:yellow
).
black
)
if
log
&&
max_attempts
&&
attempts
>
0
result
=
yield
result
=
yield
if
result
if
result
...
...
qa/qa/tools/initialize_gitlab_auth.rb
View file @
32da5296
...
@@ -16,7 +16,7 @@ module QA
...
@@ -16,7 +16,7 @@ module QA
def
run
def
run
Runtime
::
Scenario
.
define
(
:gitlab_address
,
address
)
Runtime
::
Scenario
.
define
(
:gitlab_address
,
address
)
puts
"Signing in and creating the default password for the root user if it's not set already..."
QA
::
Runtime
::
Logger
.
info
(
"Signing in and creating the default password for the root user if it's not set already..."
)
QA
::
Runtime
::
Browser
.
visit
(
:gitlab
,
QA
::
Page
::
Main
::
Login
)
QA
::
Runtime
::
Browser
.
visit
(
:gitlab
,
QA
::
Page
::
Main
::
Login
)
Flow
::
Login
.
sign_in
Flow
::
Login
.
sign_in
...
...
qa/spec/spec_helper.rb
View file @
32da5296
...
@@ -6,6 +6,7 @@ require 'securerandom'
...
@@ -6,6 +6,7 @@ require 'securerandom'
require
'pathname'
require
'pathname'
require
'active_support/core_ext/hash'
require
'active_support/core_ext/hash'
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/object/blank'
require
'rainbow/refinement'
require_relative
'qa_deprecation_toolkit_env'
require_relative
'qa_deprecation_toolkit_env'
QaDeprecationToolkitEnv
.
configure!
QaDeprecationToolkitEnv
.
configure!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment