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
Changes from 1 commit
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
36 changes: 36 additions & 0 deletions e2e/_suites/fleet/ingest_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package main

import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"io"
"os"
"strings"
"time"
Expand Down Expand Up @@ -135,6 +138,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...")
pullFreshImages(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 Expand Up @@ -215,3 +223,31 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {
}
})
}

func pullFreshImages(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.

Wdyt about moving an abstraction of the PullFreshImages method to the internal docker package?

c, err := client.NewClientWithOpts()
if err != nil {
return err
}
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
}
io.Copy(os.Stdout, r)
}
return nil
}