You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/06/22 11:42:09 UTC

[GitHub] [incubator-devlake] mappjzc opened a new pull request, #2314: feat: ae project e2e test

mappjzc opened a new pull request, #2314:
URL: https://github.com/apache/incubator-devlake/pull/2314

   # Summary
   Add TestAECommitDataFlow
   Move ae.go code to impl.go
   <!--
   Thanks for submitting a pull request!
   
   We appreciate you spending the time to work on these changes.
   Please fill out as many sections below as possible.
   -->
   
   ### Does this close any open issues?
   Please mention the issues here.
   
   ### Screenshots
   Include any relevant screenshots here.
   
   ### Other Information
   Any other information that is important to this PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2314: feat: ae project e2e test

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #2314:
URL: https://github.com/apache/incubator-devlake/pull/2314#discussion_r905992677


##########
plugins/ae/models/migrationscripts/init_schema.go:
##########
@@ -21,20 +21,63 @@ import (
 	"context"
 
 	"github.com/apache/incubator-devlake/plugins/ae/models/migrationscripts/archived"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/helper"
 	"gorm.io/gorm"
 )
 
-type InitSchemas struct{}
+type InitSchemas struct {
+	config core.ConfigGetter
+}
+
+func (u *InitSchemas) SetConfigGetter(config core.ConfigGetter) {
+	u.config = config
+}
 
-func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
-	return db.Migrator().AutoMigrate(
+func (u *InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
+	err := db.Migrator().DropTable(
 		&archived.AECommit{},
 		&archived.AEProject{},
+		&archived.AeConnection{},

Review Comment:
   I don't think this is needed.



##########
plugins/ae/models/migrationscripts/init_schema.go:
##########
@@ -21,20 +21,63 @@ import (
 	"context"
 
 	"github.com/apache/incubator-devlake/plugins/ae/models/migrationscripts/archived"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/helper"
 	"gorm.io/gorm"
 )
 
-type InitSchemas struct{}
+type InitSchemas struct {
+	config core.ConfigGetter
+}
+
+func (u *InitSchemas) SetConfigGetter(config core.ConfigGetter) {
+	u.config = config
+}
 
-func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
-	return db.Migrator().AutoMigrate(
+func (u *InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
+	err := db.Migrator().DropTable(
 		&archived.AECommit{},
 		&archived.AEProject{},
+		&archived.AeConnection{},
+		"_raw_ae_project",
+		"_raw_ae_commits",
 	)
+	if err != nil {
+		return err
+	}
+
+	err = db.Migrator().AutoMigrate(
+		&archived.AECommit{},
+		&archived.AEProject{},
+		&archived.AeConnection{},
+	)
+	if err != nil {
+		return err
+	}
+
+	encodeKey := u.config.GetString(core.EncodeKeyEnvStr)
+	connection := &archived.AeConnection{}
+	connection.Endpoint = u.config.GetString("AE_ENDPOINT")
+	connection.Proxy = u.config.GetString("GITHUB_PROXY")

Review Comment:
   `AE_PROXY` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2314: feat: ae project e2e test

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2314:
URL: https://github.com/apache/incubator-devlake/pull/2314#discussion_r903795410


##########
plugins/ae/e2e/raw_tables/_raw_ae_project.csv:
##########
@@ -0,0 +1,2 @@
+id,params,data,url,input,created_at
+3,"{""ProjectId"":13}","{""id"":13,""git_url"":""https://github.com/merico-dev/lake"",""priority"":10000,""create_time"":""2021-11-25T20:58:58.053904+08:00"",""update_time"":""2021-11-25T20:58:58.053904+08:00""}","http://34.214.122.134:30012/projects/13","null","2022-06-21 15:13:46.175"

Review Comment:
   where is connection id?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2314: feat: ae project e2e test

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2314:
URL: https://github.com/apache/incubator-devlake/pull/2314#discussion_r903996052


##########
plugins/ae/e2e/project_test.go:
##########
@@ -0,0 +1,62 @@
+/*
+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 (
+	"fmt"
+	"testing"
+
+	"github.com/apache/incubator-devlake/helpers/e2ehelper"
+	"github.com/apache/incubator-devlake/plugins/ae/impl"
+	"github.com/apache/incubator-devlake/plugins/ae/models"
+	"github.com/apache/incubator-devlake/plugins/ae/tasks"
+)
+
+func TestAEProjectDataFlow(t *testing.T) {
+	var ae impl.AE
+	dataflowTester := e2ehelper.NewDataFlowTester(t, "ae", ae)
+
+	taskData := &tasks.AeTaskData{
+		Options: &tasks.AeOptions{
+			ConnectionId: 1,
+			ProjectId:    13,
+		},
+	}
+
+	// import raw data table
+	dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_ae_project.csv", "_raw_ae_project")
+
+	// verify extraction
+	dataflowTester.FlushTabler(&models.AEProject{})
+	dataflowTester.Subtask(tasks.ExtractProjectMeta, taskData)
+	dataflowTester.VerifyTable(
+		models.AEProject{},
+		fmt.Sprintf("./snapshot_tables/%s.csv", models.AEProject{}.TableName()),
+		[]string{"id"},

Review Comment:
   add connection_id here and confirm it's not 0.



##########
plugins/ae/models/migrationscripts/updateSchemas20220622.go:
##########
@@ -0,0 +1,61 @@
+/*
+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 migrationscripts
+
+import (
+	"context"
+	"time"
+
+	"github.com/apache/incubator-devlake/models/migrationscripts/archived"
+	aearchived "github.com/apache/incubator-devlake/plugins/ae/models/migrationscripts/archived"
+	"gorm.io/gorm"
+)
+
+type UpdateSchemas20220622 struct{}
+
+type AEProject20220622 struct {
+	ConnectionId uint64 `gorm:"primaryKey"`
+	Id           int    `gorm:"primaryKey;type:varchar(255)"`
+	GitUrl       string `gorm:"type:varchar(255);comment:url of the repo in github"`
+	Priority     int
+	AECreateTime *time.Time
+	AEUpdateTime *time.Time
+	archived.NoPKModel
+}
+
+func (AEProject20220622) TableName() string {
+	return "_tool_ae_projects"
+}
+
+func (*UpdateSchemas20220622) Up(ctx context.Context, db *gorm.DB) error {
+	if !db.Migrator().HasColumn(&aearchived.AEProject{}, "connection_id") {
+		err := db.Migrator().AddColumn(&AEProject20220622{}, "connection_id")

Review Comment:
   Just drop it and recreate it.  Or fill connection_id for exist rows.



##########
plugins/ae/e2e/snapshot_tables/_tool_ae_projects.csv:
##########
@@ -0,0 +1 @@
+id,git_url,priority,ae_create_time,ae_update_time,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark

Review Comment:
   it's should not be empty. And you need to check it after it's generated auto.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2314: feat: ae project e2e test

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2314:
URL: https://github.com/apache/incubator-devlake/pull/2314#discussion_r903796534


##########
plugins/ae/e2e/snapshot_tables/_tool_ae_projects.csv:
##########
@@ -0,0 +1,2 @@
+id,git_url,priority,ae_create_time,ae_update_time,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+13,https://github.com/merico-dev/lake,10000,2021-11-25T12:58:58.054+00:00,2021-11-25T12:58:58.054+00:00,"{""ProjectId"":13}",_raw_ae_project,3,

Review Comment:
   it's not pass because of the result `2021-11-25T12:58:58.053+00:00` is not match `2021-11-25T12:58:58.054+00:00` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh merged pull request #2314: feat: ae project e2e test

Posted by GitBox <gi...@apache.org>.
klesh merged PR #2314:
URL: https://github.com/apache/incubator-devlake/pull/2314


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org