@@ -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.
118118func (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