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

Pull fresh docker images before suite #1123

Merged
merged 2 commits into from
May 4, 2021
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 e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ The following environment variables affect how the tests are run in both the CI
>"ELASTIC_APM_ACTIVE" only affects Helm and Metricbeat test suites.
- `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`.
- `SKIP_PULL`: Set this environment variable to prevent the test suite to pull Docker images for all components. Default: `false`
- `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`.
- `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.
- `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`.
Expand Down
6 changes: 6 additions & 0 deletions e2e/_suites/fleet/ingest_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/elastic/e2e-testing/cli/config"
"github.com/elastic/e2e-testing/internal/common"
"github.com/elastic/e2e-testing/internal/compose"
"github.com/elastic/e2e-testing/internal/docker"
"github.com/elastic/e2e-testing/internal/elasticsearch"
"github.com/elastic/e2e-testing/internal/installer"
"github.com/elastic/e2e-testing/internal/kibana"
Expand Down Expand Up @@ -135,6 +136,11 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {
"stackVersion": common.StackVersion,
}

if !shell.GetEnvBool("SKIP_PULL") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a section for Environment variables affecting the build: https://github.com/elastic/e2e-testing/tree/master/e2e#environment-variables-affecting-the-build Can we add info about this new var there?

log.Info("Pulling Docker images...")
docker.PullImages(common.StackVersion, common.AgentVersion, common.KibanaVersion)
}

common.ProfileEnv["kibanaDockerNamespace"] = "kibana"
if strings.HasPrefix(common.KibanaVersion, "pr") || utils.IsCommit(common.KibanaVersion) {
// because it comes from a PR
Expand Down
30 changes: 30 additions & 0 deletions internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"compress/gzip"
"context"
"fmt"
"io"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -436,3 +437,32 @@ func getDockerClient() *client.Client {

return instance
}

// PullImages pulls images
func PullImages(stackVersion, agentVersion, kibanaVersion string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little one: because this method could be reused across different test suites, i.e. metricbeat, we could pass the images array as parameter.

Again, it's not a blocker and it could be done in a follow-up PR.

c := getDockerClient()
ctx := context.Background()
images := []string{
"docker.elastic.co/beats/elastic-agent:" + agentVersion,
"docker.elastic.co/beats/elastic-agent-ubi8:" + agentVersion,
"docker.elastic.co/elasticsearch/elasticsearch:" + stackVersion,
"docker.elastic.co/kibana/kibana:" + kibanaVersion,
"docker.elastic.co/observability-ci/elastic-agent:" + agentVersion,
"docker.elastic.co/observability-ci/elastic-agent-ubi8:" + agentVersion,
"docker.elastic.co/observability-ci/elasticsearch:" + stackVersion,
"docker.elastic.co/observability-ci/elasticsearch-ubi8:" + stackVersion,
"docker.elastic.co/observability-ci/kibana:" + kibanaVersion,
"docker.elastic.co/observability-ci/kibana-ubi8:" + kibanaVersion,
}
for _, image := range images {
r, err := c.ImagePull(ctx, image, types.ImagePullOptions{})
if err != nil {
return err
}
_, err = io.Copy(os.Stdout, r)
if err != nil {
return err
}
}
return nil
}