-
Notifications
You must be signed in to change notification settings - Fork 118
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create different agent per each test execution #1724
Conversation
Added maxUnavailable and maxSurge keys into elastic-agent template to allow wait for the pods created by the daemonset.
8064fe9
to
50ad13d
Compare
Containers are using the alias
Two different solutions here:
WDYT @jsoriano ? Should we go for the environment variables ? I tried also to not define
but doing so:
So, I tried to set the hostname for the agents directly in the docker-compose scenario. That hostname is shared (using environment variables) with the service, so they could run queries against elastic-agent if needed (e.g. send some logs). |
@@ -113,15 +117,14 @@ func (tsd TerraformServiceDeployer) SetUp(ctx context.Context, svcInfo ServiceIn | |||
env: tfEnvironment, | |||
shutdownTimeout: 300 * time.Second, | |||
} | |||
outCtxt := svcInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid creating a temporal variable
if r.options.RunTearDown || r.options.RunTestsOnly { | ||
logger.Debug("Skip creating output directory") | ||
} else { | ||
outputDir, err := servicedeployer.CreateOutputDir(r.locationManager, svcInfo.Test.RunID) | ||
if err != nil { | ||
return servicedeployer.ServiceInfo{}, fmt.Errorf("could not create output dir for terraform deployer %w", err) | ||
} | ||
svcInfo.OutputDir = outputDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that this folder is just created with --setup or regular testing commands.
The OutputDir and RunID values will be retrieved from ServiceState in case testing is run in stages (e.g. --no-provision)
serviceDeployer, err := servicedeployer.Factory(serviceOptions) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not create service runner: %w", err) | ||
// Configure package (single data stream) via Fleet APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move creation of test Agent Policy as one of the first steps, so it can be used to enroll the new agents.
// In case of custom agent (servicedeployer) enabling independent agents, update serviceOptions to include test policy too | ||
if r.options.RunIndependentElasticAgent { | ||
serviceOptions.PolicyName = agentInfo.Policy.Name | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, it is not set the Agent Policy name in all the scenarios, to avoid changing the current behaviour. Currently, in servicedeployer it is used the default policy Elastic-Agent (elastic-package)
💚 Build Succeeded
History
cc @mrodm |
This PR adds support to create a new agent per each test run.
Created a new module
agentdeployer
that is in charge of creating agents separately from theservicedeployer
module.Added a new environment variable ELASTIC_PACKAGE_TEST_ENABLE_INDEPENDENT_AGENT to enable creating independent agents for tests (system tests). In order to enable this feature, this environment variable must be set to
true
:Pending:
Use of tags in elastic agents instead of checking enrolling time ? https://www.elastic.co/guide/en/fleet/current/filter-agent-list-by-tags.html#add-tags-at-enrollmentelastic-agent
as a hostname to run requestselastic-agent
alias as previously.Kubernetes requires to use tags to try to distinguish from other agents.Filtered agents with Policy ID (created in advance)internal/service/boot.go
_dev/deploy/agent
) should be moved toagentdeployer
module?Relates #787