Skip to content

Commit

Permalink
autotest scene set protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey committed Oct 21, 2021
1 parent aa2bb60 commit d0099bf
Show file tree
Hide file tree
Showing 26 changed files with 807 additions and 229 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE dice_test_file_records ADD COLUMN `space_id` int(11) DEFAULT false COMMENT 'autotest space id';
5 changes: 5 additions & 0 deletions apistructs/autotest_scene_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ type AutoTestSceneSetImportRequest struct {

IdentityInfo
}

type AutoTestSceneSetImportResponse struct {
Header
Data uint64 `json:"data"`
}
1 change: 1 addition & 0 deletions apistructs/component_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const (
UpdateSceneOperationKey OperationKey = "UpdateScene"
DeleteSceneOperationKey OperationKey = "DeleteScene"
DeleteSceneSetOperationKey OperationKey = "DeleteSceneSet"
ExportSceneSetOperationKey OperationKey = "exportSceneSet"
ClickAddSceneSeButtonOperationKey OperationKey = "ClickAddSceneSet"
DragSceneSetOperationKey OperationKey = "DragSceneSet"
CopySceneOperationKey OperationKey = "CopyScene"
Expand Down
3 changes: 3 additions & 0 deletions apistructs/file_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type TestFileRecord struct {
ProjectID uint64 `json:"projectID"`
TestSetID uint64 `json:"testSetID"`
ApiFileUUID string `json:"apiFileUUID"`
SpaceID uint64 `json:"spaceID"`
Type FileActionType `json:"type"`
State FileRecordState `json:"state"`
CreatedAt time.Time `json:"createdAt"`
Expand All @@ -38,6 +39,7 @@ type TestFileRecordRequest struct {
ID uint64 `json:"id"`
FileName string `json:"name"`
ProjectID uint64 `json:"projectID"`
SpaceID uint64 `json:"spaceID"`
Description string `json:"description"`
ApiFileUUID string `json:"apiFileUUID"`
Type FileActionType `json:"type"`
Expand Down Expand Up @@ -89,6 +91,7 @@ const (

type ListTestFileRecordsRequest struct {
ProjectID uint64 `json:"projectID"`
SpaceID uint64 `json:"spaceID"`
Types []FileActionType `json:"types"`
Locale string `json:"locale"`
}
Expand Down
18 changes: 18 additions & 0 deletions bundle/autotest_sceneset.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,21 @@ func (b *Bundle) DragSceneSet(req apistructs.SceneSetRequest) error {
}
return nil
}

// ExportAutotestSceneSet export autotest scene set
func (b *Bundle) ExportAutotestSceneSet(userID string, req apistructs.AutoTestSceneSetExportRequest) error {
host, err := b.urls.DOP()
if err != nil {
return err
}
hc := b.hc
var exportID uint64
_, err = hc.Post(host).Path("/api/autotests/scenesets/actions/export").
Header(httputil.UserHeader, userID).
JSONBody(req).Do().JSON(&exportID)
if err != nil {
return apierrors.ErrInvoke.InternalError(err)
}

return nil
}
2 changes: 1 addition & 1 deletion bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func New(options ...Option) *Bundle {
}
if b.i18nLoader == nil {
b.i18nLoader = i18n.NewLoader()
b.i18nLoader.LoadDir("pkg/erda-configs/i18n")
b.i18nLoader.LoadDir("erda-configs/i18n")
b.i18nLoader.DefaultLocale("zh-CN")
}
return b
Expand Down
3 changes: 3 additions & 0 deletions conf/dop/dop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ component-protocol.components.code-coverage.tip:
component-protocol.components.code-coverage.executeHistoryButton:
component-protocol.components.code-coverage.downloadButton:

component-protocol.components.scenes-import-record.filter:
component-protocol.components.scenes-import-record.table:




Expand Down
34 changes: 34 additions & 0 deletions conf/dop/i18n/component-protocol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ zh:
test-case-num-notpassed: 未通过
test-case-rate-passed: 通过率
test-case-rate-executed: 执行率
import: 导入
export: 导出
scene-set-export-confirm: 是否确认导出
scene-set-export-success-msg: 导出任务已创建, 请在导入导出记录表中查看进度
status-success: 成功
status-failed: 失败,
status-pending: 排队中
status-processing: 进行中
download-file: 下载文件
import-export-record: 导入导出记录
import-export-table: 导入导出记录表
type: 类型
operator: 操作人
time: 时间
desc: 描述
status: 状态
result: 结果
en:
issue-manage: issue manage
issue: issue
Expand Down Expand Up @@ -183,6 +200,23 @@ en:
board-view: Board View
custom: Custom
state: State
import: Import
export: Export
scene-set-export-confirm: Are you sure to export?
scene-set-export-success-msg: The export task has been created, please check the progress in the import and export record table
status-success: Success
status-failed: Failed,
status-pending: Pending
status-processing: Processing
download-file: Download File
import-export-record: Import and export records
import-export-table: Import and export records table
type: Type
operator: Operator
time: Time,
desc: Description
status: Status
result: Result
test-case-num-total: Test Case Total Number
test-case-num-done: Finished
test-case-num-block: Block
Expand Down
1 change: 1 addition & 0 deletions conf/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ openapi-v1-routes:
- issue-manage
- issue-dashboard
- code-coverage
- scenes-import-record
- addr: http://localhost:8080
scenarios:
- demo
Expand Down
1 change: 1 addition & 0 deletions modules/dop/component-protocol/components/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ import (
_ "github.com/erda-project/erda/modules/dop/component-protocol/components/issue-dashboard"
_ "github.com/erda-project/erda/modules/dop/component-protocol/components/issue-manage"
_ "github.com/erda-project/erda/modules/dop/component-protocol/components/test-dashboard"
_ "github.com/erda-project/erda/modules/dop/component-protocol/components/scenes-import-record"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright (c) 2021 Terminus, Inc.
//
// Licensed 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 filter

import (
"context"
"encoding/json"

"github.com/sirupsen/logrus"

"github.com/erda-project/erda-infra/base/servicehub"
"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
"github.com/erda-project/erda/modules/openapi/component-protocol/components/base"
)

type ComponentAction struct {
base.DefaultProvider

Name string `json:"name"`
Type string `json:"type"`
State State `json:"state"`
Props map[string]interface{} `json:"props"`
Operations map[string]interface{} `json:"operations"`
}

type State struct {
Conditions []interface{} `json:"conditions"`
Values struct {
Type []string `json:"type"`
} `json:"values"`
}

func (i *ComponentAction) GenComponentState(c *cptype.Component) error {
if c == nil || c.State == nil {
return nil
}
var state State
cont, err := json.Marshal(c.State)
if err != nil {
logrus.Errorf("marshal component state failed, content:%v, err:%v", c.State, err)
return err
}
err = json.Unmarshal(cont, &state)
if err != nil {
logrus.Errorf("unmarshal component state failed, content:%v, err:%v", cont, err)
return err
}
i.State = state
return nil
}

func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scenario cptype.Scenario, event cptype.ComponentEvent, gs *cptype.GlobalStateData) error {
if err := ca.GenComponentState(c); err != nil {
return err
}
ca.Props = map[string]interface{}{
"delay": 1000,
}
ca.State.Conditions = []interface{}{
map[string]interface{}{
"emptyText": "全部",
"fixed": true,
"key": "type",
"label": "类型",
"options": []interface{}{
map[string]interface{}{
"label": "导入",
"value": "import",
},
map[string]interface{}{
"label": "导出",
"value": "export",
},
},
"type": "select",
},
}
ca.Operations = map[string]interface{}{
"filter": map[string]interface{}{
"key": "filter",
"reload": true,
},
}
return nil
}

func init() {
base.InitProviderWithCreator("scenes-import-record", "filter", func() servicehub.Provider {
return &ComponentAction{}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package leftHeadButton
package scenes_import_record

import (
protocol "github.com/erda-project/erda/modules/openapi/component-protocol"
_ "github.com/erda-project/erda/modules/dop/component-protocol/components/scenes-import-record/filter"
_ "github.com/erda-project/erda/modules/dop/component-protocol/components/scenes-import-record/table"
)

type ComponentleftHeadButtonModal struct {
CtxBdl protocol.ContextBundle
Props map[string]interface{} `json:"props"`
Operations map[string]interface{} `json:"operations"`
State State `json:"state"`
}

type State struct {
ActionType string `json:"actionType"`
FormVisible bool `json:"formVisible"`
}

type Operation struct {
Key string `json:"key"`
Reload bool `json:"reload"`
}
Loading

0 comments on commit d0099bf

Please # to comment.