Skip to content

Commit

Permalink
Merge branch 'main' into sandbox/twrc
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Oct 28, 2024
2 parents 6b766f6 + 56e088b commit 6cd788f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/testworkflows/testworkflowexecutor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -337,13 +338,13 @@ func (e *executor) getPreExecutionMachine(workflow *testworkflowsv1.TestWorkflow
return expressions.CombinedMachines(cloudMachine, workflowMachine)
}

func (e *executor) getPostExecutionMachine(execution *testkube.TestWorkflowExecution, orgId, envId string) expressions.Machine {
executionConfig := e.buildExecutionConfig(execution, orgId, envId)
func (e *executor) getPostExecutionMachine(execution *testkube.TestWorkflowExecution, orgId, envId, parentIds string) expressions.Machine {
executionConfig := e.buildExecutionConfig(execution, orgId, envId, parentIds)
executionMachine := testworkflowconfig.CreateExecutionMachine(&executionConfig)
return expressions.CombinedMachines(executionMachine)
}

func (e *executor) buildExecutionConfig(execution *testkube.TestWorkflowExecution, orgId, envId string) testworkflowconfig.ExecutionConfig {
func (e *executor) buildExecutionConfig(execution *testkube.TestWorkflowExecution, orgId, envId, parentIds string) testworkflowconfig.ExecutionConfig {
return testworkflowconfig.ExecutionConfig{
Id: execution.Id,
GroupId: execution.GroupId,
Expand All @@ -355,6 +356,7 @@ func (e *executor) buildExecutionConfig(execution *testkube.TestWorkflowExecutio
Debug: false,
OrganizationId: orgId,
EnvironmentId: envId,
ParentIds: parentIds,
}
}

Expand Down Expand Up @@ -526,7 +528,7 @@ func (e *executor) initialize(ctx context.Context, workflow *testworkflowsv1.Tes

// Simplify the result
preMachine := e.getPreExecutionMachine(workflow, organizationId, environmentId)
postMachine := e.getPostExecutionMachine(execution, organizationId, environmentId)
postMachine := e.getPostExecutionMachine(execution, organizationId, environmentId, strings.Join(request.ParentExecutionIds, "/"))
_ = expressions.Simplify(&workflow, preMachine, postMachine)

// Build the final tags
Expand Down Expand Up @@ -690,7 +692,7 @@ func (e *executor) Execute(ctx context.Context, workflow testworkflowsv1.TestWor

// Schedule the execution by the Execution Worker
result, err := e.workerClient.Execute(context.Background(), executionworkertypes.ExecuteRequest{
Execution: e.buildExecutionConfig(execution, organizationId, environmentId),
Execution: e.buildExecutionConfig(execution, organizationId, environmentId, strings.Join(request.ParentExecutionIds, "/")),
Secrets: secretsMap,
Workflow: workflow,
ControlPlane: e.buildControlPlaneConfig(organizationId, environmentId),
Expand Down

0 comments on commit 6cd788f

Please sign in to comment.