This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch enrich-status-e2e
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/enrich-status-e2e by this push:
     new 081392579 fix: gitlab add deployment e2e test
081392579 is described below

commit 081392579b5e34bbbf91f9e36b1433b29309de8c
Author: abeizn <[email protected]>
AuthorDate: Wed Nov 8 14:23:48 2023 +0800

    fix: gitlab add deployment e2e test
---
 backend/plugins/gitlab/e2e/deployment_test.go      | 68 ++++++++++++++++++++++
 .../e2e/raw_tables/_raw_gitlab_api_deployments.csv |  9 +++
 .../snapshot_tables/_tool_gitlab_deployments.csv   | 30 ++++++++++
 .../snapshot_tables/cicd_deployment_commits.csv    |  9 +++
 .../e2e/snapshot_tables/cicd_deployments.csv       |  9 +++
 .../plugins/gitlab/tasks/deployment_collector.go   |  6 +-
 .../plugins/gitlab/tasks/deployment_convertor.go   | 10 ++--
 .../plugins/gitlab/tasks/deployment_extractor.go   |  9 +--
 8 files changed, 138 insertions(+), 12 deletions(-)

diff --git a/backend/plugins/gitlab/e2e/deployment_test.go 
b/backend/plugins/gitlab/e2e/deployment_test.go
new file mode 100644
index 000000000..7b32ead4e
--- /dev/null
+++ b/backend/plugins/gitlab/e2e/deployment_test.go
@@ -0,0 +1,68 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package e2e
+
+import (
+       "testing"
+
+       "github.com/apache/incubator-devlake/core/models/common"
+       "github.com/apache/incubator-devlake/core/models/domainlayer/devops"
+       "github.com/apache/incubator-devlake/helpers/e2ehelper"
+       "github.com/apache/incubator-devlake/plugins/gitlab/impl"
+       "github.com/apache/incubator-devlake/plugins/gitlab/models"
+       "github.com/apache/incubator-devlake/plugins/gitlab/tasks"
+)
+
+func TestGitlabDeploymentDataFlow(t *testing.T) {
+
+       var gitlab impl.Gitlab
+       dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", gitlab)
+
+       taskData := &tasks.GitlabTaskData{
+               Options: &tasks.GitlabOptions{
+                       ConnectionId: 1,
+                       ProjectId:    12345678,
+                       ScopeConfig:  new(models.GitlabScopeConfig),
+               },
+       }
+       // import raw data table
+       
dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_gitlab_api_deployments.csv",
+               "_raw_gitlab_api_deployments")
+       
dataflowTester.ImportCsvIntoTabler("./raw_tables/_tool_gitlab_projects.csv", 
&models.GitlabProject{})
+
+       // verify extraction
+       dataflowTester.FlushTabler(&models.GitlabDeployment{})
+       dataflowTester.Subtask(tasks.ExtractDeploymentMeta, taskData)
+       dataflowTester.VerifyTableWithOptions(&models.GitlabDeployment{}, 
e2ehelper.TableOptions{
+               CSVRelPath:  "./snapshot_tables/_tool_gitlab_deployments.csv",
+               IgnoreTypes: []interface{}{common.NoPKModel{}},
+       })
+
+       // verify conversion
+       dataflowTester.FlushTabler(&devops.CicdDeploymentCommit{})
+       dataflowTester.FlushTabler(&devops.CICDDeployment{})
+       dataflowTester.Subtask(tasks.ConvertDeploymentMeta, taskData)
+       dataflowTester.VerifyTableWithOptions(&devops.CicdDeploymentCommit{}, 
e2ehelper.TableOptions{
+               CSVRelPath:  "./snapshot_tables/cicd_deployment_commits.csv",
+               IgnoreTypes: []interface{}{common.NoPKModel{}},
+       })
+       dataflowTester.VerifyTableWithOptions(&devops.CICDDeployment{}, 
e2ehelper.TableOptions{
+               CSVRelPath:  "./snapshot_tables/cicd_deployments.csv",
+               IgnoreTypes: []interface{}{common.NoPKModel{}},
+       })
+}
diff --git 
a/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv 
b/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv
new file mode 100644
index 000000000..6ef463041
--- /dev/null
+++ b/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv
@@ -0,0 +1,9 @@
+"id","params","data","url","input","created_at"
+1,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13426753,""iid"":1,""ref"":""master"",""sha"":""add237f6852e6108ee8e0246780a54ce909c6087"",""created_at"":""2019-03-13T14:14:24.109Z"",""updated_at"":""2019-03-13T14:17:47.647Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
+2,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13432654,""iid"":2,""ref"":""master"",""sha"":""8373d207f0f2cc4414c4b1ad359b5af56e979d59"",""created_at"":""2019-03-13T14:53:48.148Z"",""updated_at"":""2019-03-13T14:57:58.866Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
+3,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13432768,""iid"":3,""ref"":""master"",""sha"":""35c3a3d82586fa0bcdb2a73b812081ece4e83429"",""created_at"":""2019-03-13T14:55:21.182Z"",""updated_at"":""2019-03-13T15:02:23.332Z"",""user"":{""id"":3466461,""username"":""rankinzheng"",""name"":""Runjin
 
Zheng"",""state"":""active"",""locked"":false,""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/3466461/avatar.png"",""web_url"":""https://gitlab.com/rankinzheng""},""en
 [...]
+4,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13436532,""iid"":4,""ref"":""deploy"",""sha"":""35c3a3d82586fa0bcdb2a73b812081ece4e83429"",""created_at"":""2019-03-13T15:21:00.302Z"",""updated_at"":""2019-03-13T15:21:27.833Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
+5,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13436763,""iid"":5,""ref"":""deploy"",""sha"":""fc449afa34b6732752d2c8ca117833e8cc1226dc"",""created_at"":""2019-03-13T15:23:35.859Z"",""updated_at"":""2019-03-13T15:23:55.981Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
+6,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13436778,""iid"":6,""ref"":""master"",""sha"":""fc449afa34b6732752d2c8ca117833e8cc1226dc"",""created_at"":""2019-03-13T15:23:52.979Z"",""updated_at"":""2019-03-13T15:25:41.435Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
+7,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13436986,""iid"":8,""ref"":""deploy"",""sha"":""d8e7440fc02b62064624c788f4e4da19ca7be198"",""created_at"":""2019-03-13T15:25:46.042Z"",""updated_at"":""2019-03-13T15:26:37.476Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
+8,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13436915,""iid"":7,""ref"":""master"",""sha"":""d8e7440fc02b62064624c788f4e4da19ca7be198"",""created_at"":""2019-03-13T15:25:15.583Z"",""updated_at"":""2019-03-13T15:28:32.992Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly
 [...]
\ No newline at end of file
diff --git 
a/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv 
b/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv
new file mode 100644
index 000000000..6b18e243d
--- /dev/null
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv
@@ -0,0 +1,30 @@
+connection_id,gitlab_id,deployment_id,created_date,updated_date,status,iid,ref,sha,environment,name,deployable_commit_author_email,deployable_commit_author_name,deployable_commit_created_at,deployable_commit_id,deployable_commit_message,deployable_commit_short_id,deployable_commit_title,deployable_created_at,deployable_finished_at,deployable_id,deployable_name,deployable_ref,deployable_stage,deployable_started_at,deployable_status,deployable_tag,deployable_duration,queued_duration,deploy
 [...]
+1,12345678,13426753,2019-03-13T14:14:24.109+00:00,2019-03-13T14:17:47.647+00:00,success,1,master,add237f6852e6108ee8e0246780a54ce909c6087,staging,test_deploy_vdev,[email protected],文宇祥,2019-03-13T14:14:23.000+00:00,add237f6852e6108ee8e0246780a54ce909c6087,"Merge
 branch 'update-gitlab-ci' into 'master'
+
+Update CI
+
+See merge request meri.co/vdev.co!175",add237f6,Merge branch 
'update-gitlab-ci' into 
'master',2019-03-13T14:14:24.000+00:00,2019-03-13T14:17:47.640+00:00,176919795,test_deploy_vdev,master,deploy,2019-03-13T14:17:33.559+00:00,failed,0,14.080506,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T14:14:23.884+00:00,51653436,master,add237f6852e6108ee8e024
 [...]
+1,12345678,13432654,2019-03-13T14:53:48.148+00:00,2019-03-13T14:57:58.866+00:00,completed,2,master,8373d207f0f2cc4414c4b1ad359b5af56e979d59,staging,test_deploy_vdev,[email protected],yuxiang,2019-03-13T14:53:34.000+00:00,8373d207f0f2cc4414c4b1ad359b5af56e979d59,"Try
 use ssh -i instead of sshpass
+",8373d207,Try use ssh -i instead of 
sshpass,2019-03-13T14:53:48.042+00:00,2019-03-13T14:57:58.845+00:00,176953840,test_deploy_vdev,master,deploy,2019-03-13T14:57:46.441+00:00,failed,0,12.403719,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T14:53:47.930+00:00,51661712,master,8373d207f0f2cc4414c4b1ad359b5af56e979d59,failed,2019-03-13T14:57:59.200+
 [...]
+1,12345678,13432768,2019-03-13T14:55:21.182+00:00,2019-03-13T15:02:23.332+00:00,failed,3,master,35c3a3d82586fa0bcdb2a73b812081ece4e83429,staging,test_deploy_vdev,[email protected],Runjin
 
Zheng,2019-03-13T14:55:17.000+00:00,35c3a3d82586fa0bcdb2a73b812081ece4e83429,"Merge
 branch '117-change-language-in-intercom' into 'master'
+
+Make Intercom support Chinese
+
+Closes #117
+
+See merge request meri.co/vdev.co!176",35c3a3d8,Merge branch 
'117-change-language-in-intercom' into 
'master',2019-03-13T14:55:20.963+00:00,,176955080,test_deploy_vdev,master,deploy,,skipped,0,,0,3466461,Runjin
 
Zheng,rankinzheng,active,https://gitlab.com/uploads/-/system/user/avatar/3466461/avatar.png,https://gitlab.com/rankinzheng,2019-01-29T13:03:20.328+00:00,,,,,,,2019-03-13T14:55:20.823+00:00,51662062,master,35c3a3d82586fa0bcdb2a73b812081ece4e83429,failed,2019-03-13T15:02:23.720+00:00
 [...]
+1,12345678,13436532,2019-03-13T15:21:00.302+00:00,2019-03-13T15:21:27.833+00:00,canceled,4,deploy,35c3a3d82586fa0bcdb2a73b812081ece4e83429,production,deploy_vdev,[email protected],Runjin
 
Zheng,2019-03-13T14:55:17.000+00:00,35c3a3d82586fa0bcdb2a73b812081ece4e83429,"Merge
 branch '117-change-language-in-intercom' into 'master'
+
+Make Intercom support Chinese
+
+Closes #117
+
+See merge request meri.co/vdev.co!176",35c3a3d8,Merge branch 
'117-change-language-in-intercom' into 
'master',2019-03-13T15:21:00.170+00:00,2019-03-13T15:21:27.825+00:00,176979325,deploy_vdev,deploy,deploy,2019-03-13T15:21:07.335+00:00,failed,0,20.489227,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T15:21:00.135+00:00,51667110,deploy,35c3a3d82586f
 [...]
+1,12345678,13436763,2019-03-13T15:23:35.859+00:00,2019-03-13T15:23:55.981+00:00,created,5,deploy,fc449afa34b6732752d2c8ca117833e8cc1226dc,production,deploy_vdev,[email protected],yuxiang,2019-03-13T15:23:26.000+00:00,fc449afa34b6732752d2c8ca117833e8cc1226dc,"Try
 to fix permission denied error
+",fc449afa,Try to fix permission denied 
error,2019-03-13T15:23:35.762+00:00,2019-03-13T15:23:55.970+00:00,176981974,deploy_vdev,deploy,deploy,2019-03-13T15:23:40.064+00:00,failed,0,15.905676,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T15:23:35.750+00:00,51667732,deploy,fc449afa34b6732752d2c8ca117833e8cc1226dc,failed,2019-03-13T15:23:56.157+00:0
 [...]
+1,12345678,13436778,2019-03-13T15:23:52.979+00:00,2019-03-13T15:25:41.435+00:00,running,6,master,fc449afa34b6732752d2c8ca117833e8cc1226dc,staging,test_deploy_vdev,[email protected],yuxiang,2019-03-13T15:23:26.000+00:00,fc449afa34b6732752d2c8ca117833e8cc1226dc,"Try
 to fix permission denied error
+",fc449afa,Try to fix permission denied 
error,2019-03-13T15:23:52.886+00:00,2019-03-13T15:25:41.412+00:00,176982160,test_deploy_vdev,master,deploy,,canceled,0,,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T15:23:52.774+00:00,51667800,master,fc449afa34b6732752d2c8ca117833e8cc1226dc,canceled,2019-03-13T15:25:46.768+00:00,https://gitlab.com/merico-d
 [...]
+1,12345678,13436915,2019-03-13T15:25:15.583+00:00,2019-03-13T15:28:32.992+00:00,undeployed,7,master,d8e7440fc02b62064624c788f4e4da19ca7be198,staging,test_deploy_vdev,[email protected],yuxiang,2019-03-13T15:24:52.000+00:00,d8e7440fc02b62064624c788f4e4da19ca7be198,"Update
 CI scripts
+",d8e7440f,Update CI 
scripts,2019-03-13T15:25:15.460+00:00,2019-03-13T15:28:32.934+00:00,176983636,test_deploy_vdev,master,deploy,,canceled,0,,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T15:25:15.329+00:00,51668124,master,d8e7440fc02b62064624c788f4e4da19ca7be198,canceled,2019-03-13T15:28:33.884+00:00,https://gitlab.com/merico-dev/ee/vdev.co/-/p
 [...]
+1,12345678,13436986,2019-03-13T15:25:46.042+00:00,2019-03-13T15:26:37.476+00:00,blocked,8,deploy,d8e7440fc02b62064624c788f4e4da19ca7be198,production,deploy_vdev,[email protected],yuxiang,2019-03-13T15:24:52.000+00:00,d8e7440fc02b62064624c788f4e4da19ca7be198,"Update
 CI scripts
+",d8e7440f,Update CI 
scripts,2019-03-13T15:25:45.877+00:00,2019-03-13T15:26:37.468+00:00,176984044,deploy_vdev,deploy,deploy,2019-03-13T15:26:19.170+00:00,failed,0,18.298368,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T15:25:45.858+00:00,51668248,deploy,d8e7440fc02b62064624c788f4e4da19ca7be198,failed,2019-03-13T15:26:37.971+00:00,https://gitlab.
 [...]
diff --git 
a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_deployment_commits.csv 
b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_deployment_commits.csv
new file mode 100644
index 000000000..507dc7072
--- /dev/null
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_deployment_commits.csv
@@ -0,0 +1,9 @@
+id,commit_sha,cicd_scope_id,cicd_deployment_id,name,result,status,environment,created_date,started_date,finished_date,duration_sec,ref_name,repo_id,repo_url,prev_success_deployment_commit_id
+gitlab:GitlabDeployment:1:12345678:13426753,add237f6852e6108ee8e0246780a54ce909c6087,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13426753,test_deploy_vdev:13426753,SUCCESS,DONE,staging,2019-03-13T14:14:24.109+00:00,2019-03-13T14:17:33.559+00:00,2019-03-13T14:17:47.640+00:00,14,master,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13432654,8373d207f0f2cc4414c4b1ad359b5af56e979d59,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13432654,test_deploy_vdev:13432654,SUCCESS,DONE,staging,2019-03-13T14:53:48.148+00:00,2019-03-13T14:57:46.441+00:00,2019-03-13T14:57:58.845+00:00,12,master,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13432768,35c3a3d82586fa0bcdb2a73b812081ece4e83429,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13432768,test_deploy_vdev:13432768,FAILURE,DONE,staging,2019-03-13T14:55:21.182+00:00,,,,master,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13436532,35c3a3d82586fa0bcdb2a73b812081ece4e83429,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13436532,deploy_vdev:13436532,FAILURE,DONE,production,2019-03-13T15:21:00.302+00:00,2019-03-13T15:21:07.335+00:00,2019-03-13T15:21:27.825+00:00,20,deploy,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13436763,fc449afa34b6732752d2c8ca117833e8cc1226dc,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13436763,deploy_vdev:13436763,,OTHER,production,2019-03-13T15:23:35.859+00:00,2019-03-13T15:23:40.064+00:00,2019-03-13T15:23:55.970+00:00,15,deploy,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13436778,fc449afa34b6732752d2c8ca117833e8cc1226dc,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13436778,test_deploy_vdev:13436778,,IN_PROGRESS,staging,2019-03-13T15:23:52.979+00:00,,2019-03-13T15:25:41.412+00:00,108,master,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13436915,d8e7440fc02b62064624c788f4e4da19ca7be198,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13436915,test_deploy_vdev:13436915,,OTHER,staging,2019-03-13T15:25:15.583+00:00,,2019-03-13T15:28:32.934+00:00,197,master,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
+gitlab:GitlabDeployment:1:12345678:13436986,d8e7440fc02b62064624c788f4e4da19ca7be198,gitlab:GitlabProject:1:12345678,gitlab:GitlabDeployment:1:12345678:13436986,deploy_vdev:13436986,,OTHER,production,2019-03-13T15:25:46.042+00:00,2019-03-13T15:26:19.170+00:00,2019-03-13T15:26:37.468+00:00,18,deploy,gitlab:GitlabProject:1:12345678,https://gitlab.com/gitlab-data/snowflake_spend,
diff --git a/backend/plugins/gitlab/e2e/snapshot_tables/cicd_deployments.csv 
b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_deployments.csv
new file mode 100644
index 000000000..30d5d60b0
--- /dev/null
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/cicd_deployments.csv
@@ -0,0 +1,9 @@
+id,cicd_scope_id,name,result,status,environment,created_date,started_date,finished_date,duration_sec
+gitlab:GitlabDeployment:1:12345678:13426753,gitlab:GitlabProject:1:12345678,test_deploy_vdev:13426753,SUCCESS,DONE,staging,2019-03-13T14:14:24.109+00:00,2019-03-13T14:17:33.559+00:00,2019-03-13T14:17:47.640+00:00,14
+gitlab:GitlabDeployment:1:12345678:13432654,gitlab:GitlabProject:1:12345678,test_deploy_vdev:13432654,SUCCESS,DONE,staging,2019-03-13T14:53:48.148+00:00,2019-03-13T14:57:46.441+00:00,2019-03-13T14:57:58.845+00:00,12
+gitlab:GitlabDeployment:1:12345678:13432768,gitlab:GitlabProject:1:12345678,test_deploy_vdev:13432768,FAILURE,DONE,staging,2019-03-13T14:55:21.182+00:00,,,
+gitlab:GitlabDeployment:1:12345678:13436532,gitlab:GitlabProject:1:12345678,deploy_vdev:13436532,FAILURE,DONE,production,2019-03-13T15:21:00.302+00:00,2019-03-13T15:21:07.335+00:00,2019-03-13T15:21:27.825+00:00,20
+gitlab:GitlabDeployment:1:12345678:13436763,gitlab:GitlabProject:1:12345678,deploy_vdev:13436763,,OTHER,production,2019-03-13T15:23:35.859+00:00,2019-03-13T15:23:40.064+00:00,2019-03-13T15:23:55.970+00:00,15
+gitlab:GitlabDeployment:1:12345678:13436778,gitlab:GitlabProject:1:12345678,test_deploy_vdev:13436778,,IN_PROGRESS,staging,2019-03-13T15:23:52.979+00:00,,2019-03-13T15:25:41.412+00:00,108
+gitlab:GitlabDeployment:1:12345678:13436915,gitlab:GitlabProject:1:12345678,test_deploy_vdev:13436915,,OTHER,staging,2019-03-13T15:25:15.583+00:00,,2019-03-13T15:28:32.934+00:00,197
+gitlab:GitlabDeployment:1:12345678:13436986,gitlab:GitlabProject:1:12345678,deploy_vdev:13436986,,OTHER,production,2019-03-13T15:25:46.042+00:00,2019-03-13T15:26:19.170+00:00,2019-03-13T15:26:37.468+00:00,18
diff --git a/backend/plugins/gitlab/tasks/deployment_collector.go 
b/backend/plugins/gitlab/tasks/deployment_collector.go
index b7d2a4c69..616f44df3 100644
--- a/backend/plugins/gitlab/tasks/deployment_collector.go
+++ b/backend/plugins/gitlab/tasks/deployment_collector.go
@@ -31,14 +31,14 @@ import (
 var _ plugin.SubTaskEntryPoint = CollectDeployment
 
 const (
-       RAW_DEPLOYMENT = "gitlab_deployments"
+       RAW_DEPLOYMENT = "gitlab_api_deployments"
 )
 
 func init() {
-       RegisterSubtaskMeta(CollectDeploymentMeta)
+       RegisterSubtaskMeta(&CollectDeploymentMeta)
 }
 
-var CollectDeploymentMeta = &plugin.SubTaskMeta{
+var CollectDeploymentMeta = plugin.SubTaskMeta{
        Name:             "CollectDeployment",
        EntryPoint:       CollectDeployment,
        EnabledByDefault: true,
diff --git a/backend/plugins/gitlab/tasks/deployment_convertor.go 
b/backend/plugins/gitlab/tasks/deployment_convertor.go
index e5fafcbe9..bf3cfdc40 100644
--- a/backend/plugins/gitlab/tasks/deployment_convertor.go
+++ b/backend/plugins/gitlab/tasks/deployment_convertor.go
@@ -35,16 +35,16 @@ import (
 var _ plugin.SubTaskEntryPoint = ConvertDeployment
 
 func init() {
-       RegisterSubtaskMeta(ConvertDeploymentMeta)
+       RegisterSubtaskMeta(&ConvertDeploymentMeta)
 }
 
-var ConvertDeploymentMeta = &plugin.SubTaskMeta{
+var ConvertDeploymentMeta = plugin.SubTaskMeta{
        Name:             "ConvertDeployment",
        EntryPoint:       ConvertDeployment,
        EnabledByDefault: true,
        Description:      "Convert gitlab deployment from tool layer to domain 
layer",
        DomainTypes:      []string{plugin.DOMAIN_TYPE_CICD},
-       Dependencies:     []*plugin.SubTaskMeta{ExtractDeploymentMeta},
+       Dependencies:     []*plugin.SubTaskMeta{&ExtractDeploymentMeta},
 }
 
 func ConvertDeployment(taskCtx plugin.SubTaskContext) errors.Error {
@@ -99,8 +99,8 @@ func ConvertDeployment(taskCtx plugin.SubTaskContext) 
errors.Error {
                                        Default: devops.RESULT_DEFAULT,
                                }, gitlabDeployment.Status),
                                Status: devops.GetStatus(&devops.StatusRule{
-                                       Done:       []string{StatusSuccess, 
StatusCompleted, StatusFailed},
-                                       InProgress: []string{StatusRunning, 
StatusCanceled, StatusBlocked},
+                                       Done:       []string{StatusSuccess, 
StatusCompleted, StatusFailed, StatusCanceled},
+                                       InProgress: []string{StatusRunning},
                                        Default:    devops.STATUS_OTHER,
                                }, gitlabDeployment.Status),
                                Environment:  gitlabDeployment.Environment,
diff --git a/backend/plugins/gitlab/tasks/deployment_extractor.go 
b/backend/plugins/gitlab/tasks/deployment_extractor.go
index 2e8124301..264037415 100644
--- a/backend/plugins/gitlab/tasks/deployment_extractor.go
+++ b/backend/plugins/gitlab/tasks/deployment_extractor.go
@@ -19,27 +19,28 @@ package tasks
 
 import (
        "encoding/json"
+       "time"
+
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
        "github.com/apache/incubator-devlake/plugins/gitlab/models"
-       "time"
 )
 
 var _ plugin.SubTaskEntryPoint = ExtractDeployment
 
 func init() {
-       RegisterSubtaskMeta(ExtractDeploymentMeta)
+       RegisterSubtaskMeta(&ExtractDeploymentMeta)
 }
 
-var ExtractDeploymentMeta = &plugin.SubTaskMeta{
+var ExtractDeploymentMeta = plugin.SubTaskMeta{
        Name:             "ExtractDeployment",
        EntryPoint:       ExtractDeployment,
        EnabledByDefault: true,
        Description:      "Extract gitlab deployment from raw layer to tool 
layer",
        DomainTypes:      []string{plugin.DOMAIN_TYPE_CICD},
-       Dependencies:     []*plugin.SubTaskMeta{CollectDeploymentMeta},
+       Dependencies:     []*plugin.SubTaskMeta{&CollectDeploymentMeta},
 }
 
 func ExtractDeployment(taskCtx plugin.SubTaskContext) errors.Error {

Reply via email to