From 4815acc51973747ac378d19fd9516ada74cac05c Mon Sep 17 00:00:00 2001 From: Patrick Zhao Date: Thu, 13 Feb 2025 17:51:00 +0800 Subject: [PATCH] fix test report link Signed-off-by: Patrick Zhao --- .../common/repository/models/custom_workflow_test_report.go | 1 + .../aslan/core/common/repository/models/wokflow_task_v4.go | 3 ++- .../workflowcontroller/stepcontroller/step_junit_report.go | 1 + .../aslan/core/workflow/service/workflow/job/job_testing.go | 1 + .../aslan/core/workflow/service/workflow/workflow_task_v4.go | 3 ++- pkg/types/step/step_junit_report.go | 1 + 6 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/microservice/aslan/core/common/repository/models/custom_workflow_test_report.go b/pkg/microservice/aslan/core/common/repository/models/custom_workflow_test_report.go index 036756376f..ec1e4bb6ea 100644 --- a/pkg/microservice/aslan/core/common/repository/models/custom_workflow_test_report.go +++ b/pkg/microservice/aslan/core/common/repository/models/custom_workflow_test_report.go @@ -22,6 +22,7 @@ type CustomWorkflowTestReport struct { ID primitive.ObjectID `bson:"_id,omitempty"` WorkflowName string `bson:"workflow_name"` JobName string `bson:"job_name"` + JobTaskName string `bson:"job_task_name"` TaskID int64 `bson:"task_id"` ServiceName string `bson:"service_name"` ServiceModule string `bson:"service_module"` diff --git a/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go b/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go index 3580e9d977..444aedf681 100644 --- a/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go +++ b/pkg/microservice/aslan/core/common/repository/models/wokflow_task_v4.go @@ -173,7 +173,8 @@ type JobPreview struct { } type WorkflowTestModule struct { - RunningJobName string `json:"running_job_name"` + JobName string `json:"job_name"` + JobTaskName string `json:"job_task_name"` Type string `json:"type"` TestName string `json:"name"` TestCaseNum int `json:"total_case_num"` diff --git a/pkg/microservice/aslan/core/common/service/workflowcontroller/stepcontroller/step_junit_report.go b/pkg/microservice/aslan/core/common/service/workflowcontroller/stepcontroller/step_junit_report.go index 1a2040923d..d3adbcaa4b 100644 --- a/pkg/microservice/aslan/core/common/service/workflowcontroller/stepcontroller/step_junit_report.go +++ b/pkg/microservice/aslan/core/common/service/workflowcontroller/stepcontroller/step_junit_report.go @@ -136,6 +136,7 @@ func (s *junitReportCtl) AfterRun(ctx context.Context) error { err = commonrepo.NewCustomWorkflowTestReportColl().Create(&commonmodels.CustomWorkflowTestReport{ WorkflowName: s.junitReportSpec.SourceWorkflow, JobName: s.junitReportSpec.SourceJobKey, + JobTaskName: s.junitReportSpec.JobTaskName, TaskID: s.junitReportSpec.TaskID, ServiceName: s.junitReportSpec.ServiceName, ServiceModule: s.junitReportSpec.ServiceModule, diff --git a/pkg/microservice/aslan/core/workflow/service/workflow/job/job_testing.go b/pkg/microservice/aslan/core/workflow/service/workflow/job/job_testing.go index 3aa301ee7c..09e7c1555b 100644 --- a/pkg/microservice/aslan/core/workflow/service/workflow/job/job_testing.go +++ b/pkg/microservice/aslan/core/workflow/service/workflow/job/job_testing.go @@ -689,6 +689,7 @@ func (j *TestingJob) toJobtask(jobSubTaskID int, testing *commonmodels.TestModul Spec: &step.StepJunitReportSpec{ SourceWorkflow: j.workflow.Name, SourceJobKey: j.job.Name, + JobTaskName: jobName, TaskID: taskID, ReportDir: testingInfo.TestResultPath, S3DestDir: path.Join(j.workflow.Name, fmt.Sprint(taskID), jobTask.Name, "junit"), diff --git a/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go b/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go index 038b935344..a63891e2b0 100644 --- a/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go +++ b/pkg/microservice/aslan/core/workflow/service/workflow/workflow_task_v4.go @@ -1494,7 +1494,8 @@ func ListWorkflowTaskV4ByFilter(filter *TaskHistoryFilter, filterList []string, for _, testResult := range testResultList { testModules = append(testModules, &commonmodels.WorkflowTestModule{ - RunningJobName: job.Name, + JobName: job.Name, + JobTaskName: testResult.JobTaskName, Type: "function", TestName: testResult.ZadigTestName, TestCaseNum: testResult.TestCaseNum, diff --git a/pkg/types/step/step_junit_report.go b/pkg/types/step/step_junit_report.go index 61ba3df521..a1033c3918 100644 --- a/pkg/types/step/step_junit_report.go +++ b/pkg/types/step/step_junit_report.go @@ -20,6 +20,7 @@ type StepJunitReportSpec struct { SourceWorkflow string `bson:"source_workflow" json:"source_workflow" yaml:"source_workflow"` // no stage name is recorded since the job name is unique, for now (version 2.1.0) SourceJobKey string `bson:"source_job_key" json:"source_job_key" yaml:"source_job_key"` + JobTaskName string `bson:"job_task_name" json:"job_task_name" yaml:"job_task_name"` TaskID int64 `bson:"task_id" json:"task_id" yaml:"task_id"` ServiceName string `bson:"service_name" json:"service_name" yaml:"service_name"` ServiceModule string `bson:"service_module" json:"service_module" yaml:"service_module"`