Skip to content

Commit b126a3d

Browse files
committed
move project name rendering to agentdeployer package
1 parent e9ae6a0 commit b126a3d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

internal/agentdeployer/agent.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (d *DockerComposeAgentDeployer) SetUp(ctx context.Context, agentInfo AgentI
133133
return nil, fmt.Errorf("could not create resources for custom agent: %w", err)
134134
}
135135

136-
composeProjectName := fmt.Sprintf("elastic-package-agent-%s-%s", d.agentName(), agentInfo.Test.RunID)
136+
composeProjectName := d.ProjectName(agentInfo.Test.RunID)
137137

138138
agent := dockerComposeDeployedAgent{
139139
ymlPaths: []string{filepath.Join(configDir, dockerTestAgentDockerCompose)},
@@ -228,6 +228,11 @@ func (d *DockerComposeAgentDeployer) SetUp(ctx context.Context, agentInfo AgentI
228228
return &agent, nil
229229
}
230230

231+
// ProjectName returns the Docker Compose project name for the agent.
232+
func (d *DockerComposeAgentDeployer) ProjectName(runID string) string {
233+
return fmt.Sprintf("elastic-package-agent-%s-%s", d.agentName(), runID)
234+
}
235+
231236
func (d *DockerComposeAgentDeployer) agentHostname() string {
232237
return fmt.Sprintf("%s-%s", dockerTestAgentServiceName, d.agentRunID)
233238
}

internal/testrunner/script/agents.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func installAgent(ts *testscript.TestScript, neg bool, args []string) {
123123
ts.Setenv(*networkNameLabel, depInfo.NetworkName)
124124
}
125125
if *containerNameLabel != "" {
126-
ts.Setenv(*containerNameLabel, fmt.Sprintf("elastic-package-agent-%s-%s-%s-%s-1", filepath.Base(pkgRoot), ds, info.Test.RunID, depInfo.Name))
126+
ts.Setenv(*containerNameLabel, fmt.Sprintf("%s-%s-1", dep.ProjectName(info.Test.RunID), depInfo.Name))
127127
}
128128
polID := installed.deployed.Info().Policy.ID
129129
ts.Check(decoratedWith("getting kibana agent", doKibanaAgent(ctx, stk.kibana, func(a kibana.Agent) (bool, error) {

0 commit comments

Comments
 (0)