-
Notifications
You must be signed in to change notification settings - Fork 214
Add custom ECH deployment + smoke test #8337
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
Merged
michel-laterman
merged 45 commits into
elastic:main
from
michel-laterman:integration-tests-custom-image
Jul 11, 2025
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
2fbec62
Use a custom image for the ECH deployment when running integration tests
michel-laterman 4ee3fb3
Use per-step env vars
michel-laterman 37d02bd
Update TF_VAR
michel-laterman 48f3eff
Merge branch 'main' into integration-tests-custom-image
michel-laterman 4f1bee1
remove extra FIPS var manipulation
michel-laterman 1470af2
Merge branch 'main' into integration-tests-custom-image
michel-laterman dddab2e
Merge branch 'main' into integration-tests-custom-image
michel-laterman f6cb9aa
Merge branch 'main' into integration-tests-custom-image
michel-laterman 97d97c4
Correct merge
michel-laterman d5b18dc
Merge branch 'main' into integration-tests-custom-image
michel-laterman d47df46
Use plugin instead of pre-command hook
michel-laterman d7e0190
Fix image tag
michel-laterman 47121af
Merge branch 'main' into integration-tests-custom-image
michel-laterman ea0aad4
Merge branch 'main' into integration-tests-custom-image
michel-laterman 7136397
Merge branch 'main' into integration-tests-custom-image
michel-laterman 67a50d4
Use top level env vars
michel-laterman 3adcb4c
Merge branch 'main' into integration-tests-custom-image
michel-laterman 041fa59
Do not use top level env due to cross polution
michel-laterman 1d11d9b
Call cloud:load and cloud:push from packaging step
michel-laterman 3abc4c1
Add ECH test + group
michel-laterman 04b9c1a
Remove extra depends on
michel-laterman c1d8f99
text fix
michel-laterman 9c58a47
Fix typo in test
michel-laterman c371ff8
Merge branch 'main' into integration-tests-custom-image
michel-laterman 954946a
Use dedicate script to provision and run ECH tests
michel-laterman 900c3c2
Fix missing plugins
michel-laterman ab7795d
Fix packaging step
michel-laterman 7618874
Fix package name
michel-laterman 5776aa9
Merge branch 'main' into integration-tests-custom-image
michel-laterman be85989
bump tf version, fix group
michel-laterman cad8424
Fix package import
michel-laterman 344f8c8
Merge branch 'main' into integration-tests-custom-image
michel-laterman ee3d32b
Review feedback
michel-laterman fde5126
Add vault plugin
michel-laterman 6d90a53
remove extra line from packaging
michel-laterman 641052a
Fix typo
michel-laterman d89c99d
revert ASDF_terraform_version
michel-laterman a6c10cc
fix asdf_terrafrom_version
michel-laterman 0f30c34
Add missing args
michel-laterman 7ed4952
Add TEST_PACKAGE env var
michel-laterman b380f63
Review feedback
michel-laterman a57debb
Merge branch 'main' into integration-tests-custom-image
michel-laterman fa88b18
Fix args
michel-laterman ea71e70
Merge branch 'main' into integration-tests-custom-image
michel-laterman 68339f6
Review feedback
michel-laterman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| //go:build integration | ||
|
|
||
| package ess | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "net/http" | ||
| "net/url" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/gofrs/uuid/v5" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/elastic/elastic-agent-libs/kibana" | ||
| "github.com/elastic/elastic-agent/pkg/control/v2/cproto" | ||
| atesting "github.com/elastic/elastic-agent/pkg/testing" | ||
| "github.com/elastic/elastic-agent/pkg/testing/define" | ||
| "github.com/elastic/elastic-agent/pkg/testing/tools/fleettools" | ||
| "github.com/elastic/elastic-agent/testing/integration" | ||
| ) | ||
|
|
||
| func TestECH(t *testing.T) { | ||
| info := define.Require(t, define.Requirements{ | ||
| Group: integration.ECH, | ||
| Stack: &define.Stack{}, | ||
| Sudo: true, | ||
| Local: false, | ||
| OS: []define.OS{ | ||
| { | ||
| Type: define.Linux, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| // Check that the Fleet Server in the deployment is healthy | ||
| fleetServerHost, err := fleettools.DefaultURL(t.Context(), info.KibanaClient) | ||
| statusUrl, err := url.JoinPath(fleetServerHost, "/api/status") | ||
| require.NoError(t, err) | ||
|
|
||
| require.EventuallyWithT(t, func(c *assert.CollectT) { | ||
| resp, err := http.Get(statusUrl) | ||
| require.NoError(c, err) | ||
| defer resp.Body.Close() | ||
|
|
||
| require.Equal(c, http.StatusOK, resp.StatusCode) | ||
|
|
||
| var body struct { | ||
| Name string `json:"name"` | ||
| Status string `json:"status"` | ||
| } | ||
| err = json.NewDecoder(resp.Body).Decode(&body) | ||
| require.NoError(c, err) | ||
|
|
||
| t.Logf("body.status = %s", body.Status) | ||
| require.Equal(c, "HEALTHY", body.Status) | ||
| }, 5*time.Minute, 10*time.Second, "Fleet Server in ECH deployment is not healthy") | ||
|
|
||
| // Create a policy and install an agent | ||
| policyUUID := uuid.Must(uuid.NewV4()).String() | ||
| policy := kibana.AgentPolicy{ | ||
| Name: "testloglevel-policy-" + policyUUID, | ||
| Namespace: "default", | ||
| Description: "Test Log Level Policy " + policyUUID, | ||
| MonitoringEnabled: []kibana.MonitoringEnabledOption{}, | ||
| } | ||
| t.Log("Creating Agent policy...") | ||
| policyResp, err := info.KibanaClient.CreatePolicy(t.Context(), policy) | ||
| require.NoError(t, err, "failed creating policy") | ||
|
|
||
| t.Log("Creating Agent enrollment API key...") | ||
| createEnrollmentApiKeyReq := kibana.CreateEnrollmentAPIKeyRequest{ | ||
| PolicyID: policyResp.ID, | ||
| } | ||
| enrollmentToken, err := info.KibanaClient.CreateEnrollmentAPIKey(t.Context(), createEnrollmentApiKeyReq) | ||
| require.NoError(t, err, "failed creating enrollment API key") | ||
| t.Logf("Created policy %+v", policyResp.AgentPolicy) | ||
|
|
||
| fixture, err := define.NewFixtureFromLocalBuild(t, define.Version()) | ||
| require.NoError(t, err) | ||
| err = fixture.Prepare(t.Context()) | ||
| require.NoError(t, err) | ||
|
|
||
| opts := &atesting.InstallOpts{ | ||
| Force: true, | ||
| Privileged: true, | ||
| EnrollOpts: atesting.EnrollOpts{ | ||
| URL: fleetServerHost, | ||
| EnrollmentToken: enrollmentToken.APIKey, | ||
| }, | ||
| } | ||
| out, err := fixture.Install(t.Context(), opts) | ||
| if err != nil { | ||
| t.Logf("install output: %s", out) | ||
| require.NoError(t, err) | ||
| } | ||
|
|
||
| var agentID string | ||
| require.EventuallyWithT(t, func(c *assert.CollectT) { | ||
| status, err := fixture.ExecStatus(t.Context()) | ||
| require.NoError(c, err) | ||
| statusBuffer := new(strings.Builder) | ||
| err = json.NewEncoder(statusBuffer).Encode(status) | ||
| require.NoError(c, err) | ||
| t.Logf("agent status: %v", statusBuffer.String()) | ||
|
|
||
| require.Equal(c, int(cproto.State_HEALTHY), status.State, "agent state is not healthy") | ||
| require.Equal(c, int(cproto.State_HEALTHY), status.FleetState, "agent's fleet-server state is not healthy") | ||
| agentID = status.Info.ID | ||
| }, time.Minute, time.Second, "agent never became healthy or connected to Fleet") | ||
|
|
||
| require.EventuallyWithT(t, func(c *assert.CollectT) { | ||
| status, err := fleettools.GetAgentStatus(t.Context(), info.KibanaClient, agentID) | ||
| require.NoError(c, err) | ||
| require.Equal(c, "online", status) | ||
| }, time.Minute, time.Second, "agent does not show as online in fleet") | ||
|
|
||
| t.Run("run uninstall", testUninstallAuditUnenroll(t.Context(), fixture, info)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.