diff --git a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go index 6984d07cf1..5f85b2000e 100644 --- a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go +++ b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go @@ -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 @@ -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) @@ -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") } diff --git a/internal/docker/docker.go b/internal/docker/docker.go index 2a48078ad4..8b4889554a 100644 --- a/internal/docker/docker.go +++ b/internal/docker/docker.go @@ -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 {