This is an automated email from the ASF dual-hosted git repository. narro pushed a commit to branch feat-8393 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit f096be8c78dc25e62c24ccce1f82262bd702efc0 Author: narro wizard <[email protected]> AuthorDate: Mon Apr 21 13:55:05 2025 +0800 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 #8393 --- backend/core/models/domainlayer/qa/qa_api.go | 33 +++++++++++++ backend/core/models/domainlayer/qa/qa_project.go | 28 +++++++++++ backend/core/models/domainlayer/qa/qa_test_case.go | 35 ++++++++++++++ .../domainlayer/qa/qa_test_case_execution.go | 36 ++++++++++++++ .../migrationscripts/20250421_create_qa_tables.go | 56 ++++++++++++++++++++++ backend/core/models/migrationscripts/register.go | 1 + 6 files changed, 189 insertions(+) diff --git a/backend/core/models/domainlayer/qa/qa_api.go b/backend/core/models/domainlayer/qa/qa_api.go new file mode 100644 index 000000000..e8a1b09ed --- /dev/null +++ b/backend/core/models/domainlayer/qa/qa_api.go @@ -0,0 +1,33 @@ +/* +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 qa + +import ( + "time" + + "github.com/apache/incubator-devlake/core/models/domainlayer" +) + +// QaApi represents a QA API in the domain layer +type QaApi struct { + domainlayer.DomainEntityExtended + Name string `gorm:"type:varchar(255);comment:API name"` + CreateTime time.Time `gorm:"comment:API creation time"` + CreatorId string `gorm:"type:varchar(255);comment:Creator ID"` + QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"` +} diff --git a/backend/core/models/domainlayer/qa/qa_project.go b/backend/core/models/domainlayer/qa/qa_project.go new file mode 100644 index 000000000..c58d23337 --- /dev/null +++ b/backend/core/models/domainlayer/qa/qa_project.go @@ -0,0 +1,28 @@ +/* +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 qa + +import ( + "github.com/apache/incubator-devlake/core/models/domainlayer" +) + +// QaProject represents a QA project in the domain layer +type QaProject struct { + domainlayer.DomainEntityExtended + Name string `gorm:"type:varchar(255);comment:Project name"` +} diff --git a/backend/core/models/domainlayer/qa/qa_test_case.go b/backend/core/models/domainlayer/qa/qa_test_case.go new file mode 100644 index 000000000..2df4ccb29 --- /dev/null +++ b/backend/core/models/domainlayer/qa/qa_test_case.go @@ -0,0 +1,35 @@ +/* +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 qa + +import ( + "time" + + "github.com/apache/incubator-devlake/core/models/domainlayer" +) + +// QaTestCase represents a QA test case in the domain layer +type QaTestCase struct { + domainlayer.DomainEntityExtended + Name string `gorm:"type:varchar(255);comment:Test case name"` + CreateTime time.Time `gorm:"comment:Test case creation time"` + CreatorId string `gorm:"type:varchar(255);comment:Creator ID"` + Type string `gorm:"type:varchar(255);comment:Test case type | functional | api"` // enum in image, using string + TargetId string `gorm:"type:varchar(255);comment:Valid only when type = api, represents qa_api_id"` // nullable in image, using string + QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"` +} diff --git a/backend/core/models/domainlayer/qa/qa_test_case_execution.go b/backend/core/models/domainlayer/qa/qa_test_case_execution.go new file mode 100644 index 000000000..753e1fc0a --- /dev/null +++ b/backend/core/models/domainlayer/qa/qa_test_case_execution.go @@ -0,0 +1,36 @@ +/* +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 qa + +import ( + "time" + + "github.com/apache/incubator-devlake/core/models/domainlayer" +) + +// QaTestCaseExecution represents a QA test case execution in the domain layer +type QaTestCaseExecution struct { + domainlayer.DomainEntityExtended + QaProjectId string `gorm:"type:varchar(255);index;comment:Project ID"` + QaTestCaseId string `gorm:"type:varchar(255);index;comment:Test case ID"` + CreateTime time.Time `gorm:"comment:Test (plan) creation time"` + StartTime time.Time `gorm:"comment:Test start time"` + FinishTime time.Time `gorm:"comment:Test finish time"` + CreatorId string `gorm:"type:varchar(255);comment:Executor ID"` + Status string `gorm:"type:varchar(255);comment:Test execution status | PENDING | IN_PROGRESS | SUCCESS | FAILED"` // enum, using string +} diff --git a/backend/core/models/migrationscripts/20250421_create_qa_tables.go b/backend/core/models/migrationscripts/20250421_create_qa_tables.go new file mode 100644 index 000000000..936dc5959 --- /dev/null +++ b/backend/core/models/migrationscripts/20250421_create_qa_tables.go @@ -0,0 +1,56 @@ +/* +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 ( + "github.com/apache/incubator-devlake/core/context" + "github.com/apache/incubator-devlake/core/errors" + "github.com/apache/incubator-devlake/core/models/domainlayer/qa" + "github.com/apache/incubator-devlake/core/plugin" +) + +var _ plugin.MigrationScript = (*createQaTables)(nil) + +type createQaTables struct{} + +func (*createQaTables) Version() uint64 { + return 20250421104500 // YYYYMMDDHHMMSS format +} + +func (*createQaTables) Name() string { + return "create QA tables" +} + +func (*createQaTables) Up(basicRes context.BasicRes) errors.Error { + db := basicRes.GetDal() + + if err := db.AutoMigrate(&qa.QaProject{}); err != nil { + return err + } + if err := db.AutoMigrate(&qa.QaApi{}); err != nil { + return err + } + if err := db.AutoMigrate(&qa.QaTestCase{}); err != nil { + return err + } + if err := db.AutoMigrate(&qa.QaTestCaseExecution{}); err != nil { + return err + } + + return nil +} diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go index c7dd8b759..4886f66a4 100644 --- a/backend/core/models/migrationscripts/register.go +++ b/backend/core/models/migrationscripts/register.go @@ -135,5 +135,6 @@ func All() []plugin.MigrationScript { new(addIsChildToCicdPipeline), new(addCqIssueImpacts), new(addDueDateToIssues), + new(createQaTables), } }
