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
82e244c6
Commit
82e244c6
authored
Aug 31, 2021
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refresh CI minutes cache after updating limits
parent
a24f1c03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
ee/lib/ee/api/namespaces.rb
ee/lib/ee/api/namespaces.rb
+4
-4
ee/spec/requests/api/namespaces_spec.rb
ee/spec/requests/api/namespaces_spec.rb
+30
-4
No files found.
ee/lib/ee/api/namespaces.rb
View file @
82e244c6
...
...
@@ -29,11 +29,11 @@ module EE
::
Ci
::
Runner
.
instance_type
.
each
(
&
:tick_runner_queue
)
end
if
params
[
:extra_shared_runners_minutes_limit
].
present?
||
params
[
:shared_runners_minutes_limit
].
present?
::
Ci
::
Minutes
::
RefreshCachedDataService
.
new
(
namespace
).
execute
namespace
.
update
(
update_attrs
).
tap
do
if
update_attrs
[
:extra_shared_runners_minutes_limit
].
present?
||
update_attrs
[
:shared_runners_minutes_limit
].
present?
::
Ci
::
Minutes
::
RefreshCachedDataService
.
new
(
namespace
).
execute
end
end
namespace
.
update
(
update_attrs
)
end
end
...
...
ee/spec/requests/api/namespaces_spec.rb
View file @
82e244c6
...
...
@@ -188,6 +188,10 @@ RSpec.describe API::Namespaces do
end
describe
'PUT /namespaces/:id'
do
let!
(
:namespace_statistics
)
do
create
(
:namespace_statistics
,
namespace:
group1
,
shared_runners_seconds:
1600
*
60
)
end
let
(
:params
)
do
{
shared_runners_minutes_limit:
9001
,
...
...
@@ -198,9 +202,12 @@ RSpec.describe API::Namespaces do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
group1
.
update!
(
shared_runners_minutes_limit:
1000
,
extra_shared_runners_minutes_limit:
500
)
end
context
'when authenticated as admin'
do
subject
{
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
params
}
it
'updates namespace using full_path when full_path contains dots'
do
put
api
(
"/namespaces/
#{
group1
.
full_path
}
"
,
admin
),
params:
params
...
...
@@ -213,7 +220,7 @@ RSpec.describe API::Namespaces do
end
it
'updates namespace using id'
do
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
params
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
params
[
:shared_runners_minutes_limit
])
...
...
@@ -224,7 +231,7 @@ RSpec.describe API::Namespaces do
it
'expires the CI minutes CachedQuota'
do
expect_next
(
Gitlab
::
Ci
::
Minutes
::
CachedQuota
).
to
receive
(
:expire!
)
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
params
subject
end
context
'when request has extra_shared_runners_minutes_limit param'
do
...
...
@@ -233,10 +240,29 @@ RSpec.describe API::Namespaces do
params
.
delete
(
:shared_runners_minutes_limit
)
end
it
'updates the extra shared runners minutes limit'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'extra_shared_runners_minutes_limit'
])
.
to
eq
(
params
[
:extra_shared_runners_minutes_limit
])
end
it
'expires the CI minutes CachedQuota'
do
expect_next
(
Gitlab
::
Ci
::
Minutes
::
CachedQuota
).
to
receive
(
:expire!
)
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
params
subject
end
it
'updates pending builds data since adding extra minutes the quota is not used up anymore'
do
minutes_exceeded
=
group1
.
ci_minutes_quota
.
minutes_used_up?
expect
(
minutes_exceeded
).
to
eq
(
true
)
pending_build
=
create
(
:ci_pending_build
,
namespace:
group1
,
minutes_exceeded:
minutes_exceeded
)
subject
expect
(
pending_build
.
reload
.
minutes_exceeded
).
to
eq
(
false
)
end
end
...
...
@@ -245,7 +271,7 @@ RSpec.describe API::Namespaces do
params
.
delete
(
:shared_runners_minutes_limit
)
expect
(
Gitlab
::
Ci
::
Minutes
::
CachedQuota
).
not_to
receive
(
:new
)
put
api
(
"/namespaces/
#{
group1
.
id
}
"
,
admin
),
params:
params
subject
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