-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/autotest scene set export import (#2470)
* autotest scene set export * autotest scene set import * autotest scene set protocol
- Loading branch information
Showing
34 changed files
with
1,560 additions
and
281 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
.erda/migrations/qa/20211021-auto-test-file-record-space-id.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// 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 apistructs | ||
|
||
type TestSceneSetFileType string | ||
|
||
var ( | ||
TestSceneSetFileTypeExcel TestSceneSetFileType = "excel" | ||
) | ||
|
||
func (t TestSceneSetFileType) Valid() bool { | ||
switch t { | ||
case TestSceneSetFileTypeExcel: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
// AutoTestSceneSetExportRequest export autotest scene set | ||
type AutoTestSceneSetExportRequest struct { | ||
ID uint64 `json:"id"` | ||
Locale string `schema:"-"` | ||
IsCopy bool `json:"-"` | ||
FileType TestSceneSetFileType `schema:"fileType"` | ||
SceneSetName string `json:"sceneSetName"` | ||
SpaceID uint64 `json:"spaceID"` | ||
ProjectID uint64 `json:"projectID"` | ||
|
||
IdentityInfo | ||
} | ||
|
||
type AutoTestSceneSetImportRequest struct { | ||
ProjectID uint64 `schema:"projectID"` | ||
SpaceID uint64 `schema:"spaceID"` | ||
FileType TestSceneSetFileType `schema:"fileType"` | ||
|
||
IdentityInfo | ||
} | ||
|
||
type AutoTestSceneSetImportResponse struct { | ||
Header | ||
Data uint64 `json:"data"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
modules/dop/component-protocol/components/scenes-import-record/filter/render.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.