Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 83973b2

Browse files
jalvzmergify-bot
authored andcommitted
Pull fresh docker images before suite (#1123)
* Pull fresh docker images before suite * code review (cherry picked from commit 77eaee8)
1 parent 061b4a1 commit 83973b2

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

e2e/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ The following environment variables affect how the tests are run in both the CI
147147
>"ELASTIC_APM_ACTIVE" only affects Helm and Metricbeat test suites.
148148
149149
- `ELASTIC_APM_ENVIRONMENT`: Set this environment variable to `ci` to send APM data to Elastic Cloud. Otherwise, the framework will spin up local APM Server and Kibana instances. For the CI, it will read credentials from Vault. Default value: `local`.
150+
- `SKIP_PULL`: Set this environment variable to prevent the test suite to pull Docker images for all components. Default: `false`
150151
- `SKIP_SCENARIOS`: Set this environment variable to `false` if it's needed to include the scenarios annotated as `@skip` in the current test execution. Default value: `true`.
151152
- `BEATS_LOCAL_PATH`: Set this environment variable to the base path to your local clone of Beats if it's needed to use the binary snapshots produced by your local build instead of the official releases. The snapshots will be fetched from the `${BEATS_LOCAL_PATH}/${THE_BEAT}/build/distributions` local directory. This variable is intended to be used by Beats developers, when testing locally the artifacts generated its own build. Default: empty.
152153
- `BEATS_USE_CI_SNAPSHOTS`: Set this environment variable to `true` if it's needed to use the binary snapshots produced by Beats CI instead of the official releases. The snapshots will be downloaded from a bucket in Google Cloud Storage. This variable is used by the Beats repository, when testing the artifacts generated by the packaging job. Default: `false`.

e2e/_suites/fleet/ingest_manager_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/elastic/e2e-testing/cli/config"
1616
"github.com/elastic/e2e-testing/internal/common"
1717
"github.com/elastic/e2e-testing/internal/compose"
18+
"github.com/elastic/e2e-testing/internal/docker"
1819
"github.com/elastic/e2e-testing/internal/elasticsearch"
1920
"github.com/elastic/e2e-testing/internal/installer"
2021
"github.com/elastic/e2e-testing/internal/kibana"
@@ -121,6 +122,11 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {
121122
"stackVersion": common.StackVersion,
122123
}
123124

125+
if !shell.GetEnvBool("SKIP_PULL") {
126+
log.Info("Pulling Docker images...")
127+
docker.PullImages(common.StackVersion, common.AgentVersion, common.KibanaVersion)
128+
}
129+
124130
common.ProfileEnv["kibanaDockerNamespace"] = "kibana"
125131
if strings.HasPrefix(common.KibanaVersion, "pr") || utils.IsCommit(common.KibanaVersion) {
126132
// because it comes from a PR

internal/docker/docker.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"compress/gzip"
1010
"context"
1111
"fmt"
12+
"io"
1213
"os"
1314
"path/filepath"
1415
"strings"
@@ -436,3 +437,32 @@ func getDockerClient() *client.Client {
436437

437438
return instance
438439
}
440+
441+
// PullImages pulls images
442+
func PullImages(stackVersion, agentVersion, kibanaVersion string) error {
443+
c := getDockerClient()
444+
ctx := context.Background()
445+
images := []string{
446+
"docker.elastic.co/beats/elastic-agent:" + agentVersion,
447+
"docker.elastic.co/beats/elastic-agent-ubi8:" + agentVersion,
448+
"docker.elastic.co/elasticsearch/elasticsearch:" + stackVersion,
449+
"docker.elastic.co/kibana/kibana:" + kibanaVersion,
450+
"docker.elastic.co/observability-ci/elastic-agent:" + agentVersion,
451+
"docker.elastic.co/observability-ci/elastic-agent-ubi8:" + agentVersion,
452+
"docker.elastic.co/observability-ci/elasticsearch:" + stackVersion,
453+
"docker.elastic.co/observability-ci/elasticsearch-ubi8:" + stackVersion,
454+
"docker.elastic.co/observability-ci/kibana:" + kibanaVersion,
455+
"docker.elastic.co/observability-ci/kibana-ubi8:" + kibanaVersion,
456+
}
457+
for _, image := range images {
458+
r, err := c.ImagePull(ctx, image, types.ImagePullOptions{})
459+
if err != nil {
460+
return err
461+
}
462+
_, err = io.Copy(os.Stdout, r)
463+
if err != nil {
464+
return err
465+
}
466+
}
467+
return nil
468+
}

0 commit comments

Comments
 (0)