Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
- "./testing/docker/elasticsearch/roles.yml:/usr/share/elasticsearch/config/roles.yml"
- "./testing/docker/elasticsearch/users:/usr/share/elasticsearch/config/users"
- "./testing/docker/elasticsearch/users_roles:/usr/share/elasticsearch/config/users_roles"
- "./testing/docker/elasticsearch/ingest-geoip:/usr/share/elasticsearch/config/ingest-geoip"

kibana:
image: docker.elastic.co/kibana/kibana:8.3.0-6ba9f710-SNAPSHOT
Expand Down
45 changes: 1 addition & 44 deletions systemtest/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ import (
"github.com/elastic/apm-server/systemtest/apmservertest"
"github.com/elastic/apm-server/systemtest/estest"
"github.com/elastic/go-elasticsearch/v8"
"github.com/elastic/go-elasticsearch/v8/esapi"
)

const (
startContainersTimeout = 5 * time.Minute
waitHealthyInterval = 5 * time.Second
)

var (
Expand Down Expand Up @@ -112,7 +110,6 @@ func StartStackContainers() error {
g, ctx := errgroup.WithContext(ctx)
g.Go(func() error { return waitContainerHealthy(ctx, "kibana") })
g.Go(func() error { return waitContainerHealthy(ctx, "fleet-server") })
g.Go(func() error { return waitGeoIPDatabase(ctx) })
return g.Wait()
}

Expand Down Expand Up @@ -194,51 +191,11 @@ func waitContainerHealthy(ctx context.Context, serviceName string) error {
log.Printf("Waiting for %s container (%s) to become healthy", serviceName, container.ID)
first = false
}
time.Sleep(waitHealthyInterval)
time.Sleep(5 * time.Second)
}
return nil
}

// Elasticsearch downloads the geoIP database after starting up, and then refreshes it
// periodically. In CI the cluster will be fresh, so we wait for the database to be
// downloaded before running any tests which may depend on it being available.
func waitGeoIPDatabase(ctx context.Context) error {
type geoIPDatabase struct {
Name string
}
type nodeGeoIPStats struct {
Databases []geoIPDatabase
}

first := true
for {
var out struct {
Nodes map[string]nodeGeoIPStats
}
_, err := Elasticsearch.Do(ctx, esapi.IngestGeoIPStatsRequest{}, &out)
if err != nil {
return err
}

if n := len(out.Nodes); n != 1 {
return fmt.Errorf("expected 1 node, got %d", n)
}
for _, nodeStats := range out.Nodes {
for _, db := range nodeStats.Databases {
if db.Name == "GeoLite2-City.mmdb" {
return nil
}
}
}

if first {
log.Printf("Waiting for geoIP database to be downloaded")
first = false
}
time.Sleep(waitHealthyInterval)
}
}

func stackContainerInfo(ctx context.Context, docker *client.Client, name string) (*types.Container, error) {
containers, err := docker.ContainerList(ctx, types.ContainerListOptions{
Filters: filters.NewArgs(
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.