Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Closed
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
85 changes: 85 additions & 0 deletions e2e/_suites/kubernetes-autodiscover/autodiscover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,27 @@ import (
messages "github.com/cucumber/messages-go/v10"
log "github.com/sirupsen/logrus"

<<<<<<< HEAD
=======
"github.com/elastic/e2e-testing/cli/config"
"github.com/elastic/e2e-testing/internal/common"
"github.com/elastic/e2e-testing/internal/deploy"
"github.com/elastic/e2e-testing/internal/kubernetes"
>>>>>>> 9d505cc6... fix: resolve issues in k8s-autodiscover test suite (#1171)
"github.com/elastic/e2e-testing/internal/shell"
"github.com/elastic/e2e-testing/internal/utils"
)

<<<<<<< HEAD
const defaultBeatVersion = "7.13.0-SNAPSHOT"
const defaultEventsWaitTimeout = 120 * time.Second
const defaultDeployWaitTimeout = 120 * time.Second
=======
var beatVersions = map[string]string{}

var defaultEventsWaitTimeout = 60 * time.Second
var defaultDeployWaitTimeout = 60 * time.Second
>>>>>>> 9d505cc6... fix: resolve issues in k8s-autodiscover test suite (#1171)

type podsManager struct {
kubectl kubernetesControl
Expand Down Expand Up @@ -85,6 +99,65 @@ func (m *podsManager) executeTemplateFor(podName string, writer io.Writer, optio
return nil
}

<<<<<<< HEAD
=======
func (m *podsManager) configureDockerImage(podName string) error {
if podName != "filebeat" && podName != "heartbeat" && podName != "metricbeat" {
log.Debugf("Not processing custom binaries for pod: %s. Only [filebeat, heartbeat, metricbeat] will be processed", podName)
return nil
}

// we are caching the versions by pod to avoid downloading and loading/tagging the Docker image multiple times
if beatVersions[podName] != "" {
log.Tracef("The beat version was already loaded: %s", beatVersions[podName])
return nil
}

beatVersion := common.BeatVersion + "-amd64"

useCISnapshots := shell.GetEnvBool("BEATS_USE_CI_SNAPSHOTS")
beatsLocalPath := shell.GetEnv("BEATS_LOCAL_PATH", "")
if useCISnapshots || beatsLocalPath != "" {
log.Debugf("Configuring Docker image for %s", podName)

// this method will detect if the GITHUB_CHECK_SHA1 variable is set
artifactName := utils.BuildArtifactName(podName, common.BeatVersion, common.BeatVersionBase, "linux", "amd64", "tar.gz", true)

imagePath, err := utils.FetchBeatsBinary(artifactName, podName, common.BeatVersion, common.BeatVersionBase, utils.TimeoutFactor, true)
if err != nil {
return err
}

// load the TAR file into the docker host as a Docker image
err = deploy.LoadImage(imagePath)
if err != nil {
return err
}

// tag the image with the proper docker tag, including platform
err = deploy.TagImage(
"docker.elastic.co/beats/"+podName+":"+common.BeatVersionBase,
"docker.elastic.co/observability-ci/"+podName+":"+beatVersion,
)
if err != nil {
return err
}

// load PR image into kind
err = cluster.LoadImage(m.ctx, "docker.elastic.co/observability-ci/"+podName+":"+beatVersion)
if err != nil {
return err
}

}

log.Tracef("Caching beat version '%s' for %s", beatVersion, podName)
beatVersions[podName] = beatVersion

return nil
}

>>>>>>> 9d505cc6... fix: resolve issues in k8s-autodiscover test suite (#1171)
func (m *podsManager) isDeleted(podName string, options []string) error {
var buf bytes.Buffer
err := m.executeTemplateFor(podName, &buf, options)
Expand Down Expand Up @@ -387,7 +460,19 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
log.DeferExitHandler(cancel)

ctx.BeforeSuite(func() {
<<<<<<< HEAD
err := cluster.initialize(suiteContext)
=======
// init logger
config.Init()

common.InitVersions()

defaultEventsWaitTimeout = defaultEventsWaitTimeout * time.Duration(utils.TimeoutFactor)
defaultDeployWaitTimeout = defaultDeployWaitTimeout * time.Duration(utils.TimeoutFactor)

err := cluster.Initialize(suiteContext, "testdata/kind.yml")
>>>>>>> 9d505cc6... fix: resolve issues in k8s-autodiscover test suite (#1171)
if err != nil {
log.WithError(err).Fatal("Failed to initialize cluster")
}
Expand Down
5 changes: 5 additions & 0 deletions internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,13 @@ func LoadImage(imagePath string) error {
func TagImage(src string, target string) error {
dockerClient := getDockerClient()

<<<<<<< HEAD:internal/docker/docker.go
maxTimeout := 15 * time.Second
exp := common.GetExponentialBackOff(maxTimeout)
=======
maxTimeout := 5 * time.Second * time.Duration(utils.TimeoutFactor)
exp := utils.GetExponentialBackOff(maxTimeout)
>>>>>>> 9d505cc6... fix: resolve issues in k8s-autodiscover test suite (#1171):internal/deploy/docker_client.go
retryCount := 0

tagImageFn := func() error {
Expand Down