Skip to content

Commit 78bd648

Browse files
Use ELASTICSEARCH_VERSION instead of fleet-server's version when downloading agent (#5246)
1 parent d30e22a commit 78bd648

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

testing/e2e/agent_install_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,20 @@ func (suite *AgentInstallSuite) SetupSuite() {
117117
// downloadAgent will search the artifacts repo for the latest snapshot and return the stream to the download for the current OS + ARCH.
118118
func (suite *AgentInstallSuite) downloadAgent(ctx context.Context) io.ReadCloser {
119119
suite.T().Helper()
120-
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://artifacts-api.elastic.co/v1/search/%s-SNAPSHOT", version.DefaultVersion), nil)
120+
// Use version associated with latest DRA instead of fleet-server's version to avoid breaking on fleet-server version bumps
121+
draVersion, ok := os.LookupEnv("ELASTICSEARCH_VERSION")
122+
if !ok || draVersion == "" {
123+
suite.T().Fatal("ELASTICSEARCH_VERSION is not set")
124+
}
125+
draSplit := strings.Split(draVersion, "-")
126+
if len(draSplit) == 3 {
127+
draVersion = draSplit[0] + "-" + draSplit[2] // remove hash
128+
} else if len(draSplit) > 3 {
129+
suite.T().Fatalf("Unsupported ELASTICSEARCH_VERSION format, expected 3 segments got: %s", draVersion)
130+
}
131+
suite.T().Logf("Using ELASTICSARCH_VERSION=%s", draVersion)
132+
133+
req, err := http.NewRequestWithContext(ctx, "GET", "https://artifacts-api.elastic.co/v1/search/"+draVersion, nil)
121134
suite.Require().NoError(err)
122135

123136
resp, err := suite.Client.Do(req)
@@ -141,7 +154,7 @@ func (suite *AgentInstallSuite) downloadAgent(ctx context.Context) io.ReadCloser
141154
arch = "aarch64"
142155
}
143156

144-
fileName := fmt.Sprintf("elastic-agent-%s-SNAPSHOT-%s-%s.%s", version.DefaultVersion, runtime.GOOS, arch, fType)
157+
fileName := fmt.Sprintf("elastic-agent-%s-%s-%s.%s", draVersion, runtime.GOOS, arch, fType)
145158
pkg, ok := body.Packages[fileName]
146159
suite.Require().Truef(ok, "unable to find package download for fileName = %s", fileName)
147160

0 commit comments

Comments
 (0)