From d9e3b5169e4154add3c3489c34c300e7eb88cf4c Mon Sep 17 00:00:00 2001 From: Adam Stokes <51892+adam-stokes@users.noreply.github.com> Date: Tue, 6 Apr 2021 11:55:00 -0400 Subject: [PATCH 1/2] Uniquify the stand-alone step for checking agent status (#993) There were 2 steps identical in both the stand-alone and fleet test suites. Running the stand-alone test suite was picking up the step from the fleet test suite and trying to reference the FleetTestSuite structure which did not hold any of the agent information (like the hostname) for the stand alone tests. This fixes it so that the standalone test step is being referenced in the correct test suite. Signed-off-by: Adam Stokes <51892+adam-stokes@users.noreply.github.com> --- e2e/_suites/fleet/features/stand_alone_agent.feature | 2 +- e2e/_suites/fleet/stand-alone.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/_suites/fleet/features/stand_alone_agent.feature b/e2e/_suites/fleet/features/stand_alone_agent.feature index af05676a92..78af314844 100644 --- a/e2e/_suites/fleet/features/stand_alone_agent.feature +++ b/e2e/_suites/fleet/features/stand_alone_agent.feature @@ -54,7 +54,7 @@ Examples: Ubi8 @run_fleet_server Scenario Outline: Deploying a stand-alone agent with fleet server mode When a "" stand-alone agent is deployed with fleet server mode - Then the agent is listed in Fleet as "online" + Then the stand-alone agent is listed in Fleet as "online" @default Examples: default diff --git a/e2e/_suites/fleet/stand-alone.go b/e2e/_suites/fleet/stand-alone.go index 9f219ee323..4f6ea68f89 100644 --- a/e2e/_suites/fleet/stand-alone.go +++ b/e2e/_suites/fleet/stand-alone.go @@ -68,7 +68,7 @@ func (sats *StandAloneTestSuite) contributeSteps(s *godog.ScenarioContext) { s.Step(`^there is new data in the index from agent$`, sats.thereIsNewDataInTheIndexFromAgent) s.Step(`^the "([^"]*)" docker container is stopped$`, sats.theDockerContainerIsStopped) s.Step(`^there is no new data in the index after agent shuts down$`, sats.thereIsNoNewDataInTheIndexAfterAgentShutsDown) - s.Step(`^the agent is listed in Fleet as "([^"]*)"$`, sats.theAgentIsListedInFleetWithStatus) + s.Step(`^the stand-alone agent is listed in Fleet as "([^"]*)"$`, sats.theAgentIsListedInFleetWithStatus) } func (sats *StandAloneTestSuite) theAgentIsListedInFleetWithStatus(desiredStatus string) error { From 9aeb82ce5adfa36bae8ed5853c77879730dd3d57 Mon Sep 17 00:00:00 2001 From: Adam Stokes <51892+adam-stokes@users.noreply.github.com> Date: Thu, 8 Apr 2021 05:30:03 -0400 Subject: [PATCH 2/2] Remove the agent config file parameters for stand alone (#983) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adam Stokes <51892+adam-stokes@users.noreply.github.com> Co-authored-by: Manuel de la Peña --- .../services/elastic-agent/docker-compose.yml | 2 -- e2e/_suites/fleet/stand-alone.go | 33 +++---------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/cli/config/compose/services/elastic-agent/docker-compose.yml b/cli/config/compose/services/elastic-agent/docker-compose.yml index c5c0180254..ff855ce544 100644 --- a/cli/config/compose/services/elastic-agent/docker-compose.yml +++ b/cli/config/compose/services/elastic-agent/docker-compose.yml @@ -19,5 +19,3 @@ services: platform: ${elasticAgentPlatform:-linux/amd64} ports: - "127.0.0.1:8220:8220" - volumes: - - "${elasticAgentConfigFile}:/usr/share/elastic-agent/elastic-agent.yml" diff --git a/e2e/_suites/fleet/stand-alone.go b/e2e/_suites/fleet/stand-alone.go index 4f6ea68f89..f516bdd586 100644 --- a/e2e/_suites/fleet/stand-alone.go +++ b/e2e/_suites/fleet/stand-alone.go @@ -7,7 +7,6 @@ package main import ( "context" "fmt" - "os" "strings" "time" @@ -22,10 +21,9 @@ import ( // StandAloneTestSuite represents the scenarios for Stand-alone-mode type StandAloneTestSuite struct { - AgentConfigFilePath string - Cleanup bool - Hostname string - Image string + Cleanup bool + Hostname string + Image string // date controls for queries AgentStoppedDate time.Time RuntimeDependenciesStartDate time.Time @@ -45,21 +43,6 @@ func (sats *StandAloneTestSuite) afterScenario() { } else { log.WithField("service", serviceName).Info("Because we are running in development mode, the service won't be stopped") } - - if _, err := os.Stat(sats.AgentConfigFilePath); err == nil { - beatsLocalPath := shell.GetEnv("BEATS_LOCAL_PATH", "") - if beatsLocalPath == "" { - os.Remove(sats.AgentConfigFilePath) - - log.WithFields(log.Fields{ - "path": sats.AgentConfigFilePath, - }).Trace("Elastic Agent configuration file removed.") - } else { - log.WithFields(log.Fields{ - "path": sats.AgentConfigFilePath, - }).Trace("Elastic Agent configuration file not removed because it's part of a repository.") - } - } } func (sats *StandAloneTestSuite) contributeSteps(s *godog.ScenarioContext) { @@ -102,11 +85,6 @@ func (sats *StandAloneTestSuite) startAgent(image string, env map[string]string) dockerImageTag += "-amd64" } - configurationFilePath, err := steps.FetchBeatConfiguration(true, "elastic-agent", "elastic-agent.docker.yml") - if err != nil { - return err - } - serviceManager := services.NewServiceManager() profileEnv["elasticAgentDockerImageSuffix"] = "" @@ -118,10 +96,7 @@ func (sats *StandAloneTestSuite) startAgent(image string, env map[string]string) containerName := fmt.Sprintf("%s_%s_%d", FleetProfileName, ElasticAgentServiceName, 1) - sats.AgentConfigFilePath = configurationFilePath - profileEnv["elasticAgentContainerName"] = containerName - profileEnv["elasticAgentConfigFile"] = sats.AgentConfigFilePath profileEnv["elasticAgentPlatform"] = "linux/amd64" profileEnv["elasticAgentTag"] = dockerImageTag @@ -129,7 +104,7 @@ func (sats *StandAloneTestSuite) startAgent(image string, env map[string]string) profileEnv[k] = v } - err = serviceManager.AddServicesToCompose(context.Background(), FleetProfileName, []string{ElasticAgentServiceName}, profileEnv) + err := serviceManager.AddServicesToCompose(context.Background(), FleetProfileName, []string{ElasticAgentServiceName}, profileEnv) if err != nil { log.Error("Could not deploy the elastic-agent") return err