Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Jun 19, 2024

Follows #1909
Part of #787

This PR creates a different deployer folder for each test. This will ensure that if at some point those kind of tests could be parallelized, they would not have issues creating all the resources in the same folder.

Currently, all resources are created in the same folder and they are not cleaned up after finishing the tests:

  • For packages using Terraform: ~/.elastic-package/deployer/terraform
  • For packages using custom agents: ~/.elastic-package/deployer/docker_custom_agent

For instance:

/home/user/.elastic-package/deployer/ ├── docker_custom_agent │   └── docker-custom-agent-base.yml 

This PR creates a new subfolder under those folders to create the resources needed for each test in different directories. For instance:

/home/user/.elastic-package/deployer/ ├── docker_custom_agent │   └── oracle-34417 │   └── docker-custom-agent-base.yml 
@mrodm mrodm self-assigned this Jun 19, 2024
@mrodm mrodm requested a review from a team as a code owner June 19, 2024 18:49
@mrodm mrodm changed the title Create different deployer folders Create different deployer folders per each test Jun 19, 2024
@mrodm mrodm force-pushed the create-different-deployer-folders branch from 5ef26eb to 56b3220 Compare June 19, 2024 18:58
)

configDir, err := d.installDockerfile()
configDir, err := d.installDockerfile(deployerFolderName(svcInfo))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could use go-resource to manage these files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated custom_agent to create the required files using go-resource.

Terraform (servicedeployer) was already using go-resource to create the required configuration files or scripts.

}

customAgentDir := filepath.Join(locationManager.DeployerDir(), dockerCustomAgentDir)
customAgentDir := filepath.Join(locationManager.DeployerDir(), dockerCustomAgentDir, folder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use tmp dirs for these files? Though probably we want them in more persistent places for test system --setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would prefer to keep them in these known/persistent locations.

Defined configDir into the agent or service struct instead of the service info or gent info, since it is not needed to use outside these structs/instances.
Comment on lines +64 to +72
func ProcessResourceApplyResults(results resource.ApplyResults) string {
var errors []string
for _, result := range results {
if err := result.Err(); err != nil {
errors = append(errors, err.Error())
}
}
return strings.Join(errors, ", ")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the helpers since it is going to be used in both agentdeployer and servicedeployer packages.

ymlPaths []string
project string
env []string
configDir string
Copy link
Contributor Author

@mrodm mrodm Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from agentInfo struct to be just defined here in the deployed agent.

Currently, this variable is not used outside this struct dockerComposeDeployedAgent, so it is not needed to keep it afterwards in the info struct.

@mrodm mrodm requested a review from jsoriano June 20, 2024 10:14
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm merged commit d87fda9 into elastic:main Jun 20, 2024
@mrodm mrodm deleted the create-different-deployer-folders branch June 20, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants