Skip to content

Commit 69a1798

Browse files
authored
Configure fakeintake override after update env (#43409)
### What does this PR do? Configure the fakeintake override after update env ### Motivation It can happen that `UpdateEnv` needs to recreate the fakeintake, which removes the override. This should fix it. I needed to increase the timeout as the agent checks api key health every minute in the test, so we need to wait more than 1min. ### Describe how you validated your changes CI ### Additional Notes Ideally the framework should be fixed to avoid this issue. Co-authored-by: pierre.gimalac <[email protected]>
1 parent 5acfb51 commit 69a1798

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/new-e2e/tests/agent-subcommands/health/health_common_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,29 @@ func (v *baseHealthSuite) TestDefaultInstallHealthy() {
4747
}
4848

4949
func (v *baseHealthSuite) TestDefaultInstallUnhealthy() {
50+
// restart the agent, which validates the key using the fakeintake at startup
51+
v.UpdateEnv(awshost.Provisioner(
52+
awshost.WithEC2InstanceOptions(ec2.WithOS(v.descriptor)),
53+
awshost.WithAgentOptions(agentparams.WithAgentConfig("log_level: info\nforwarder_apikey_validation_interval: 1")),
54+
))
55+
5056
// the fakeintake says that any API key is invalid by sending a 403 code
5157
override := api.ResponseOverride{
5258
Endpoint: "/api/v1/validate",
5359
StatusCode: 403,
5460
Method: http.MethodGet,
5561
Body: []byte("invalid API key"),
5662
}
63+
5764
err := v.Env().FakeIntake.Client().ConfigureOverride(override)
5865
require.NoError(v.T(), err)
5966

60-
// restart the agent, which validates the key using the fakeintake at startup
61-
v.UpdateEnv(awshost.Provisioner(
62-
awshost.WithEC2InstanceOptions(ec2.WithOS(v.descriptor)),
63-
awshost.WithAgentOptions(agentparams.WithAgentConfig("log_level: info\nforwarder_apikey_validation_interval: 1")),
64-
))
65-
6667
require.EventuallyWithT(v.T(), func(collect *assert.CollectT) {
67-
// forwarder should be unhealthy because the key is invalid
68+
// forwarder should become unhealthy when next checking because the fakeintake will return 403
6869
_, err = v.Env().Agent.Client.Health()
6970
assert.ErrorContains(collect, err, "Agent health: FAIL")
7071
assert.ErrorContains(collect, err, "=== 1 unhealthy components ===\nforwarder")
71-
}, time.Second*30, time.Second)
72+
}, 2*time.Minute, 10*time.Second)
7273

7374
// the fakeintake now says that the api key is valid
7475
override.StatusCode = 200

0 commit comments

Comments
 (0)