@@ -24,12 +24,14 @@ const ingestManagerDataStreamsURL = kibanaBaseURL + "/api/ingest_manager/data_st
2424
2525// FleetTestSuite represents the scenarios for Fleet-mode
2626type FleetTestSuite struct {
27- EnrolledAgentID string // will be used to store current agent
28- BoxType string // we currently support Linux
29- Cleanup bool
30- ConfigID string // will be used to manage tokens
31- CurrentToken string // current enrollment token
32- CurrentTokenID string // current enrollment tokenID
27+ AgentDownloadName string // the name for the binary
28+ AgentDownloadPath string // the path where the agent for the binary is installed
29+ EnrolledAgentID string // will be used to store current agent
30+ BoxType string // we currently support Linux
31+ Cleanup bool
32+ ConfigID string // will be used to manage tokens
33+ CurrentToken string // current enrollment token
34+ CurrentTokenID string // current enrollment tokenID
3335}
3436
3537func (fts * FleetTestSuite ) contributeSteps (s * godog.Suite ) {
@@ -52,7 +54,7 @@ func (fts *FleetTestSuite) anAgentIsDeployedToFleet() error {
5254 containerName := profile + "_" + serviceName + "_1" // name of the container
5355 serviceTag := "7" // docker tag of the service
5456
55- err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName )
57+ err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName , fts . AgentDownloadPath , fts . AgentDownloadName )
5658 if err != nil {
5759 return err
5860 }
@@ -83,6 +85,25 @@ func (fts *FleetTestSuite) anAgentIsDeployedToFleet() error {
8385 return err
8486}
8587
88+ // downloadAgentBinary it downloads the binary and stores the location of the downloaded file
89+ // into the Fleet struct, to be used else where
90+ func (fts * FleetTestSuite ) downloadAgentBinary () error {
91+ artifact := "elastic-agent"
92+ version := "8.0.0-SNAPSHOT"
93+ os := "linux"
94+ arch := "x86_64"
95+ extension := "tar.gz"
96+
97+ downloadURL , err := e2e .GetElasticArtifactURL (artifact , version , os , arch , extension )
98+ if err != nil {
99+ return err
100+ }
101+
102+ fts .AgentDownloadName = fmt .Sprintf ("%s-%s-%s-%s.%s" , artifact , version , os , arch , extension )
103+ fts .AgentDownloadPath , err = e2e .DownloadFile (downloadURL )
104+ return err
105+ }
106+
86107func (fts * FleetTestSuite ) setup () error {
87108 log .Debug ("Creating Fleet setup" )
88109
@@ -341,7 +362,7 @@ func (fts *FleetTestSuite) anAttemptToEnrollANewAgentFails() error {
341362
342363 containerName := profile + "_" + fts .BoxType + "_2" // name of the new container
343364
344- err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName )
365+ err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName , fts . AgentDownloadPath , fts . AgentDownloadName )
345366 if err != nil {
346367 return err
347368 }
@@ -518,11 +539,14 @@ func createFleetToken(name string, configID string) (*gabs.Container, error) {
518539 return tokenItem , nil
519540}
520541
521- func deployAgentToFleet (profile string , service string , serviceTag string , containerName string ) error {
542+ func deployAgentToFleet (profile string , service string , serviceTag string , containerName string , agentBinaryPath string , agentBinaryName string ) error {
522543 // let's start with Centos 7
523544 profileEnv [service + "Tag" ] = serviceTag
524545 // we are setting the container name because Centos service could be reused by any other test suite
525546 profileEnv [service + "ContainerName" ] = containerName
547+ // define paths where the binary will be mounted
548+ profileEnv [service + "AgentBinarySrcPath" ] = agentBinaryPath
549+ profileEnv [service + "AgentBinaryTargetPath" ] = "/" + agentBinaryName
526550
527551 serviceManager := services .NewServiceManager ()
528552
@@ -535,34 +559,17 @@ func deployAgentToFleet(profile string, service string, serviceTag string, conta
535559 return err
536560 }
537561
538- // install the agent in the box
562+ // extract the agent in the box, as it's mounted as a volume
539563 artifact := "elastic-agent"
540564 version := "8.0.0-SNAPSHOT"
541565 os := "linux"
542566 arch := "x86_64"
543567 extension := "tar.gz"
544568
545- downloadURL , err := e2e .GetElasticArtifactURL (artifact , version , os , arch , extension )
546- if err != nil {
547- return err
548- }
549-
550- cmd := []string {"curl" , "-L" , "-O" , downloadURL }
551- err = execCommandInService (profile , service , cmd , false )
552- if err != nil {
553- log .WithFields (log.Fields {
554- "command" : cmd ,
555- "error" : err ,
556- "service" : service ,
557- }).Error ("Could not download agent in box" )
558-
559- return err
560- }
561-
562569 extractedDir := fmt .Sprintf ("%s-%s-%s-%s" , artifact , version , os , arch )
563570 tarFile := fmt .Sprintf ("%s.%s" , extractedDir , extension )
564571
565- cmd = []string {"tar" , "xzvf" , tarFile }
572+ cmd : = []string {"tar" , "xzvf" , tarFile }
566573 err = execCommandInService (profile , service , cmd , false )
567574 if err != nil {
568575 log .WithFields (log.Fields {
0 commit comments