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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
7f8e0bce
Commit
7f8e0bce
authored
Apr 05, 2017
by
Kamil Trzciński
Committed by
Rémy Coutable
Apr 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added mock deployment and monitoring service with environments fixtures
parent
dd18faff
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
124 additions
and
2 deletions
+124
-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
+18
-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/19_environments.rb
db/fixtures/development/19_environments.rb
+70
-0
db/fixtures/development/20_nested_groups.rb
db/fixtures/development/20_nested_groups.rb
+0
-0
lib/api/services.rb
lib/api/services.rb
+7
-1
spec/fixtures/metrics.json
spec/fixtures/metrics.json
+1
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+2
-0
No files found.
app/models/project.rb
View file @
7f8e0bce
...
@@ -114,6 +114,8 @@ class Project < ActiveRecord::Base
...
@@ -114,6 +114,8 @@ class Project < ActiveRecord::Base
has_one
:kubernetes_service
,
dependent: :destroy
,
inverse_of: :project
has_one
:kubernetes_service
,
dependent: :destroy
,
inverse_of: :project
has_one
:prometheus_service
,
dependent: :destroy
,
inverse_of: :project
has_one
:prometheus_service
,
dependent: :destroy
,
inverse_of: :project
has_one
:mock_ci_service
,
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_project_link
,
dependent: :destroy
,
foreign_key:
"forked_to_project_id"
has_one
:forked_from_project
,
through: :forked_project_link
has_one
:forked_from_project
,
through: :forked_project_link
...
...
app/models/project_services/mock_deployment_service.rb
0 → 100644
View file @
7f8e0bce
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
)
[]
end
end
app/models/project_services/mock_monitoring_service.rb
0 → 100644
View file @
7f8e0bce
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 @
7f8e0bce
...
@@ -238,7 +238,9 @@ class Service < ActiveRecord::Base
...
@@ -238,7 +238,9 @@ class Service < ActiveRecord::Base
slack
slack
teamcity
teamcity
]
]
service_names
<<
'mock_ci'
if
Rails
.
env
.
development?
if
Rails
.
env
.
development?
service_names
+=
%w[mock_ci mock_deployment mock_monitoring]
end
service_names
.
sort_by
(
&
:downcase
)
service_names
.
sort_by
(
&
:downcase
)
end
end
...
...
changelogs/unreleased/add-mock-deployment-and-monitoring-service-for-development.yaml
0 → 100644
View file @
7f8e0bce
---
title
:
Added mock deployment and monitoring service with environments fixtures
merge_request
:
author
:
db/fixtures/development/19_environments.rb
0 → 100644
View file @
7f8e0bce
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
(
4
).
map
do
|
merge_request
|
next
unless
merge_request
.
diff_head_sha
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
db/fixtures/development/
19
_nested_groups.rb
→
db/fixtures/development/
20
_nested_groups.rb
View file @
7f8e0bce
File moved
lib/api/services.rb
View file @
7f8e0bce
...
@@ -562,8 +562,14 @@ module API
...
@@ -562,8 +562,14 @@ module API
desc:
'URL to the mock service'
desc:
'URL to the mock service'
}
}
]
]
services
[
'mock-deployment'
]
=
[]
services
[
'mock-monitoring'
]
=
[]
service_classes
<<
MockCiService
service_classes
+=
[
MockCiService
,
MockDeploymentService
,
MockMonitoringService
,
]
end
end
trigger_services
=
{
trigger_services
=
{
...
...
spec/fixtures/metrics.json
0 → 100644
View file @
7f8e0bce
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/import_export/all_models.yml
View file @
7f8e0bce
...
@@ -156,6 +156,8 @@ project:
...
@@ -156,6 +156,8 @@ project:
-
external_wiki_service
-
external_wiki_service
-
kubernetes_service
-
kubernetes_service
-
mock_ci_service
-
mock_ci_service
-
mock_deployment_service
-
mock_monitoring_service
-
forked_project_link
-
forked_project_link
-
forked_from_project
-
forked_from_project
-
forked_project_links
-
forked_project_links
...
...
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