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
3a76b0fd
Commit
3a76b0fd
authored
Sep 13, 2019
by
Sanad Liaquat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure flags are set properly
Also adds unit tests for Runtime::Feature.enabled?
parent
a4dbeeb0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
8 deletions
+42
-8
qa/qa/runtime/feature.rb
qa/qa/runtime/feature.rb
+11
-0
qa/qa/specs/features/ee/browser_ui/1_manage/group/group_saml_sso_spec.rb
...tures/ee/browser_ui/1_manage/group/group_saml_sso_spec.rb
+7
-4
qa/qa/support/retrier.rb
qa/qa/support/retrier.rb
+6
-1
qa/spec/runtime/feature_spec.rb
qa/spec/runtime/feature_spec.rb
+18
-3
No files found.
qa/qa/runtime/feature.rb
View file @
3a76b0fd
...
...
@@ -18,6 +18,11 @@ module QA
set_feature
(
key
,
false
)
end
def
enabled?
(
key
)
feature
=
JSON
.
parse
(
get_features
).
find
{
|
flag
|
flag
[
"name"
]
==
key
}
feature
&&
feature
[
"state"
]
==
"on"
end
private
def
api_client
...
...
@@ -31,6 +36,12 @@ module QA
raise
SetFeatureError
,
"Setting feature flag
#{
key
}
to
#{
value
}
failed with `
#{
response
}
`."
end
end
def
get_features
request
=
Runtime
::
API
::
Request
.
new
(
api_client
,
"/features"
)
response
=
get
(
request
.
url
)
response
.
body
end
end
end
end
qa/qa/specs/features/ee/browser_ui/1_manage/group/group_saml_sso_spec.rb
View file @
3a76b0fd
...
...
@@ -60,11 +60,14 @@ module QA
expect
(
page
).
to
have_content
(
"Test SAML SSO"
)
end
# Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/129
context
'Enforced SSO'
,
:quarantine
do
context
'Enforced SSO'
do
before
do
Runtime
::
Feature
.
enable
(
"enforced_sso"
)
Runtime
::
Feature
.
enable
(
"enforced_sso_requires_session"
)
%w[enforced_sso enforced_sso_requires_session]
.
each
do
|
flag
|
QA
::
Support
::
Retrier
.
retry_until
(
exit_on_failure:
true
)
do
Runtime
::
Feature
.
enable
(
flag
)
Runtime
::
Feature
.
enabled?
(
flag
)
end
end
end
it
'user clones and pushes to project within a group using Git HTTP'
do
...
...
qa/qa/support/retrier.rb
View file @
3a76b0fd
...
...
@@ -24,7 +24,7 @@ module QA
end
end
def
retry_until
(
max_attempts:
3
,
reload_page:
nil
,
sleep_interval:
0
)
def
retry_until
(
max_attempts:
3
,
reload_page:
nil
,
sleep_interval:
0
,
exit_on_failure:
false
)
QA
::
Runtime
::
Logger
.
debug
(
"with retry_until: max_attempts
#{
max_attempts
}
; sleep_interval
#{
sleep_interval
}
; reload_page:
#{
reload_page
}
"
)
attempts
=
0
...
...
@@ -40,6 +40,11 @@ module QA
attempts
+=
1
end
if
exit_on_failure
QA
::
Runtime
::
Logger
.
debug
(
"Raising exception after
#{
max_attempts
}
attempts"
)
raise
end
false
end
end
...
...
qa/spec/runtime/feature_spec.rb
View file @
3a76b0fd
...
...
@@ -3,7 +3,8 @@
describe
QA
::
Runtime
::
Feature
do
let
(
:api_client
)
{
double
(
'QA::Runtime::API::Client'
)
}
let
(
:request
)
{
Struct
.
new
(
:url
).
new
(
'http://api'
)
}
let
(
:response
)
{
Struct
.
new
(
:code
).
new
(
201
)
}
let
(
:response_post
)
{
Struct
.
new
(
:code
).
new
(
201
)
}
let
(
:response_get
)
{
Struct
.
new
(
:code
,
:body
).
new
(
200
,
'[{ "name": "a-flag", "state": "on" }]'
)
}
before
do
allow
(
described_class
).
to
receive
(
:api_client
).
and_return
(
api_client
)
...
...
@@ -18,7 +19,7 @@ describe QA::Runtime::Feature do
expect
(
described_class
)
.
to
receive
(
:post
)
.
with
(
request
.
url
,
{
value:
true
})
.
and_return
(
response
)
.
and_return
(
response
_post
)
subject
.
enable
(
'a-flag'
)
end
...
...
@@ -33,9 +34,23 @@ describe QA::Runtime::Feature do
expect
(
described_class
)
.
to
receive
(
:post
)
.
with
(
request
.
url
,
{
value:
false
})
.
and_return
(
response
)
.
and_return
(
response
_post
)
subject
.
disable
(
'a-flag'
)
end
end
describe
'.enabled?'
do
it
'returns a feature flag state'
do
expect
(
QA
::
Runtime
::
API
::
Request
)
.
to
receive
(
:new
)
.
with
(
api_client
,
"/features"
)
.
and_return
(
request
)
expect
(
described_class
)
.
to
receive
(
:get
)
.
and_return
(
response_get
)
expect
(
subject
.
enabled?
(
'a-flag'
)).
to
be_truthy
end
end
end
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