From e2c68727f342018b66bb915c186339f27614f7e6 Mon Sep 17 00:00:00 2001 From: Annanay Agarwal Date: Tue, 17 Aug 2021 18:30:18 +0530 Subject: [PATCH] Add e2e integrations test for GCS (#883) Signed-off-by: Annanay --- integration/e2e/backend/backend.go | 55 +++++++++++++++++++++- integration/e2e/config-all-in-one-gcs.yaml | 36 ++++++++++++++ integration/e2e/e2e_test.go | 5 ++ integration/util.go | 29 +++--------- 4 files changed, 101 insertions(+), 24 deletions(-) create mode 100644 integration/e2e/config-all-in-one-gcs.yaml diff --git a/integration/e2e/backend/backend.go b/integration/e2e/backend/backend.go index 6d68c248154..3478b9f3c73 100644 --- a/integration/e2e/backend/backend.go +++ b/integration/e2e/backend/backend.go @@ -13,9 +13,15 @@ import ( "github.com/grafana/tempo/tempodb/backend/azure" ) +const ( + azuriteImage = "mcr.microsoft.com/azure-storage/azurite" + gcsImage = "fsouza/fake-gcs-server" +) + func parsePort(endpoint string) (int, error) { substrings := strings.Split(endpoint, ":") - port, err := strconv.Atoi(substrings[len(substrings)-1]) + portStrings := strings.Split(substrings[len(substrings)-1], "/") + port, err := strconv.Atoi(portStrings[0]) if err != nil { return 0, err } @@ -43,7 +49,7 @@ func New(scenario *e2e.Scenario, cfg app.Config) (*e2e.HTTPService, error) { if err != nil { return nil, err } - backendService = util.NewAzurite(port) + backendService = NewAzurite(port) err = scenario.StartAndWaitReady(backendService) if err != nil { return nil, err @@ -53,7 +59,52 @@ func New(scenario *e2e.Scenario, cfg app.Config) (*e2e.HTTPService, error) { if err != nil { return nil, err } + case "gcs": + port, err := parsePort(cfg.StorageConfig.Trace.GCS.Endpoint) + if err != nil { + return nil, err + } + backendService = NewGCS(port) + if backendService == nil { + return nil, fmt.Errorf("error creating gcs backend") + } + err = scenario.StartAndWaitReady(backendService) + if err != nil { + return nil, err + } } return backendService, nil } + +func NewAzurite(port int) *e2e.HTTPService { + s := e2e.NewHTTPService( + "azurite", + azuriteImage, // Create the the azurite container + e2e.NewCommandWithoutEntrypoint("sh", "-c", "azurite -l /data --blobHost 0.0.0.0"), + e2e.NewHTTPReadinessProbe(port, "/devstoreaccount1?comp=list", 403, 403), //If we get 403 the Azurite is ready + port, // blob storage port + ) + + s.SetBackoff(util.TempoBackoff()) + + return s +} + +func NewGCS(port int) *e2e.HTTPService { + commands := []string{ + "mkdir -p /data/tempo", + "/bin/fake-gcs-server -data /data -public-host=tempo_e2e-gcs -port=4443", + } + s := e2e.NewHTTPService( + "gcs", + gcsImage, // Create the the gcs container + e2e.NewCommandWithoutEntrypoint("sh", "-c", strings.Join(commands, " && ")), + e2e.NewHTTPReadinessProbe(port, "/", 400, 400), // for lack of a better way, readiness probe does not support https at the moment + port, + ) + + s.SetBackoff(util.TempoBackoff()) + + return s +} diff --git a/integration/e2e/config-all-in-one-gcs.yaml b/integration/e2e/config-all-in-one-gcs.yaml new file mode 100644 index 00000000000..7b91e5bf707 --- /dev/null +++ b/integration/e2e/config-all-in-one-gcs.yaml @@ -0,0 +1,36 @@ +target: all + +server: + http_listen_port: 3200 + +distributor: + receivers: + jaeger: + protocols: + grpc: + +ingester: + lifecycler: + address: 127.0.0.1 + ring: + kvstore: + store: inmemory + replication_factor: 1 + final_sleep: 0s + trace_idle_period: 100ms + max_block_bytes: 1 + max_block_duration: 2s + complete_block_timeout: 1s + flush_check_period: 1s + +storage: + trace: + blocklist_poll: 2s + backend: gcs + gcs: + bucket_name: tempo + endpoint: https://tempo_e2e-gcs:4443/storage/v1/ + insecure: true + pool: + max_workers: 10 + queue_depth: 1000 diff --git a/integration/e2e/e2e_test.go b/integration/e2e/e2e_test.go index 60688fc42e5..6cd2a427052 100644 --- a/integration/e2e/e2e_test.go +++ b/integration/e2e/e2e_test.go @@ -31,6 +31,7 @@ const ( configAllInOneS3 = "config-all-in-one-s3.yaml" configAllInOneAzurite = "config-all-in-one-azurite.yaml" + configAllInOneGCS = "config-all-in-one-gcs.yaml" ) func TestAllInOne(t *testing.T) { @@ -46,6 +47,10 @@ func TestAllInOne(t *testing.T) { name: "azure", configFile: configAllInOneAzurite, }, + { + name: "gcs", + configFile: configAllInOneGCS, + }, } for _, tc := range testBackends { diff --git a/integration/util.go b/integration/util.go index a11bf2664dd..78425d29a55 100644 --- a/integration/util.go +++ b/integration/util.go @@ -16,8 +16,7 @@ import ( ) const ( - image = "tempo:latest" - azuriteImage = "mcr.microsoft.com/azure-storage/azurite" + image = "tempo:latest" ) func NewTempoAllInOne() *cortex_e2e.HTTPService { @@ -33,21 +32,7 @@ func NewTempoAllInOne() *cortex_e2e.HTTPService { 9411, // zipkin ingest (used by load) ) - s.SetBackoff(tempoBackoff()) - - return s -} - -func NewAzurite(port int) *cortex_e2e.HTTPService { - s := cortex_e2e.NewHTTPService( - "azurite", - azuriteImage, // Create the the azurite container - e2e.NewCommandWithoutEntrypoint("sh", "-c", "azurite -l /data --blobHost 0.0.0.0"), - e2e.NewHTTPReadinessProbe(port, "/devstoreaccount1?comp=list", 403, 403), //If we get 403 the Azurite is ready - port, // blob storage port - ) - - s.SetBackoff(tempoBackoff()) + s.SetBackoff(TempoBackoff()) return s } @@ -64,7 +49,7 @@ func NewTempoDistributor() *cortex_e2e.HTTPService { 14250, ) - s.SetBackoff(tempoBackoff()) + s.SetBackoff(TempoBackoff()) return s } @@ -80,7 +65,7 @@ func NewTempoIngester(replica int) *cortex_e2e.HTTPService { 3200, ) - s.SetBackoff(tempoBackoff()) + s.SetBackoff(TempoBackoff()) return s } @@ -96,7 +81,7 @@ func NewTempoQueryFrontend() *cortex_e2e.HTTPService { 3200, ) - s.SetBackoff(tempoBackoff()) + s.SetBackoff(TempoBackoff()) return s } @@ -112,7 +97,7 @@ func NewTempoQuerier() *cortex_e2e.HTTPService { 3200, ) - s.SetBackoff(tempoBackoff()) + s.SetBackoff(TempoBackoff()) return s } @@ -140,7 +125,7 @@ func CopyFileToSharedDir(s *e2e.Scenario, src, dst string) error { return WriteFileToSharedDir(s, dst, content) } -func tempoBackoff() util.BackoffConfig { +func TempoBackoff() util.BackoffConfig { return util.BackoffConfig{ MinBackoff: 500 * time.Millisecond, MaxBackoff: time.Second,