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
48d8bdca
Commit
48d8bdca
authored
Jan 19, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abstract EE code from CE codebase
parent
fb08198b
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
129 additions
and
119 deletions
+129
-119
app/controllers/groups/pipeline_quota_controller.rb
app/controllers/groups/pipeline_quota_controller.rb
+1
-1
app/models/application_setting.rb
app/models/application_setting.rb
+1
-3
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ee/namespace.rb
app/models/ee/namespace.rb
+4
-4
app/models/ee/project.rb
app/models/ee/project.rb
+9
-11
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/namespace_statistics.rb
app/models/namespace_statistics.rb
+1
-1
app/models/project.rb
app/models/project.rb
+8
-4
app/services/ci/register_build_service.rb
app/services/ci/register_build_service.rb
+2
-26
app/services/ee/ci/register_build_service.rb
app/services/ee/ci/register_build_service.rb
+36
-0
app/services/update_build_minutes_service.rb
app/services/update_build_minutes_service.rb
+7
-7
app/workers/clear_shared_runners_minutes_worker.rb
app/workers/clear_shared_runners_minutes_worker.rb
+1
-1
db/migrate/20161202152038_create_table_namespace_metrics.rb
db/migrate/20161202152038_create_table_namespace_metrics.rb
+0
-15
db/migrate/20161202152038_create_table_namespace_statistics.rb
...grate/20161202152038_create_table_namespace_statistics.rb
+3
-5
db/migrate/20161202152039_add_shared_runners_minutes_to_project_statistics.rb
...52039_add_shared_runners_minutes_to_project_statistics.rb
+11
-0
db/migrate/20161202152040_add_index_to_namespace_metrics.rb
db/migrate/20161202152040_add_index_to_namespace_metrics.rb
+0
-11
db/migrate/20161202152041_add_index_to_project_metrics.rb
db/migrate/20161202152041_add_index_to_project_metrics.rb
+0
-11
db/schema.rb
db/schema.rb
+3
-3
lib/active_support/prependable.rb
lib/active_support/prependable.rb
+26
-0
spec/factories/namespace_metrics.rb
spec/factories/namespace_metrics.rb
+1
-1
spec/factories/namespaces.rb
spec/factories/namespaces.rb
+3
-3
spec/models/ee/namespace_spec.rb
spec/models/ee/namespace_spec.rb
+3
-3
spec/models/namespace_statistics_spec.rb
spec/models/namespace_statistics_spec.rb
+1
-1
spec/services/update_build_minutes_service_spec.rb
spec/services/update_build_minutes_service_spec.rb
+3
-3
spec/workers/clear_shared_runners_minutes_worker_spec.rb
spec/workers/clear_shared_runners_minutes_worker_spec.rb
+3
-3
No files found.
app/controllers/groups/pipeline_quota_controller.rb
View file @
48d8bdca
...
...
@@ -4,6 +4,6 @@ class Groups::PipelineQuotaController < Groups::ApplicationController
layout
'group_settings'
def
index
@projects
=
@group
.
projects
.
with_shared_runners
.
page
(
params
[
:page
])
@projects
=
@group
.
projects
.
with_shared_runners
_limit_enabled
.
page
(
params
[
:page
])
end
end
app/models/application_setting.rb
View file @
48d8bdca
class
ApplicationSetting
<
ActiveRecord
::
Base
include
CacheMarkdownField
include
TokenAuthenticatable
prepend
EE
::
ApplicationSetting
add_authentication_token_field
:runners_registration_token
add_authentication_token_field
:health_check_access_token
...
...
@@ -123,9 +124,6 @@ class ApplicationSetting < ActiveRecord::Base
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than: :housekeeping_full_repack_period
}
validates
:shared_runners_minutes
,
numericality:
{
greater_than_or_equal_to:
0
}
validates_each
:restricted_visibility_levels
do
|
record
,
attr
,
value
|
unless
value
.
nil?
value
.
each
do
|
level
|
...
...
app/models/ci/build.rb
View file @
48d8bdca
...
...
@@ -2,7 +2,7 @@ module Ci
class
Build
<
CommitStatus
include
TokenAuthenticatable
include
AfterCommitQueue
include
EE
::
Build
prepend
EE
::
Build
belongs_to
:runner
belongs_to
:trigger_request
...
...
app/models/ee/namespace.rb
View file @
48d8bdca
...
...
@@ -4,13 +4,13 @@ module EE
# This module is intended to encapsulate EE-specific model logic
# and be included in the `Namespace` model
module
Namespace
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Prependable
inclu
ded
do
has_one
:namespace_
metr
ics
,
dependent: :destroy
prepen
ded
do
has_one
:namespace_
statist
ics
,
dependent: :destroy
delegate
:shared_runners_minutes
,
:shared_runners_minutes_last_reset
,
to: :namespace_
metr
ics
,
allow_nil:
true
to: :namespace_
statist
ics
,
allow_nil:
true
end
def
actual_shared_runners_minutes_limit
...
...
app/models/ee/project.rb
View file @
48d8bdca
...
...
@@ -4,11 +4,13 @@ module EE
# This module is intended to encapsulate EE-specific model logic
# and be included in the `Project` model
module
Project
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Prependable
prepended
do
scope
:with_shared_runners_limit_enabled
,
->
{
with_shared_runners
.
non_public_only
}
included
do
delegate
:shared_runners_minutes
,
:shared_runners_minutes_last_reset
,
to: :project_
metr
ics
,
allow_nil:
true
to: :project_
statist
ics
,
allow_nil:
true
delegate
:actual_shared_runners_minutes_limit
,
:shared_runners_minutes_used?
,
to: :namespace
...
...
@@ -16,16 +18,12 @@ module EE
has_one
:project_metrics
,
dependent: :destroy
end
def
shared_runners_
minutes_limit_enabled
?
!
public
?
&&
shared_runners_enabled?
&&
namespace
.
shared_runners_minutes_limit_enabl
ed?
def
shared_runners_
available
?
super
&&
!
namespace
.
shared_runners_minutes_us
ed?
end
def
shared_runners
if
shared_runners_enabled?
&&
!
namespace
.
shared_runners_minutes_used?
Ci
::
Runner
.
shared
else
Ci
::
Runner
.
none
end
def
shared_runners_minutes_limit_enabled?
!
public
?
&&
shared_runners_enabled?
&&
namespace
.
shared_runners_minutes_limit_enabled?
end
end
end
app/models/namespace.rb
View file @
48d8bdca
class
Namespace
<
ActiveRecord
::
Base
acts_as_paranoid
include
EE
::
Namespace
prepend
EE
::
Namespace
include
CacheMarkdownField
include
Sortable
include
Gitlab
::
ShellAdapter
...
...
app/models/namespace_
metr
ics.rb
→
app/models/namespace_
statist
ics.rb
View file @
48d8bdca
class
Namespace
Metr
ics
<
ActiveRecord
::
Base
class
Namespace
Statist
ics
<
ActiveRecord
::
Base
belongs_to
:namespace
validates
:namespace
,
presence:
true
...
...
app/models/project.rb
View file @
48d8bdca
...
...
@@ -18,7 +18,7 @@ class Project < ActiveRecord::Base
include
SelectForProjectAuthorization
include
Routable
prepend
EE
::
GeoAwareAvatar
include
EE
::
Project
prepend
EE
::
Project
extend
Gitlab
::
ConfigHelper
...
...
@@ -246,7 +246,7 @@ class Project < ActiveRecord::Base
scope
:with_project_feature
,
->
{
joins
(
'LEFT JOIN project_features ON projects.id = project_features.project_id'
)
}
scope
:with_statistics
,
->
{
includes
(
:statistics
)
}
scope
:with_shared_runners
_limit_enabled
,
->
{
where
(
shared_runners_enabled:
true
).
non_public_only
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
# "enabled" here means "not disabled". It includes private features!
scope
:with_feature_enabled
,
->
(
feature
)
{
...
...
@@ -1241,9 +1241,13 @@ class Project < ActiveRecord::Base
project_feature
.
update_attribute
(
:builds_access_level
,
ProjectFeature
::
ENABLED
)
end
def
shared_runners_available?
shared_runners_enabled?
end
def
shared_runners
shared_runners_
enabled
?
?
Ci
::
Runner
.
shared
:
Ci
::
Runner
.
none
end
unless
defined?
(
:shared_runners
)
shared_runners_
available
?
?
Ci
::
Runner
.
shared
:
Ci
::
Runner
.
none
end
def
any_runners?
(
&
block
)
if
runners
.
active
.
any?
(
&
block
)
...
...
app/services/ci/register_build_service.rb
View file @
48d8bdca
...
...
@@ -3,6 +3,7 @@ module Ci
# proper pending build to runner on runner API request
class
RegisterBuildService
include
Gitlab
::
CurrentSettings
prepend
EE
::
Ci
::
RegisterBuildService
attr_reader
:runner
...
...
@@ -13,11 +14,7 @@ module Ci
def
execute
builds
=
if
runner
.
shared?
if
shared_runner_build_limits_feature_enabled?
builds_for_shared_runner_with_build_minutes_check
else
builds_for_shared_runner
end
builds_for_shared_runner
else
builds_for_specific_runner
end
...
...
@@ -41,13 +38,6 @@ module Ci
private
def
builds_for_shared_runner_with_build_minutes_check
# select projects which have allowed number of shared runner minutes or are public
builds_for_shared_runner
.
where
(
"projects.visibility_level=? OR (
#{
builds_check_limit
.
to_sql
}
)=1"
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
def
builds_for_shared_runner
new_builds
.
# don't run projects which have not enabled shared runners and builds
...
...
@@ -62,20 +52,6 @@ module Ci
order
(
'COALESCE(project_builds.running_builds, 0) ASC'
,
'ci_builds.id ASC'
)
end
def
builds_check_limit
Namespace
.
reorder
(
nil
).
where
(
"namespaces.id = projects.namespace_id"
).
joins
(
'LEFT JOIN namespace_metrics ON namespace_metrics.namespace_id = namespaces.id'
).
where
(
'COALESCE(namespaces.shared_runners_minutes_limit, ?, 0) = 0 OR '
\
'COALESCE(namespace_metrics.shared_runners_minutes, 0) < COALESCE(namespaces.shared_runners_minutes_limit, ?, 0)'
,
application_shared_runners_minutes
,
application_shared_runners_minutes
).
select
(
'1'
)
end
def
application_shared_runners_minutes
current_application_settings
.
shared_runners_minutes
end
def
builds_for_specific_runner
new_builds
.
where
(
project:
runner
.
projects
.
with_builds_enabled
).
order
(
'created_at ASC'
)
end
...
...
app/services/ee/ci/register_build_service.rb
0 → 100644
View file @
48d8bdca
module
EE
module
Ci
# This class responsible for assigning
# proper pending build to runner on runner API request
class
RegisterBuildService
extend
ActiveSupport
::
Prependable
def
builds_for_shared_runner
return
super
unless
shared_runner_build_limits_feature_enabled?
# select projects which have allowed number of shared runner minutes or are public
super
.
where
(
"projects.visibility_level=? OR (
#{
builds_check_limit
.
to_sql
}
)=1"
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
def
builds_check_limit
Namespace
.
reorder
(
nil
).
where
(
'namespaces.id = projects.namespace_id'
).
joins
(
'LEFT JOIN namespace_statistics ON namespace_statistics.namespace_id = namespaces.id'
).
where
(
'COALESCE(namespaces.shared_runners_minutes_limit, ?, 0) = 0 OR '
\
'COALESCE(namespace_statistics.shared_runners_minutes, 0) < COALESCE(namespaces.shared_runners_minutes_limit, ?, 0)'
,
application_shared_runners_minutes
,
application_shared_runners_minutes
).
select
(
'1'
)
end
def
application_shared_runners_minutes
current_application_settings
.
shared_runners_minutes
end
def
shared_runner_build_limits_feature_enabled?
ENV
[
'DISABLE_SHARED_RUNNER_BUILD_MINUTES_LIMIT'
].
to_s
!=
'true'
end
end
end
end
app/services/update_build_minutes_service.rb
View file @
48d8bdca
...
...
@@ -4,21 +4,21 @@ class UpdateBuildMinutesService < BaseService
return
unless
build
.
complete?
return
unless
build
.
duration
Project
Metrics
.
update_counters
(
project_metr
ics
,
Project
Statistics
.
update_counters
(
project
.
statist
ics
,
shared_runners_minutes:
build
.
duration
)
Namespace
Metrics
.
update_counters
(
namespace_metr
ics
,
shared_runners_minutes:
build
.
duration
)
Namespace
Statistics
.
update_counters
(
namespace_statist
ics
,
shared_runners_minutes:
build
.
duration
)
end
private
def
namespace_
metr
ics
namespace
.
namespace_
metrics
||
namespace
.
create_namespace_metr
ics
def
namespace_
statist
ics
namespace
.
namespace_
statistics
||
namespace
.
create_namespace_statist
ics
end
def
project_
metr
ics
project
.
project_metrics
||
project
.
create_project_metrics
def
project_
statist
ics
project
.
statistics
||
project
.
create_statistics
(
namespace:
namespace
)
end
def
namespace
...
...
app/workers/clear_shared_runners_minutes_worker.rb
View file @
48d8bdca
...
...
@@ -11,7 +11,7 @@ class ClearSharedRunnersMinutesWorker
shared_runners_minutes:
0
,
shared_runners_minutes_last_reset:
Time
.
now
)
Namespace
Metr
ics
.
update_all
(
Namespace
Statist
ics
.
update_all
(
shared_runners_minutes:
0
,
shared_runners_minutes_last_reset:
Time
.
now
)
end
...
...
db/migrate/20161202152038_create_table_namespace_metrics.rb
deleted
100644 → 0
View file @
fb08198b
class
CreateTableNamespaceMetrics
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
create_table
:namespace_metrics
do
|
t
|
t
.
integer
:namespace_id
,
null:
false
t
.
integer
:shared_runners_minutes
,
default:
0
,
null:
false
t
.
timestamp
:shared_runners_minutes_last_reset
end
add_foreign_key
:namespace_metrics
,
:namespaces
,
on_delete: :cascade
end
end
db/migrate/2016120215203
9_create_table_project_metr
ics.rb
→
db/migrate/2016120215203
8_create_table_namespace_statist
ics.rb
View file @
48d8bdca
class
CreateTable
ProjectMetr
ics
<
ActiveRecord
::
Migration
class
CreateTable
NamespaceStatist
ics
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
create_table
:
project_metr
ics
do
|
t
|
t
.
integer
:project_id
,
null:
false
create_table
:
namespace_statist
ics
do
|
t
|
t
.
references
:namespace
,
null:
false
,
index:
{
unique:
true
},
foreign_key:
{
on_delete: :cascade
}
t
.
integer
:shared_runners_minutes
,
default:
0
,
null:
false
t
.
timestamp
:shared_runners_minutes_last_reset
end
add_foreign_key
:project_metrics
,
:projects
,
on_delete: :cascade
end
end
db/migrate/20161202152039_add_shared_runners_minutes_to_project_statistics.rb
0 → 100644
View file @
48d8bdca
class
AddSharedRunnersMinutesToProjectStatistics
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
counter_column
=
{
limit:
8
,
null:
false
,
default:
0
}
add_column
:project_statistics
,
:shared_runners_minutes
,
:integer
,
counter_column
add_column
:project_statistics
,
:shared_runners_minutes_last_reset
,
:timestamp
end
end
db/migrate/20161202152040_add_index_to_namespace_metrics.rb
deleted
100644 → 0
View file @
fb08198b
class
AddIndexToNamespaceMetrics
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
change
add_concurrent_index
:namespace_metrics
,
[
:namespace_id
],
{
unique:
true
}
end
end
db/migrate/20161202152041_add_index_to_project_metrics.rb
deleted
100644 → 0
View file @
fb08198b
class
AddIndexToProjectMetrics
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
change
add_concurrent_index
:project_metrics
,
[
:project_id
],
{
unique:
true
}
end
end
db/schema.rb
View file @
48d8bdca
...
...
@@ -825,13 +825,13 @@ ActiveRecord::Schema.define(version: 20170106172224) do
add_index
"milestones"
,
[
"title"
],
name:
"index_milestones_on_title"
,
using: :btree
add_index
"milestones"
,
[
"title"
],
name:
"index_milestones_on_title_trigram"
,
using: :gin
,
opclasses:
{
"title"
=>
"gin_trgm_ops"
}
create_table
"namespace_
metr
ics"
,
force: :cascade
do
|
t
|
create_table
"namespace_
statist
ics"
,
force: :cascade
do
|
t
|
t
.
integer
"namespace_id"
,
null:
false
t
.
integer
"shared_runners_minutes"
,
default:
0
,
null:
false
t
.
datetime
"shared_runners_minutes_last_reset"
end
add_index
"namespace_
metr
ics"
,
[
"namespace_id"
],
name:
"index_namespace_metrics_on_namespace_id"
,
unique:
true
,
using: :btree
add_index
"namespace_
statist
ics"
,
[
"namespace_id"
],
name:
"index_namespace_metrics_on_namespace_id"
,
unique:
true
,
using: :btree
create_table
"namespaces"
,
force: :cascade
do
|
t
|
t
.
string
"name"
,
null:
false
...
...
@@ -1515,7 +1515,7 @@ ActiveRecord::Schema.define(version: 20170106172224) do
add_foreign_key
"merge_request_metrics"
,
"merge_requests"
,
on_delete: :cascade
add_foreign_key
"merge_requests_closing_issues"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"merge_requests_closing_issues"
,
"merge_requests"
,
on_delete: :cascade
add_foreign_key
"namespace_
metr
ics"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"namespace_
statist
ics"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"path_locks"
,
"projects"
add_foreign_key
"path_locks"
,
"users"
add_foreign_key
"personal_access_tokens"
,
"users"
...
...
lib/active_support/prependable.rb
0 → 100644
View file @
48d8bdca
# This module is based on: https://gist.github.com/bcardarella/5735987
module
ActiveSupport
module
Prependable
include
ActiveSupport
::
Concern
def
self
.
extended
(
base
)
#:nodoc:
base
.
instance_variable_set
(
:@_dependencies
,
[])
end
def
prepend_features
(
base
)
if
base
.
instance_variable_defined?
(
:@_dependencies
)
base
.
instance_variable_get
(
:@_dependencies
)
<<
self
return
false
else
return
false
if
base
<
self
super
base
.
singleton_class
.
send
(
:prepend
,
const_get
(
'ClassMethods'
))
if
const_defined?
(
:ClassMethods
)
@_dependencies
.
each
{
|
dep
|
base
.
send
(
:include
,
dep
)
}
base
.
class_eval
(
&
@_included_block
)
if
instance_variable_defined?
(
:@_included_block
)
end
end
alias_method
:prepended
,
:included
end
end
spec/factories/namespace_metrics.rb
View file @
48d8bdca
FactoryGirl
.
define
do
factory
:namespace_
metr
ics
do
factory
:namespace_
statist
ics
do
namespace
factory: :namespace
end
end
spec/factories/namespaces.rb
View file @
48d8bdca
...
...
@@ -5,7 +5,7 @@ FactoryGirl.define do
owner
trait
:with_build_minutes
do
namespace_
metrics
factory: :namespace_metr
ics
,
shared_runners_minutes:
400
namespace_
statistics
factory: :namespace_statist
ics
,
shared_runners_minutes:
400
end
trait
:with_build_minutes_limit
do
...
...
@@ -13,12 +13,12 @@ FactoryGirl.define do
end
trait
:with_not_used_build_minutes_limit
do
namespace_
metrics
factory: :namespace_metr
ics
,
shared_runners_minutes:
300
namespace_
statistics
factory: :namespace_statist
ics
,
shared_runners_minutes:
300
shared_runners_minutes_limit
500
end
trait
:with_used_build_minutes_limit
do
namespace_
metrics
factory: :namespace_metr
ics
,
shared_runners_minutes:
1000
namespace_
statistics
factory: :namespace_statist
ics
,
shared_runners_minutes:
1000
shared_runners_minutes_limit
500
end
end
...
...
spec/models/ee/namespace_spec.rb
View file @
48d8bdca
...
...
@@ -3,10 +3,10 @@ require 'spec_helper'
describe
Namespace
,
models:
true
do
let!
(
:namespace
)
{
create
(
:namespace
)
}
it
{
is_expected
.
to
have_one
(
:namespace_
metr
ics
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_one
(
:namespace_
statist
ics
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
delegate_method
(
:shared_runners_minutes
).
to
(
:namespace_
metr
ics
)
}
it
{
is_expected
.
to
delegate_method
(
:shared_runners_minutes_last_reset
).
to
(
:namespace_
metr
ics
)
}
it
{
is_expected
.
to
delegate_method
(
:shared_runners_minutes
).
to
(
:namespace_
statist
ics
)
}
it
{
is_expected
.
to
delegate_method
(
:shared_runners_minutes_last_reset
).
to
(
:namespace_
statist
ics
)
}
describe
'#shared_runners_enabled?'
do
subject
{
namespace
.
shared_runners_enabled?
}
...
...
spec/models/namespace_
metr
ics_spec.rb
→
spec/models/namespace_
statist
ics_spec.rb
View file @
48d8bdca
require
'spec_helper'
describe
Namespace
Metr
ics
,
models:
true
do
describe
Namespace
Statist
ics
,
models:
true
do
it
{
is_expected
.
to
belong_to
(
:namespace
)
}
it
{
is_expected
.
to
validate_presence_of
(
:namespace
)
}
...
...
spec/services/update_build_minutes_service_spec.rb
View file @
48d8bdca
...
...
@@ -22,7 +22,7 @@ describe UpdateBuildMinutesService, services: true do
expect
(
project
.
project_metrics
.
reload
.
shared_runners_minutes
).
to
eq
(
build
.
duration
.
to_i
)
expect
(
namespace
.
namespace_
metr
ics
.
reload
.
shared_runners_minutes
).
expect
(
namespace
.
namespace_
statist
ics
.
reload
.
shared_runners_minutes
).
to
eq
(
build
.
duration
.
to_i
)
end
...
...
@@ -38,7 +38,7 @@ describe UpdateBuildMinutesService, services: true do
expect
(
project
.
project_metrics
.
reload
.
shared_runners_minutes
).
to
eq
(
100
+
build
.
duration
.
to_i
)
expect
(
namespace
.
namespace_
metr
ics
.
reload
.
shared_runners_minutes
).
expect
(
namespace
.
namespace_
statist
ics
.
reload
.
shared_runners_minutes
).
to
eq
(
100
+
build
.
duration
.
to_i
)
end
end
...
...
@@ -51,7 +51,7 @@ describe UpdateBuildMinutesService, services: true do
subject
expect
(
project
.
project_metrics
).
to
be_nil
expect
(
namespace
.
namespace_
metr
ics
).
to
be_nil
expect
(
namespace
.
namespace_
statist
ics
).
to
be_nil
end
end
end
...
...
spec/workers/clear_shared_runners_minutes_worker_spec.rb
View file @
48d8bdca
...
...
@@ -28,18 +28,18 @@ describe ClearSharedRunnersMinutesWorker do
end
context
'when project metrics are defined'
do
let!
(
:namespace_
metrics
)
{
create
(
:namespace_metr
ics
,
shared_runners_minutes:
100
)
}
let!
(
:namespace_
statistics
)
{
create
(
:namespace_statist
ics
,
shared_runners_minutes:
100
)
}
it
'clears counters'
do
subject
expect
(
namespace_
metr
ics
.
reload
.
shared_runners_minutes
).
to
be_zero
expect
(
namespace_
statist
ics
.
reload
.
shared_runners_minutes
).
to
be_zero
end
it
'resets timer'
do
subject
expect
(
namespace_
metr
ics
.
reload
.
shared_runners_minutes_last_reset
).
to
be_like_time
(
Time
.
now
)
expect
(
namespace_
statist
ics
.
reload
.
shared_runners_minutes_last_reset
).
to
be_like_time
(
Time
.
now
)
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