Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update the api statistics of auto test #2806

Merged
merged 11 commits into from
Nov 5, 2021

Conversation

littlejiancc
Copy link
Contributor

What type of this PR

/kind bug

What this PR does / why we need it:

fix: update the api statistics of auto test

Which issue(s) this PR fixes:

Specified Reviewers:

/assign @sfwn

ChangeLog

Language Changelog
馃嚭馃嚫 English
馃嚚馃嚦 涓枃

Need cherry-pick to release versions?

Add comment like /cherry-pick release/1.0 when this PR is merged.

For details on the cherry pick process, see the cherry pick requests section under CONTRIBUTING.md.

@erda-bot erda-bot requested a review from sfwn November 2, 2021 16:13
@littlejiancc littlejiancc added the dop devops plaoform label Nov 2, 2021
@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #2806 (9150f95) into master (da0feca) will increase coverage by 0.58%.
The diff coverage is 19.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2806      +/-   ##
==========================================
+ Coverage   16.65%   17.23%   +0.58%     
==========================================
  Files        1263     1295      +32     
  Lines      128389   132041    +3652     
==========================================
+ Hits        21379    22758    +1379     
- Misses     104798   106936    +2138     
- Partials     2212     2347     +135     
Impacted Files Coverage 螖
apistructs/autotest_scene.go 11.94% <酶> (酶)
apistructs/pipeline_yml.go 82.60% <酶> (酶)
modules/dop/endpoints/endpoints.go 1.03% <0.00%> (-0.02%) 猬囷笍
modules/dop/endpoints/testplan_v2.go 0.00% <0.00%> (酶)
...odules/dop/providers/autotest/testplan/provider.go 17.64% <0.00%> (-2.36%) 猬囷笍
modules/dop/services/autotest_v2/scene.go 0.00% <0.00%> (酶)
modules/dop/services/autotest_v2/testplan_v2.go 1.84% <0.00%> (-0.05%) 猬囷笍
...-test-plan-detail/components/executeInfo/render.go 28.34% <0.00%> (+1.43%) 猬嗭笍
...line/aop/plugins/pipeline/testplan_after/plugin.go 25.77% <0.00%> (-18.51%) 猬囷笍
...op/providers/autotest/testplan/testplan.service.go 51.39% <36.12%> (-12.94%) 猬囷笍
... and 129 more

@sfwn sfwn marked this pull request as draft November 3, 2021 02:41
@sfwn sfwn marked this pull request as ready for review November 4, 2021 12:15
@sfwn
Copy link
Member

sfwn commented Nov 5, 2021

/approve

@erda-bot erda-bot merged commit 8498a19 into erda-project:master Nov 5, 2021
@sfwn
Copy link
Member

sfwn commented Nov 5, 2021

/cherry-pick release/1.4

@erda-bot
Copy link
Member

erda-bot commented Nov 5, 2021

Automated cherry pick failed, please resolve the confilcts and create PR manually.
Details:

Auto-merging modules/openapi/component-protocol/scenarios/auto-test-plan-detail/components/executeInfo/render.go
CONFLICT (content): Merge conflict in modules/openapi/component-protocol/scenarios/auto-test-plan-detail/components/executeInfo/render.go
diff --cc modules/openapi/component-protocol/scenarios/auto-test-plan-detail/components/executeInfo/render.go
index 50ac4f36,6a6536cf..00000000
--- a/modules/openapi/component-protocol/scenarios/auto-test-plan-detail/components/executeInfo/render.go
+++ b/modules/openapi/component-protocol/scenarios/auto-test-plan-detail/components/executeInfo/render.go
@@@ -161,37 -163,24 +162,28 @@@ func (i *ComponentFileInfo) Render(ctx 
  			}
  		}
  
- 		if len(res.Reports) > 0 && res.Reports[0].Meta != nil {
- 			value, err := json.Marshal(res.Reports[0].Meta)
- 			if err != nil {
- 				i.Data["autoTestExecPercent"] = "-"
- 				i.Data["autoTestSuccessPercent"] = "-"
- 				goto Label
- 			}
- 			var report reportNew
- 			err = json.Unmarshal(value, &report)
- 			if err != nil {
- 				i.Data["autoTestExecPercent"] = "-"
- 				i.Data["autoTestSuccessPercent"] = "-"
- 				goto Label
- 			}
- 			i.Data["autoTestNum"] = report.APITotalNum
- 			if report.APITotalNum == 0 {
- 				i.Data["autoTestExecPercent"] = "0.00%"
- 				i.Data["autoTestSuccessPercent"] = "0.00%"
- 			} else {
- 				i.Data["autoTestExecPercent"] = strconv.FormatFloat(100-float64(report.APINotExecNum)/float64(report.APITotalNum)*100, 'f', 2, 64) + "%"
- 				i.Data["autoTestSuccessPercent"] = strconv.FormatFloat(float64(report.APISuccessNum)/float64(report.APITotalNum)*100, 'f', 2, 64) + "%"
- 			}
+ 		execHistory, err := i.CtxBdl.Bdl.GetAutoTestExecHistory(i.State.PipelineID)
+ 		if err != nil {
+ 			i.Data["autoTestExecPercent"] = "-"
+ 			i.Data["autoTestSuccessPercent"] = "-"
+ 			i.Data["autoTestNum"] = "-"
+ 		} else {
+ 			i.Data["autoTestExecPercent"] = fmt.Sprintf("%.2f", execHistory.ExecuteRate)
+ 			i.Data["autoTestSuccessPercent"] = fmt.Sprintf("%.2f", execHistory.PassRate)
+ 			i.Data["autoTestNum"] = execHistory.TotalApiNum
  		}
  	}
++<<<<<<< HEAD
 +Label:
 +	config, err := convertReportToConfig(env)
 +	if err != nil {
 +		return err
 +	}
 +	i.State.EnvData = config
 +	i.Data["executeEnv"] = getApiConfigName(env)
++=======
+ 	i.Data["executeEnv"] = i.State.EnvName
++>>>>>>> 8498a195 (fix: update the api statistics of auto test (#2806))
  	i.Props = make(map[string]interface{})
  	i.Props["fields"] = []PropColumn{
  		{

@littlejiancc
Copy link
Contributor Author

/cherry-pick release/1.4

erda-bot pushed a commit to erda-bot/erda that referenced this pull request Nov 5, 2021
* modify algorithm of passRate and execRate

* deal with repeat value

* list scene not include ref

* diff step types

* update api statistics

* the num api not include ref

* add auto test history api

* update openapi render

* update testplan after plugin

* update testplan after plugin

* api count not include empty name
erda-bot added a commit that referenced this pull request Nov 5, 2021
* modify algorithm of passRate and execRate

* deal with repeat value

* list scene not include ref

* diff step types

* update api statistics

* the num api not include ref

* add auto test history api

* update openapi render

* update testplan after plugin

* update testplan after plugin

* api count not include empty name

Co-authored-by: littlejian <17816869670@163.com>
@littlejiancc littlejiancc deleted the feature/testplan-bugfix branch March 29, 2022 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dop devops plaoform
Development

Successfully merging this pull request may close these issues.

None yet

3 participants