Skip to content

Commit e434e0d

Browse files
authored
feat(domain): create QA tables and models (#8395)
* feat(core): create QA tables and models - Add QaApi, QaProject, QaTestCase, and QaTestCaseExecution models - Create corresponding database tables for QA - Update migration scripts to include QA table creation * feat(customize): add CSV import APIs for QA data - Implement API endpoints for importing QA APIs, test cases, and test case executions from CSV files - Add file extraction and CSV parsing logic - Include error handling and input validation - Placeholder for service layer integration #8393 * feat(customize): add incremental import functionality for QA APIs and Test Cases - Add incremental import parameter to API endpoints for QA APIs and Test Cases - Implement service layer functions for importing CSV data into qa_apis and qa_test_cases tables - Handle both incremental and full imports - Update API handlers to use new service layer functions * feat(customize): add import functionality for QA test case executions - Implement ImportQaTestCaseExecutions function in Service - Add related CSV import handlers and data processors - Include incremental import support for QA test case executions - Update API documentation to reflect new import functionality - Add unit tests for new import features #8393 * feat(core): add QA domain layer models - Import QA package in domaininfo.go - Add QA-related domain tables to GetDomainTablesInfo() function - Fix lint * feat(customize): import creator information for QA entities - Add creator_name field to CSV imports for QA APIs, test cases, and executions - Create or update Account entities based on creator_name - Link Account entities to QA entities in the database - Update API and test case imports to handle creator information - Remove qa_apis handling when upload qa_test_cases #8393 * feat(qa): add API path and method fields and update related tests - Add 'Path' and 'Method' fields to QaApi struct - Update QaTestCase to use QaApiId instead of TargetId - Modify migration script to include new fields - Update CSV files and snapshots to reflect changes #8393
1 parent a3c0428 commit e434e0d

31 files changed

+917
-11
lines changed

backend/core/models/domainlayer/domaininfo/domaininfo.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/apache/incubator-devlake/core/models/domainlayer/codequality"
2424
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
2525
"github.com/apache/incubator-devlake/core/models/domainlayer/devops"
26+
"github.com/apache/incubator-devlake/core/models/domainlayer/qa"
2627
"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
2728
)
2829

@@ -94,5 +95,10 @@ func GetDomainTablesInfo() []dal.Tabler {
9495
&ticket.IssueCustomArrayField{},
9596
&ticket.Incident{},
9697
&ticket.IncidentAssignee{},
98+
// qa
99+
&qa.QaProject{},
100+
&qa.QaApi{},
101+
&qa.QaTestCase{},
102+
&qa.QaTestCaseExecution{},
97103
}
98104
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package qa
19+
20+
import (
21+
"time"
22+
23+
"github.com/apache/incubator-devlake/core/models/domainlayer"
24+
)
25+
26+
// QaApi represents a QA API in the domain layer
27+
type QaApi struct {
28+
domainlayer.DomainEntityExtended
29+
Name string `gorm:"type:varchar(255);comment:API name"`
30+
Path string `gorm:"type:varchar(255);comment:API path"`
31+
Method string `gorm:"type:varchar(255);comment:API method"`
32+
CreateTime time.Time `gorm:"comment:API creation time"`
33+
CreatorId string `gorm:"type:varchar(255);comment:Creator ID"`
34+
QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"`
35+
}
36+
37+
func (QaApi) TableName() string {
38+
return "qa_apis"
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package qa
19+
20+
import (
21+
"github.com/apache/incubator-devlake/core/models/domainlayer"
22+
)
23+
24+
// QaProject represents a QA project in the domain layer
25+
type QaProject struct {
26+
domainlayer.DomainEntityExtended
27+
Name string `gorm:"type:varchar(255);comment:Project name"`
28+
}
29+
30+
func (QaProject) TableName() string {
31+
return "qa_projects"
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package qa
19+
20+
import (
21+
"time"
22+
23+
"github.com/apache/incubator-devlake/core/models/domainlayer"
24+
)
25+
26+
// QaTestCase represents a QA test case in the domain layer
27+
type QaTestCase struct {
28+
domainlayer.DomainEntityExtended
29+
Name string `gorm:"type:varchar(255);comment:Test case name"`
30+
CreateTime time.Time `gorm:"comment:Test case creation time"`
31+
CreatorId string `gorm:"type:varchar(255);comment:Creator ID"`
32+
Type string `gorm:"type:varchar(255);comment:Test case type | functional | api"` // enum in image, using string
33+
QaApiId string `gorm:"type:varchar(255);comment:Valid only when type = api, represents qa_api_id"` // nullable in image, using string
34+
QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"`
35+
}
36+
37+
func (qaTestCase *QaTestCase) TableName() string {
38+
return "qa_test_cases"
39+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package qa
19+
20+
import (
21+
"time"
22+
23+
"github.com/apache/incubator-devlake/core/models/domainlayer"
24+
)
25+
26+
// QaTestCaseExecution represents a QA test case execution in the domain layer
27+
type QaTestCaseExecution struct {
28+
domainlayer.DomainEntityExtended
29+
QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"`
30+
QaTestCaseId string `gorm:"type:varchar(255);index;comment:Test case ID"`
31+
CreateTime time.Time `gorm:"comment:Test (plan) creation time"`
32+
StartTime time.Time `gorm:"comment:Test start time"`
33+
FinishTime time.Time `gorm:"comment:Test finish time"`
34+
CreatorId string `gorm:"type:varchar(255);comment:Executor ID"`
35+
Status string `gorm:"type:varchar(255);comment:Test execution status | PENDING | IN_PROGRESS | SUCCESS | FAILED"` // enum, using string
36+
}
37+
38+
func (QaTestCaseExecution) TableName() string {
39+
return "qa_test_case_executions"
40+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package migrationscripts
19+
20+
import (
21+
"time"
22+
23+
"github.com/apache/incubator-devlake/core/context"
24+
"github.com/apache/incubator-devlake/core/errors"
25+
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
26+
"github.com/apache/incubator-devlake/core/plugin"
27+
)
28+
29+
var _ plugin.MigrationScript = (*createQaTables)(nil)
30+
31+
type createQaTables struct{}
32+
33+
func (*createQaTables) Version() uint64 {
34+
return 20250421104500 // YYYYMMDDHHMMSS format
35+
}
36+
37+
func (*createQaTables) Name() string {
38+
return "create QA tables"
39+
}
40+
41+
// QaProject represents a QA project in the domain layer
42+
type QaProject struct {
43+
archived.DomainEntityExtended
44+
Name string `gorm:"type:varchar(255);comment:Project name"`
45+
}
46+
47+
// QaApi represents a QA API in the domain layer
48+
type QaApi struct {
49+
archived.DomainEntityExtended
50+
Name string `gorm:"type:varchar(255);comment:API name"`
51+
Path string `gorm:"type:varchar(255);comment:API path"`
52+
Method string `gorm:"type:varchar(255);comment:API method"`
53+
CreateTime time.Time `gorm:"comment:API creation time"`
54+
CreatorId string `gorm:"type:varchar(255);comment:Creator ID"`
55+
QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"`
56+
}
57+
58+
// QaTestCase represents a QA test case in the domain layer
59+
type QaTestCase struct {
60+
archived.DomainEntityExtended
61+
Name string `gorm:"type:varchar(255);comment:Test case name"`
62+
CreateTime time.Time `gorm:"comment:Test case creation time"`
63+
CreatorId string `gorm:"type:varchar(255);comment:Creator ID"`
64+
Type string `gorm:"type:varchar(255);comment:Test case type | functional | api"` // enum in image, using string
65+
QaApiId string `gorm:"type:varchar(255);comment:Valid only when type = api, represents qa_api_id"` // nullable in image, using string
66+
QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"`
67+
}
68+
69+
// QaTestCaseExecution represents a QA test case execution in the domain layer
70+
type QaTestCaseExecution struct {
71+
archived.DomainEntityExtended
72+
QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"`
73+
QaTestCaseId string `gorm:"type:varchar(255);index;comment:Test case ID"`
74+
CreateTime time.Time `gorm:"comment:Test (plan) creation time"`
75+
StartTime time.Time `gorm:"comment:Test start time"`
76+
FinishTime time.Time `gorm:"comment:Test finish time"`
77+
CreatorId string `gorm:"type:varchar(255);comment:Executor ID"`
78+
Status string `gorm:"type:varchar(255);comment:Test execution status | PENDING | IN_PROGRESS | SUCCESS | FAILED"` // enum, using string
79+
}
80+
81+
func (*createQaTables) Up(basicRes context.BasicRes) errors.Error {
82+
db := basicRes.GetDal()
83+
84+
if err := db.AutoMigrate(&QaProject{}); err != nil {
85+
return err
86+
}
87+
if err := db.AutoMigrate(&QaApi{}); err != nil {
88+
return err
89+
}
90+
if err := db.AutoMigrate(&QaTestCase{}); err != nil {
91+
return err
92+
}
93+
if err := db.AutoMigrate(&QaTestCaseExecution{}); err != nil {
94+
return err
95+
}
96+
97+
return nil
98+
}

backend/core/models/migrationscripts/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,6 @@ func All() []plugin.MigrationScript {
135135
new(addIsChildToCicdPipeline),
136136
new(addCqIssueImpacts),
137137
new(addDueDateToIssues),
138+
new(createQaTables),
138139
}
139140
}

0 commit comments

Comments
 (0)