Skip to content

Commit dc846d9

Browse files
mount static geoip db into es container (#8065)
* mount static geoip db into es container fixes flaky test that depended on the geoip db being downloaded. closes #7260 * Revert "systemtest: wait for geoIP database availability (#7272)" This reverts commit ec38207.
1 parent 982e238 commit dc846d9

File tree

5 files changed

+2
-44
lines changed

5 files changed

+2
-44
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ services:
3737
- "./testing/docker/elasticsearch/roles.yml:/usr/share/elasticsearch/config/roles.yml"
3838
- "./testing/docker/elasticsearch/users:/usr/share/elasticsearch/config/users"
3939
- "./testing/docker/elasticsearch/users_roles:/usr/share/elasticsearch/config/users_roles"
40+
- "./testing/docker/elasticsearch/ingest-geoip:/usr/share/elasticsearch/config/ingest-geoip"
4041

4142
kibana:
4243
image: docker.elastic.co/kibana/kibana:8.3.0-6ba9f710-SNAPSHOT

systemtest/containers.go

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ import (
5050
"github.com/elastic/apm-server/systemtest/apmservertest"
5151
"github.com/elastic/apm-server/systemtest/estest"
5252
"github.com/elastic/go-elasticsearch/v8"
53-
"github.com/elastic/go-elasticsearch/v8/esapi"
5453
)
5554

5655
const (
5756
startContainersTimeout = 5 * time.Minute
58-
waitHealthyInterval = 5 * time.Second
5957
)
6058

6159
var (
@@ -112,7 +110,6 @@ func StartStackContainers() error {
112110
g, ctx := errgroup.WithContext(ctx)
113111
g.Go(func() error { return waitContainerHealthy(ctx, "kibana") })
114112
g.Go(func() error { return waitContainerHealthy(ctx, "fleet-server") })
115-
g.Go(func() error { return waitGeoIPDatabase(ctx) })
116113
return g.Wait()
117114
}
118115

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

202-
// Elasticsearch downloads the geoIP database after starting up, and then refreshes it
203-
// periodically. In CI the cluster will be fresh, so we wait for the database to be
204-
// downloaded before running any tests which may depend on it being available.
205-
func waitGeoIPDatabase(ctx context.Context) error {
206-
type geoIPDatabase struct {
207-
Name string
208-
}
209-
type nodeGeoIPStats struct {
210-
Databases []geoIPDatabase
211-
}
212-
213-
first := true
214-
for {
215-
var out struct {
216-
Nodes map[string]nodeGeoIPStats
217-
}
218-
_, err := Elasticsearch.Do(ctx, esapi.IngestGeoIPStatsRequest{}, &out)
219-
if err != nil {
220-
return err
221-
}
222-
223-
if n := len(out.Nodes); n != 1 {
224-
return fmt.Errorf("expected 1 node, got %d", n)
225-
}
226-
for _, nodeStats := range out.Nodes {
227-
for _, db := range nodeStats.Databases {
228-
if db.Name == "GeoLite2-City.mmdb" {
229-
return nil
230-
}
231-
}
232-
}
233-
234-
if first {
235-
log.Printf("Waiting for geoIP database to be downloaded")
236-
first = false
237-
}
238-
time.Sleep(waitHealthyInterval)
239-
}
240-
}
241-
242199
func stackContainerInfo(ctx context.Context, docker *client.Client, name string) (*types.Container, error) {
243200
containers, err := docker.ContainerList(ctx, types.ContainerListOptions{
244201
Filters: filters.NewArgs(
12.1 KB
Binary file not shown.
20.3 KB
Binary file not shown.
17.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)