@@ -28,12 +28,14 @@ const ingestManagerDataStreamsURL = kibanaBaseURL + "/api/ingest_manager/data_st
2828
2929// FleetTestSuite represents the scenarios for Fleet-mode
3030type FleetTestSuite struct {
31- EnrolledAgentID string // will be used to store current agent
32- BoxType string // we currently support Linux
33- Cleanup bool
34- ConfigID string // will be used to manage tokens
35- CurrentToken string // current enrollment token
36- CurrentTokenID string // current enrollment tokenID
31+ AgentDownloadName string // the name for the binary
32+ AgentDownloadPath string // the path where the agent for the binary is installed
33+ EnrolledAgentID string // will be used to store current agent
34+ BoxType string // we currently support Linux
35+ Cleanup bool
36+ ConfigID string // will be used to manage tokens
37+ CurrentToken string // current enrollment token
38+ CurrentTokenID string // current enrollment tokenID
3739}
3840
3941func (fts * FleetTestSuite ) contributeSteps (s * godog.Suite ) {
@@ -56,7 +58,7 @@ func (fts *FleetTestSuite) anAgentIsDeployedToFleet() error {
5658 containerName := profile + "_" + serviceName + "_1" // name of the container
5759 serviceTag := "7" // docker tag of the service
5860
59- err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName )
61+ err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName , fts . AgentDownloadPath , fts . AgentDownloadName )
6062 if err != nil {
6163 return err
6264 }
@@ -87,6 +89,25 @@ func (fts *FleetTestSuite) anAgentIsDeployedToFleet() error {
8789 return err
8890}
8991
92+ // downloadAgentBinary it downloads the binary and stores the location of the downloaded file
93+ // into the Fleet struct, to be used else where
94+ func (fts * FleetTestSuite ) downloadAgentBinary () error {
95+ artifact := "elastic-agent"
96+ version := "8.0.0-SNAPSHOT"
97+ os := "linux"
98+ arch := "x86_64"
99+ extension := "tar.gz"
100+
101+ downloadURL , err := e2e .GetElasticArtifactURL (artifact , version , os , arch , extension )
102+ if err != nil {
103+ return err
104+ }
105+
106+ fts .AgentDownloadName = fmt .Sprintf ("%s-%s-%s-%s.%s" , artifact , version , os , arch , extension )
107+ fts .AgentDownloadPath , err = e2e .DownloadFile (downloadURL )
108+ return err
109+ }
110+
90111func (fts * FleetTestSuite ) setup () error {
91112 log .Debug ("Creating Fleet setup" )
92113
@@ -345,7 +366,7 @@ func (fts *FleetTestSuite) anAttemptToEnrollANewAgentFails() error {
345366
346367 containerName := profile + "_" + fts .BoxType + "_2" // name of the new container
347368
348- err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName )
369+ err := deployAgentToFleet (profile , fts .BoxType , serviceTag , containerName , fts . AgentDownloadPath , fts . AgentDownloadName )
349370 if err != nil {
350371 return err
351372 }
@@ -522,11 +543,14 @@ func createFleetToken(name string, configID string) (*gabs.Container, error) {
522543 return tokenItem , nil
523544}
524545
525- func deployAgentToFleet (profile string , service string , serviceTag string , containerName string ) error {
546+ func deployAgentToFleet (profile string , service string , serviceTag string , containerName string , agentBinaryPath string , agentBinaryName string ) error {
526547 // let's start with Centos 7
527548 profileEnv [service + "Tag" ] = serviceTag
528549 // we are setting the container name because Centos service could be reused by any other test suite
529550 profileEnv [service + "ContainerName" ] = containerName
551+ // define paths where the binary will be mounted
552+ profileEnv [service + "AgentBinarySrcPath" ] = agentBinaryPath
553+ profileEnv [service + "AgentBinaryTargetPath" ] = "/" + agentBinaryName
530554
531555 serviceManager := services .NewServiceManager ()
532556
@@ -539,34 +563,17 @@ func deployAgentToFleet(profile string, service string, serviceTag string, conta
539563 return err
540564 }
541565
542- // install the agent in the box
566+ // extract the agent in the box, as it's mounted as a volume
543567 artifact := "elastic-agent"
544568 version := "8.0.0-SNAPSHOT"
545569 os := "linux"
546570 arch := "x86_64"
547571 extension := "tar.gz"
548572
549- downloadURL , err := e2e .GetElasticArtifactURL (artifact , version , os , arch , extension )
550- if err != nil {
551- return err
552- }
553-
554- cmd := []string {"curl" , "-L" , "-O" , downloadURL }
555- err = execCommandInService (profile , service , cmd , false )
556- if err != nil {
557- log .WithFields (log.Fields {
558- "command" : cmd ,
559- "error" : err ,
560- "service" : service ,
561- }).Error ("Could not download agent in box" )
562-
563- return err
564- }
565-
566573 extractedDir := fmt .Sprintf ("%s-%s-%s-%s" , artifact , version , os , arch )
567574 tarFile := fmt .Sprintf ("%s.%s" , extractedDir , extension )
568575
569- cmd = []string {"tar" , "xzvf" , tarFile }
576+ cmd : = []string {"tar" , "xzvf" , tarFile }
570577 err = execCommandInService (profile , service , cmd , false )
571578 if err != nil {
572579 log .WithFields (log.Fields {
0 commit comments