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

Automated cherry pick of #3040: fix: Recovery pass rate and execution rate statistics of auto test scene #3041

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -156,16 +156,35 @@ func (i *ComponentFileInfo) Render(ctx context.Context, c *apistructs.Component,
if rsp.Status == apistructs.PipelineStatusNoNeedBySystem {
i.Data["status"] = "鏃犻渶鎵ц"
}

execHistory, err := i.CtxBdl.Bdl.GetAutoTestExecHistory(i.State.PipelineID)
res, err := i.CtxBdl.Bdl.GetPipelineReportSet(i.State.PipelineID, []string{"api-test"})
if err != nil {
i.Data["autoTestExecPercent"] = "-"
i.Data["autoTestSuccessPercent"] = "-"
} else {
i.Data["autoTestExecPercent"] = fmt.Sprintf("%.2f", execHistory.ExecuteRate)
i.Data["autoTestSuccessPercent"] = fmt.Sprintf("%.2f", execHistory.PassRate)
return err
}
if res != nil && 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) + "%"
}
}
}
Label:
i.Props = make(map[string]interface{})
i.Props["fields"] = []PropColumn{
{
Expand Down