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'
gem
'rotp'
,
'~> 3.1.0'
gem
'timecop'
,
'~> 0.9.1'
gem
'parallel'
,
'~> 1.19'
gem
'rainbow'
,
'~> 3.0.0'
gem
'rspec-parameterized'
,
'~> 0.4.2'
gem
'octokit'
,
'~> 4.21'
gem
'webdrivers'
,
'~> 5.0'
...
...
qa/qa/resource/base.rb
View file @
32da5296
...
...
@@ -8,6 +8,7 @@ module QA
class
Base
include
ApiFabricator
extend
Capybara
::
DSL
using
Rainbow
NoValueError
=
Class
.
new
(
RuntimeError
)
...
...
@@ -102,7 +103,7 @@ module QA
Runtime
::
Logger
.
debug
do
msg
=
[
"==
#{
'='
*
parents
.
size
}
>"
]
msg
<<
"
#{
fabrication_http_method
}
a
#{
name
}
"
msg
<<
"
#{
fabrication_http_method
}
a
#{
Rainbow
(
name
).
black
.
bg
(
:white
)
}
"
msg
<<
identifier
msg
<<
"as a dependency of
#{
parents
.
last
}
"
if
parents
.
any?
msg
<<
"via
#{
fabrication_method
}
"
...
...
@@ -182,7 +183,7 @@ module QA
end
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
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
end
def
fabricate!
puts
'TODO: FABRICATE VIA UI'
end
def
resource_web_url
(
resource
)
...
...
qa/qa/resource/clusters/agent_token.rb
View file @
32da5296
...
...
@@ -11,7 +11,6 @@ module QA
end
def
fabricate!
puts
'TODO: FABRICATE VIA UI'
end
def
resource_web_url
(
resource
)
...
...
qa/qa/runtime/env.rb
View file @
32da5296
...
...
@@ -65,6 +65,10 @@ module QA
ENV
[
'QA_LOG_PATH'
]
||
$stdout
end
def
colorized_logs?
enabled?
(
ENV
[
'COLORIZED_LOGS'
],
default:
false
)
end
# set to 'false' to have the browser run visibly instead of headless
def
webdriver_headless?
if
ENV
.
key?
(
'CHROME_HEADLESS'
)
...
...
qa/qa/runtime/logger.rb
View file @
32da5296
...
...
@@ -2,11 +2,13 @@
require
'logger'
require
'forwardable'
require
'rainbow/refinement'
module
QA
module
Runtime
module
Logger
extend
SingleForwardable
using
Rainbow
def_delegators
:logger
,
:debug
,
:info
,
:warn
,
:error
,
:fatal
,
:unknown
...
...
@@ -14,8 +16,16 @@ module QA
attr_writer
:logger
def
logger
Rainbow
.
enabled
=
Runtime
::
Env
.
colorized_logs?
@logger
||=
::
Logger
.
new
(
Runtime
::
Env
.
log_destination
).
tap
do
|
logger
|
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
...
...
qa/qa/service/cluster_provider/gcloud.rb
View file @
32da5296
...
...
@@ -49,7 +49,7 @@ module QA
if
account
.
empty?
raise
"Failed to login to gcloud. No credentials provided in environment and no credentials found locally."
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
...
...
qa/qa/service/shellout.rb
View file @
32da5296
...
...
@@ -5,6 +5,7 @@ require 'open3'
module
QA
module
Service
module
Shellout
using
Rainbow
CommandError
=
Class
.
new
(
StandardError
)
module_function
...
...
@@ -14,7 +15,7 @@ module QA
# as a library - gitlab-org/gitlab-qa#94
#
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
|
stdin
.
puts
(
stdin_data
)
if
stdin_data
...
...
qa/qa/support/page/logging.rb
View file @
32da5296
...
...
@@ -4,6 +4,8 @@ module QA
module
Support
module
Page
module
Logging
using
Rainbow
def
assert_no_element
(
name
)
log
(
"asserting no element :
#{
name
}
"
)
...
...
@@ -17,7 +19,7 @@ module QA
end
def
scroll_to
(
selector
,
text:
nil
)
msg
=
"scrolling to :
#{
selector
}
"
msg
=
"scrolling to :
#{
Rainbow
(
selector
).
underline
.
bright
}
"
msg
+=
" with text:
#{
text
}
"
if
text
log
(
msg
)
...
...
@@ -37,7 +39,7 @@ module QA
element
=
super
log
(
"found :
#{
name
}
"
)
if
element
log
(
"found :
#{
Rainbow
(
name
).
underline
.
bright
}
"
)
element
end
...
...
@@ -47,7 +49,7 @@ module QA
elements
=
super
log
(
"found
#{
elements
.
size
}
:
#{
name
}
"
)
if
elements
log
(
"found
#{
elements
.
size
}
:
#{
Rainbow
(
name
).
underline
.
bright
}
"
)
if
elements
elements
end
...
...
@@ -71,7 +73,7 @@ module QA
end
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
<<
"with args
#{
kwargs
}
"
...
...
@@ -170,7 +172,7 @@ module QA
end
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
<<
"class:
#{
kwargs
[
:class
]
}
"
if
kwargs
[
:class
]
msg
<<
"(wait:
#{
kwargs
[
:wait
]
||
Capybara
.
default_max_wait_time
}
)"
...
...
qa/qa/support/repeater.rb
View file @
32da5296
# frozen_string_literal: true
require
'active_support/inflector'
require
'rainbow/refinement'
module
QA
module
Support
module
Repeater
using
Rainbow
DEFAULT_MAX_WAIT_TIME
=
60
RepeaterConditionExceededError
=
Class
.
new
(
RuntimeError
)
...
...
@@ -39,7 +40,7 @@ module QA
QA
::
Runtime
::
Logger
.
debug
(
msg
.
join
(
' '
))
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
if
result
...
...
qa/qa/tools/initialize_gitlab_auth.rb
View file @
32da5296
...
...
@@ -16,7 +16,7 @@ module QA
def
run
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
)
Flow
::
Login
.
sign_in
...
...
qa/spec/spec_helper.rb
View file @
32da5296
...
...
@@ -6,6 +6,7 @@ require 'securerandom'
require
'pathname'
require
'active_support/core_ext/hash'
require
'active_support/core_ext/object/blank'
require
'rainbow/refinement'
require_relative
'qa_deprecation_toolkit_env'
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