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
85d0663b
Commit
85d0663b
authored
Mar 31, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added mock deployment and monitoring service with environments fixtures
parent
cf91b76a
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
121 additions
and
2 deletions
+121
-2
app/models/project.rb
app/models/project.rb
+2
-0
app/models/project_services/mock_deployment_service.rb
app/models/project_services/mock_deployment_service.rb
+19
-0
app/models/project_services/mock_monitoring_service.rb
app/models/project_services/mock_monitoring_service.rb
+17
-0
app/models/service.rb
app/models/service.rb
+3
-1
changelogs/unreleased/add-mock-deployment-and-monitoring-service-for-development.yaml
...ck-deployment-and-monitoring-service-for-development.yaml
+4
-0
db/fixtures/development/20_environments.rb
db/fixtures/development/20_environments.rb
+68
-0
lib/api/services.rb
lib/api/services.rb
+7
-1
spec/fixtures/metrics.json
spec/fixtures/metrics.json
+1
-0
No files found.
app/models/project.rb
View file @
85d0663b
...
...
@@ -116,6 +116,8 @@ class Project < ActiveRecord::Base
has_one
:prometheus_service
,
dependent: :destroy
,
inverse_of: :project
has_one
:index_status
,
dependent: :destroy
has_one
:mock_ci_service
,
dependent: :destroy
has_one
:mock_deployment_service
,
dependent: :destroy
has_one
:mock_monitoring_service
,
dependent: :destroy
has_one
:forked_project_link
,
dependent: :destroy
,
foreign_key:
"forked_to_project_id"
has_one
:forked_from_project
,
through: :forked_project_link
...
...
app/models/project_services/mock_deployment_service.rb
0 → 100644
View file @
85d0663b
class
MockDeploymentService
<
DeploymentService
def
title
'Mock deployment'
end
def
description
'Mock deployment service'
end
def
self
.
to_param
'mock_deployment'
end
# No terminals support
def
terminals
(
environment
)
binding
.
pry
[]
end
end
app/models/project_services/mock_monitoring_service.rb
0 → 100644
View file @
85d0663b
class
MockMonitoringService
<
MonitoringService
def
title
'Mock monitoring'
end
def
description
'Mock monitoring service'
end
def
self
.
to_param
'mock_monitoring'
end
def
metrics
(
environment
)
JSON
.
parse
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/metrics.json'
))
end
end
app/models/service.rb
View file @
85d0663b
...
...
@@ -240,7 +240,9 @@ class Service < ActiveRecord::Base
slack
teamcity
]
service_names
<<
'mock_ci'
if
Rails
.
env
.
development?
if
Rails
.
env
.
development?
service_names
+=
[
'mock_ci'
,
'mock_deployment'
,
'mock_monitoring'
]
end
service_names
.
sort_by
(
&
:downcase
)
end
...
...
changelogs/unreleased/add-mock-deployment-and-monitoring-service-for-development.yaml
0 → 100644
View file @
85d0663b
---
title
:
Added mock deployment and monitoring service with environments fixtures
merge_request
:
author
:
db/fixtures/development/20_environments.rb
0 → 100644
View file @
85d0663b
require
'./spec/support/sidekiq'
class
Gitlab::Seeder::Environments
def
initialize
(
project
)
@project
=
project
end
def
seed!
@project
.
create_mock_deployment_service!
(
active:
true
)
@project
.
create_mock_monitoring_service!
(
active:
true
)
create_master_deployments!
(
'production'
)
create_master_deployments!
(
'staging'
)
create_merge_request_review_deployments!
end
private
def
create_master_deployments!
(
name
)
@project
.
repository
.
commits
(
'master'
,
limit:
4
).
map
do
|
commit
|
create_deployment!
(
@project
,
name
,
'master'
,
commit
.
id
)
end
end
def
create_merge_request_review_deployments!
@project
.
merge_requests
.
sample
(
2
).
map
do
|
merge_request
|
create_deployment!
(
merge_request
.
source_project
,
"review/
#{
merge_request
.
source_branch
}
"
,
merge_request
.
source_branch
,
merge_request
.
diff_head_sha
)
end
end
def
create_deployment!
(
project
,
name
,
ref
,
sha
)
environment
=
find_or_create_environment!
(
project
,
name
)
environment
.
deployments
.
create!
(
project:
project
,
ref:
ref
,
sha:
sha
,
tag:
false
,
deployable:
find_deployable
(
project
,
name
)
)
end
def
find_or_create_environment!
(
project
,
name
)
project
.
environments
.
find_or_create_by!
(
name:
name
).
tap
do
|
environment
|
environment
.
update
(
external_url:
"https://google.com/
#{
name
}
"
)
end
end
def
find_deployable
(
project
,
environment
)
project
.
builds
.
where
(
environment:
environment
).
sample
end
end
Gitlab
::
Seeder
.
quiet
do
Project
.
all
.
sample
(
5
).
each
do
|
project
|
project_environments
=
Gitlab
::
Seeder
::
Environments
.
new
(
project
)
project_environments
.
seed!
end
end
lib/api/services.rb
View file @
85d0663b
...
...
@@ -610,8 +610,14 @@ module API
desc:
'URL to the mock service'
}
]
services
[
'mock-deployment'
]
=
[]
services
[
'mock-monitoring'
]
=
[]
service_classes
<<
MockCiService
service_classes
+=
[
MockCiService
,
MockDeploymentService
,
MockMonitoringService
,
]
end
trigger_services
=
{
...
...
spec/fixtures/metrics.json
0 → 100644
View file @
85d0663b
This diff is collapsed.
Click to expand it.
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