From c12c9ae020ecdbfa2510ed675222f1549a2e1e01 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Tue, 20 Oct 2020 09:16:34 +0200 Subject: [PATCH 1/2] small fixes --- e2e/_suites/ingest-manager/fleet.go | 14 +++++++------- e2e/_suites/ingest-manager/services.go | 5 +++++ e2e/_suites/ingest-manager/stand-alone.go | 2 +- e2e/go.mod | 1 + e2e/utils.go | 10 +++++++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/e2e/_suites/ingest-manager/fleet.go b/e2e/_suites/ingest-manager/fleet.go index 263a25dd4a..982cc18bca 100644 --- a/e2e/_suites/ingest-manager/fleet.go +++ b/e2e/_suites/ingest-manager/fleet.go @@ -18,13 +18,13 @@ import ( log "github.com/sirupsen/logrus" ) -const fleetAgentsURL = kibanaBaseURL + "/api/ingest_manager/fleet/agents" -const fleetAgentEventsURL = kibanaBaseURL + "/api/ingest_manager/fleet/agents/%s/events" -const fleetAgentsUnEnrollURL = kibanaBaseURL + "/api/ingest_manager/fleet/agents/%s/unenroll" -const fleetEnrollmentTokenURL = kibanaBaseURL + "/api/ingest_manager/fleet/enrollment-api-keys" -const fleetSetupURL = kibanaBaseURL + "/api/ingest_manager/fleet/setup" -const ingestManagerAgentPoliciesURL = kibanaBaseURL + "/api/ingest_manager/agent_policies" -const ingestManagerDataStreamsURL = kibanaBaseURL + "/api/ingest_manager/data_streams" +const fleetAgentsURL = kibanaBaseURL + "/api/fleet/agents" +const fleetAgentEventsURL = kibanaBaseURL + "/api/fleet/agents/%s/events" +const fleetAgentsUnEnrollURL = kibanaBaseURL + "/api/fleet/agents/%s/unenroll" +const fleetEnrollmentTokenURL = kibanaBaseURL + "/api/fleet/enrollment-api-keys" +const fleetSetupURL = kibanaBaseURL + "/api/fleet/agents/setup" +const ingestManagerAgentPoliciesURL = kibanaBaseURL + "/api/fleet/agent_policies" +const ingestManagerDataStreamsURL = kibanaBaseURL + "/api/fleet/data_streams" const actionADDED = "added" const actionREMOVED = "removed" diff --git a/e2e/_suites/ingest-manager/services.go b/e2e/_suites/ingest-manager/services.go index ce80d27f32..b7da35e2ad 100644 --- a/e2e/_suites/ingest-manager/services.go +++ b/e2e/_suites/ingest-manager/services.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "path" "strings" "github.com/elastic/e2e-testing/cli/config" @@ -118,10 +119,14 @@ func downloadAgentBinary(artifact string, version string, OS string, arch string fileName := fmt.Sprintf("%s-%s-%s.%s", artifact, version, arch, extension) if downloadURL, exists := os.LookupEnv("ELASTIC_AGENT_DOWNLOAD_URL"); exists { + log.Error("tu som") + // replace tar gz with correct extension + downloadURL = path.Join(downloadURL, fileName) filePath, err := e2e.DownloadFile(downloadURL) return fileName, filePath, err } + log.Error("tu som 2 ") var downloadURL string var err error diff --git a/e2e/_suites/ingest-manager/stand-alone.go b/e2e/_suites/ingest-manager/stand-alone.go index a498d742b3..9938f17fe0 100644 --- a/e2e/_suites/ingest-manager/stand-alone.go +++ b/e2e/_suites/ingest-manager/stand-alone.go @@ -300,7 +300,7 @@ func searchAgentData(hostname string, startDate time.Time, minimumHitsCount int, }, } - indexName := "logs-elastic.agent-default" + indexName := "logs-elastic_agent-default" result, err := e2e.WaitForNumberOfHits(indexName, esQuery, minimumHitsCount, maxTimeout) if err != nil { diff --git a/e2e/go.mod b/e2e/go.mod index 6ad7751c0d..b23989d3ad 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -6,6 +6,7 @@ require ( github.com/Jeffail/gabs/v2 v2.5.1 github.com/cenkalti/backoff/v4 v4.0.2 github.com/cucumber/godog v0.10.0 + github.com/cucumber/messages-go/v10 v10.0.3 github.com/elastic/e2e-testing/cli v0.0.0-20200717181709-15d2db53ded7 github.com/elastic/go-elasticsearch/v8 v8.0.0-20190731061900-ea052088db25 github.com/sirupsen/logrus v1.4.2 diff --git a/e2e/utils.go b/e2e/utils.go index af31b563c5..7eaf20d032 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -233,6 +233,14 @@ func GetObjectURLFromBucket(bucket string, object string) (string, error) { // It writes to the destination file as it downloads it, without // loading the entire file into memory. func DownloadFile(url string) (string, error) { + var filepath string + + if strings.HasPrefix(url, "file:") { + log.Error("tu som 3", url) + return strings.TrimPrefix(url, "file://"), nil + } + log.Error("tu som 4", url) + tempFile, err := ioutil.TempFile(os.TempDir(), path.Base(url)) if err != nil { log.WithFields(log.Fields{ @@ -243,7 +251,7 @@ func DownloadFile(url string) (string, error) { } defer tempFile.Close() - filepath := tempFile.Name() + filepath = tempFile.Name() exp := GetExponentialBackOff(3) From 87d75cf6fb5e118a31a40b776d168aecb5b185f8 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Tue, 20 Oct 2020 09:21:48 +0200 Subject: [PATCH 2/2] cleanup --- e2e/_suites/fleet/services.go | 5 ----- e2e/go.mod | 1 - e2e/utils.go | 10 +--------- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/e2e/_suites/fleet/services.go b/e2e/_suites/fleet/services.go index 29e6b875ed..95f582bd8f 100644 --- a/e2e/_suites/fleet/services.go +++ b/e2e/_suites/fleet/services.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "path" "strings" "github.com/elastic/e2e-testing/cli/config" @@ -119,14 +118,10 @@ func downloadAgentBinary(artifact string, version string, OS string, arch string fileName := fmt.Sprintf("%s-%s-%s.%s", artifact, version, arch, extension) if downloadURL, exists := os.LookupEnv("ELASTIC_AGENT_DOWNLOAD_URL"); exists { - log.Error("tu som") - // replace tar gz with correct extension - downloadURL = path.Join(downloadURL, fileName) filePath, err := e2e.DownloadFile(downloadURL) return fileName, filePath, err } - log.Error("tu som 2 ") var downloadURL string var err error diff --git a/e2e/go.mod b/e2e/go.mod index b23989d3ad..6ad7751c0d 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -6,7 +6,6 @@ require ( github.com/Jeffail/gabs/v2 v2.5.1 github.com/cenkalti/backoff/v4 v4.0.2 github.com/cucumber/godog v0.10.0 - github.com/cucumber/messages-go/v10 v10.0.3 github.com/elastic/e2e-testing/cli v0.0.0-20200717181709-15d2db53ded7 github.com/elastic/go-elasticsearch/v8 v8.0.0-20190731061900-ea052088db25 github.com/sirupsen/logrus v1.4.2 diff --git a/e2e/utils.go b/e2e/utils.go index 7eaf20d032..af31b563c5 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -233,14 +233,6 @@ func GetObjectURLFromBucket(bucket string, object string) (string, error) { // It writes to the destination file as it downloads it, without // loading the entire file into memory. func DownloadFile(url string) (string, error) { - var filepath string - - if strings.HasPrefix(url, "file:") { - log.Error("tu som 3", url) - return strings.TrimPrefix(url, "file://"), nil - } - log.Error("tu som 4", url) - tempFile, err := ioutil.TempFile(os.TempDir(), path.Base(url)) if err != nil { log.WithFields(log.Fields{ @@ -251,7 +243,7 @@ func DownloadFile(url string) (string, error) { } defer tempFile.Close() - filepath = tempFile.Name() + filepath := tempFile.Name() exp := GetExponentialBackOff(3)