From 67a4086ef046df677268b39de1c74e1cdfdb8b55 Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Mon, 10 Jul 2023 14:59:59 +0200 Subject: [PATCH] Remove stack image defintion feature and fix image overrides (#6997) Remove the unused stack versions feature from the e2e code. Reset the image when setting the version so that stateful builder code won't keep an image digest for a version previously set (see current test failures) // pseudo code newBuilder { .setVersion("8.9.0-SNPSHOT") } // version: "8.9.0-SNAPSHOT" // image: docker.elastic.co/elasticsearch/elasticsearch@sha256:39599c71bd7446fc3c38f22462ba5c86ce65813c4ec38eb3b71bb876061351d4 b.setVersion("8.8.0") // version: "8.8.0" // image: docker.elastic.co/elasticsearch/elasticsearch@sha256:39599c71bd7446fc3c38f22462ba5c86ce65813c4ec38eb3b71bb876061351d4 // test is not actually running 8.8.0 at this point but still 8.9.0-SNAPSHOT Co-authored-by: Thibault Richard --- .../scripts/test/set-deployer-config.sh | 6 -- .gitignore | 1 - Makefile | 3 +- NOTICE.txt | 74 ++++++++-------- docs/reference/dependencies.asciidoc | 2 +- go.mod | 2 +- test/e2e/cmd/run/command.go | 58 +++++++------ test/e2e/cmd/run/run.go | 13 --- test/e2e/test/agent/builder.go | 19 +---- test/e2e/test/apmserver/builder.go | 9 +- test/e2e/test/beat/builder.go | 9 +- test/e2e/test/context.go | 84 +++++++------------ test/e2e/test/elasticsearch/builder.go | 15 +--- test/e2e/test/enterprisesearch/builder.go | 9 +- test/e2e/test/kibana/builder.go | 4 +- test/e2e/test/logstash/builder.go | 9 +- test/e2e/test/maps/builder.go | 9 +- 17 files changed, 110 insertions(+), 216 deletions(-) diff --git a/.buildkite/scripts/test/set-deployer-config.sh b/.buildkite/scripts/test/set-deployer-config.sh index 91764fc93c..4cbd55e14b 100755 --- a/.buildkite/scripts/test/set-deployer-config.sh +++ b/.buildkite/scripts/test/set-deployer-config.sh @@ -23,11 +23,6 @@ set -eu WD="$(cd "$(dirname "$0")"; pwd)" ROOT="$WD/../../.." -write_stack_version_def() { - # TODO - echo '[]' > "$ROOT/stack-versions-def.json" -} - w() { echo "$@" >> "$ROOT/deployer-config.yml"; } write_deployer_config() { @@ -66,4 +61,3 @@ write_deployer_config() { } write_deployer_config -write_stack_version_def diff --git a/.gitignore b/.gitignore index 2a5a03326c..62087f5390 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,6 @@ hack/deployer/config/provider deployer-config.yml .env .registry.env -stack-versions-def.json # ignore test output integration-tests.json diff --git a/Makefile b/Makefile index bff64f9b9b..bc55dfe01d 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ integration-xml: clean done lint: - GOGC=50 golangci-lint run --verbose + GOGC=40 golangci-lint run --verbose manifest-gen-test: hack/manifest-gen/test.sh @@ -443,7 +443,6 @@ e2e-run: go-generate --test-license=$(TEST_LICENSE) \ --test-license-pkey-path=$(TEST_LICENSE_PKEY_PATH) \ --elastic-stack-version=$(E2E_STACK_VERSION) \ - --elastic-stack-images=stack-versions-def.json \ --log-verbosity=$(LOG_VERBOSITY) \ --log-to-file=$(E2E_JSON) \ --test-timeout=$(TEST_TIMEOUT) \ diff --git a/NOTICE.txt b/NOTICE.txt index 3542815d11..03a8062f31 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -3850,43 +3850,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Module : golang.org/x/text -Version : v0.11.0 -Time : 2023-06-26T23:12:51Z -Licence : BSD-3-Clause - -Contents of probable licence file $GOMODCACHE/golang.org/x/text@v0.11.0/LICENSE: - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -------------------------------------------------------------------------------- Module : gopkg.in/yaml.v3 Version : v3.0.1 @@ -15983,6 +15946,43 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-------------------------------------------------------------------------------- +Module : golang.org/x/text +Version : v0.11.0 +Time : 2023-06-26T23:12:51Z +Licence : BSD-3-Clause + +Contents of probable licence file $GOMODCACHE/golang.org/x/text@v0.11.0/LICENSE: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + -------------------------------------------------------------------------------- Module : golang.org/x/time Version : v0.3.0 diff --git a/docs/reference/dependencies.asciidoc b/docs/reference/dependencies.asciidoc index c67afdc565..a080f3b67c 100644 --- a/docs/reference/dependencies.asciidoc +++ b/docs/reference/dependencies.asciidoc @@ -51,7 +51,6 @@ This page lists the third-party dependencies used to build {n}. | link:https://go.uber.org/automaxprocs[$$go.uber.org/automaxprocs$$] | v1.5.2 | MIT | link:https://go.uber.org/zap[$$go.uber.org/zap$$] | v1.24.0 | MIT | link:https://golang.org/x/crypto[$$golang.org/x/crypto$$] | v0.11.0 | BSD-3-Clause -| link:https://golang.org/x/text[$$golang.org/x/text$$] | v0.11.0 | BSD-3-Clause | link:https://gopkg.in/yaml.v3[$$gopkg.in/yaml.v3$$] | v3.0.1 | MIT | link:https://github.com/kubernetes/api[$$k8s.io/api$$] | v0.27.3 | Apache-2.0 | link:https://github.com/kubernetes/apimachinery[$$k8s.io/apimachinery$$] | v0.27.3 | Apache-2.0 @@ -163,6 +162,7 @@ This page lists the third-party dependencies used to build {n}. | link:https://golang.org/x/sync[$$golang.org/x/sync$$] | v0.2.0 | BSD-3-Clause | link:https://golang.org/x/sys[$$golang.org/x/sys$$] | v0.10.0 | BSD-3-Clause | link:https://golang.org/x/term[$$golang.org/x/term$$] | v0.10.0 | BSD-3-Clause +| link:https://golang.org/x/text[$$golang.org/x/text$$] | v0.11.0 | BSD-3-Clause | link:https://golang.org/x/time[$$golang.org/x/time$$] | v0.3.0 | BSD-3-Clause | link:https://golang.org/x/tools[$$golang.org/x/tools$$] | v0.9.1 | BSD-3-Clause | link:https://gomodules.xyz/jsonpatch/v2[$$gomodules.xyz/jsonpatch/v2$$] | v2.3.0 | Apache-2.0 diff --git a/go.mod b/go.mod index 4010c2dc01..8f50f7d6ac 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,6 @@ require ( go.uber.org/automaxprocs v1.5.2 go.uber.org/zap v1.24.0 golang.org/x/crypto v0.11.0 - golang.org/x/text v0.11.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.27.3 k8s.io/apimachinery v0.27.3 @@ -124,6 +123,7 @@ require ( golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/term v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.9.1 // indirect gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect diff --git a/test/e2e/cmd/run/command.go b/test/e2e/cmd/run/command.go index 9b8ac9d411..5aebc73666 100644 --- a/test/e2e/cmd/run/command.go +++ b/test/e2e/cmd/run/command.go @@ -22,35 +22,34 @@ import ( ) type runFlags struct { - managedNamespaces []string - e2eImage string - elasticStackVersion string - elasticStackImagesPath string - kubeConfig string - operatorImage string - testLicensePKeyPath string - testContextOutPath string - testLicense string - scratchDirRoot string - testRegex string - testRunName string - monitoringSecrets string - pipeline string - buildNumber string - provider string - clusterName string - operatorReplicas int - commandTimeout time.Duration - logVerbosity int - testTimeout time.Duration - autoPortForwarding bool - skipCleanup bool - local bool - logToFile bool - ignoreWebhookFailures bool - deployChaosJob bool - e2eTags string - testEnvTags []string + managedNamespaces []string + e2eImage string + elasticStackVersion string + kubeConfig string + operatorImage string + testLicensePKeyPath string + testContextOutPath string + testLicense string + scratchDirRoot string + testRegex string + testRunName string + monitoringSecrets string + pipeline string + buildNumber string + provider string + clusterName string + operatorReplicas int + commandTimeout time.Duration + logVerbosity int + testTimeout time.Duration + autoPortForwarding bool + skipCleanup bool + local bool + logToFile bool + ignoreWebhookFailures bool + deployChaosJob bool + e2eTags string + testEnvTags []string } var log logr.Logger @@ -84,7 +83,6 @@ func Command() *cobra.Command { cmd.Flags().DurationVar(&flags.commandTimeout, "command-timeout", 90*time.Second, "Timeout for commands executed") cmd.Flags().StringVar(&flags.e2eImage, "e2e-image", "", "E2E test image") cmd.Flags().StringVar(&flags.elasticStackVersion, "elastic-stack-version", test.LatestReleasedVersion7x, "Elastic Stack version") - cmd.Flags().StringVar(&flags.elasticStackImagesPath, "elastic-stack-images", "", "Path to config file declaring images for individual Elastic Stack applications") cmd.Flags().StringVar(&flags.kubeConfig, "kubeconfig", "", "Path to kubeconfig") cmd.Flags().BoolVar(&flags.local, "local", false, "Create the environment for running tests locally") cmd.Flags().StringSliceVar(&flags.managedNamespaces, "managed-namespaces", []string{"mercury", "venus"}, "List of managed namespaces") diff --git a/test/e2e/cmd/run/run.go b/test/e2e/cmd/run/run.go index 9192347131..83fff6063a 100644 --- a/test/e2e/cmd/run/run.go +++ b/test/e2e/cmd/run/run.go @@ -148,25 +148,12 @@ func (h *helper) initTestContext() error { return fmt.Errorf("invalid operator image: %s", h.operatorImage) } - var stackImages test.ElasticStackImages - if h.elasticStackImagesPath != "" { - bytes, err := os.ReadFile(h.elasticStackImagesPath) - if err != nil { - return fmt.Errorf("unable to read Elastic Stack images config file: %w", err) - } - err = json.Unmarshal(bytes, &stackImages) - if err != nil { - return fmt.Errorf("unable to parse Elastic Stack images config file: %w", err) - } - } - h.testContext = test.Context{ AutoPortForwarding: h.autoPortForwarding, E2EImage: h.e2eImage, E2ENamespace: fmt.Sprintf("%s-system", h.testRunName), E2EServiceAccount: h.testRunName, ElasticStackVersion: h.elasticStackVersion, - ElasticStackImages: stackImages, Local: h.local, LogVerbosity: h.logVerbosity, Operator: test.NamespaceOperator{ diff --git a/test/e2e/test/agent/builder.go b/test/e2e/test/agent/builder.go index c6a2b53795..e88875f1c0 100644 --- a/test/e2e/test/agent/builder.go +++ b/test/e2e/test/agent/builder.go @@ -96,17 +96,15 @@ func NewBuilder(name string) Builder { Labels: map[string]string{run.TestNameLabel: name}, } - def := test.Ctx().ImageDefinitionFor(agentv1alpha1.Kind) return Builder{ Agent: agentv1alpha1.Agent{ ObjectMeta: meta, Spec: agentv1alpha1.AgentSpec{ - Version: def.Version, + Version: test.Ctx().ElasticStackVersion, }, }, Suffix: suffix, }. - WithImage(def.Image). WithSuffix(suffix). WithLabel(run.TestNameLabel, name). WithDaemonSet() @@ -181,11 +179,6 @@ func (b Builder) WithConfig(config *commonv1.Config) Builder { return b } -func (b Builder) WithImage(image string) Builder { - b.Agent.Spec.Image = image - return b -} - func (b Builder) WithSuffix(suffix string) Builder { if suffix != "" { b.Agent.ObjectMeta.Name = b.Agent.ObjectMeta.Name + "-" + suffix @@ -329,16 +322,6 @@ func (b Builder) WithFleetMode() Builder { func (b Builder) WithFleetServer() Builder { b.Agent.Spec.FleetServerEnabled = true - return b.WithFleetImage() -} - -func (b Builder) WithFleetImage() Builder { - // do not override image or version unless an explicit override exists as builder might already have been configured - // with a specific version which we do want to preserve. - if def := test.Ctx().ImageDefinitionOrNil(FleetServerPseudoKind); def != nil { - b.Agent.Spec.Image = def.Image - b.Agent.Spec.Version = def.Version - } return b } diff --git a/test/e2e/test/apmserver/builder.go b/test/e2e/test/apmserver/builder.go index 02676d8b64..d8ca810015 100644 --- a/test/e2e/test/apmserver/builder.go +++ b/test/e2e/test/apmserver/builder.go @@ -54,13 +54,12 @@ func newBuilder(name, randSuffix string) Builder { Name: name, Namespace: test.Ctx().ManagedNamespace(0), } - def := test.Ctx().ImageDefinitionFor(apmv1.Kind) return Builder{ ApmServer: apmv1.ApmServer{ ObjectMeta: meta, Spec: apmv1.ApmServerSpec{ Count: 1, - Version: def.Version, + Version: test.Ctx().ElasticStackVersion, Config: &commonv1.Config{ Data: map[string]interface{}{ "apm-server.ilm.enabled": false, @@ -74,7 +73,6 @@ func newBuilder(name, randSuffix string) Builder { }, }, }. - WithImage(def.Image). WithSuffix(randSuffix). WithLabel(run.TestNameLabel, name). WithPodLabel(run.TestNameLabel, name) @@ -87,11 +85,6 @@ func (b Builder) WithSuffix(suffix string) Builder { return b } -func (b Builder) WithImage(image string) Builder { - b.ApmServer.Spec.Image = image - return b -} - func (b Builder) WithRestrictedSecurityContext() Builder { b.ApmServer.Spec.PodTemplate.Spec.SecurityContext = test.DefaultSecurityContext() return b diff --git a/test/e2e/test/beat/builder.go b/test/e2e/test/beat/builder.go index a72340c164..829fd16fe2 100644 --- a/test/e2e/test/beat/builder.go +++ b/test/e2e/test/beat/builder.go @@ -8,9 +8,6 @@ import ( "fmt" "testing" - "golang.org/x/text/cases" - "golang.org/x/text/language" - ghodssyaml "github.com/ghodss/yaml" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" @@ -101,12 +98,8 @@ type ValidationFunc func(client.Client) error func (b Builder) WithType(typ beatcommon.Type) Builder { typeStr := string(typ) - // for Beats we have to use the specific type as there are different Beats images within the one CRD kind. - // capitalize the Beat name to be consistent in spelling with the other CRD kinds. - def := test.Ctx().ImageDefinitionFor(cases.Title(language.Und).String(typeStr)) b.Beat.Spec.Type = typeStr - b.Beat.Spec.Version = def.Version - b.Beat.Spec.Image = def.Image + b.Beat.Spec.Version = test.Ctx().ElasticStackVersion return b } diff --git a/test/e2e/test/context.go b/test/e2e/test/context.go index 754863bed2..5382d22793 100644 --- a/test/e2e/test/context.go +++ b/test/e2e/test/context.go @@ -94,38 +94,37 @@ type ElasticStackImages []ElasticStackImageDefinition // Context encapsulates data about a specific test run type Context struct { - Operator NamespaceOperator `json:"operator"` - E2EImage string `json:"e2e_image"` - E2ENamespace string `json:"e2e_namespace"` - E2EServiceAccount string `json:"e2e_service_account"` - ElasticStackVersion string `json:"elastic_stack_version"` - ElasticStackImages ElasticStackImages `json:"elastic_stack_images"` - LogVerbosity int `json:"log_verbosity"` - OperatorImage string `json:"operator_image"` - OperatorImageRepo string `json:"operator_image_repo"` - OperatorImageTag string `json:"operator_image_tag"` - TestLicense string `json:"test_license"` - TestLicensePKeyPath string `json:"test_license_pkey_path"` - TestRegex string `json:"test_regex"` - TestRun string `json:"test_run"` - MonitoringSecrets string `json:"monitoring_secrets"` - TestTimeout time.Duration `json:"test_timeout"` - AutoPortForwarding bool `json:"auto_port_forwarding"` - DeployChaosJob bool `json:"deploy_chaos_job"` - Local bool `json:"local"` - IgnoreWebhookFailures bool `json:"ignore_webhook_failures"` - OcpCluster bool `json:"ocp_cluster"` - Pipeline string `json:"pipeline"` - BuildNumber string `json:"build_number"` - Provider string `json:"provider"` - ClusterName string `json:"clusterName"` - KubernetesVersion version.Version `json:"kubernetes_version"` - GCPCredentialsPath string `json:"gcp_credentials_path"` - AutopilotCluster bool `json:"autopilot_cluster"` - TestEnvTags []string `json:"test_tags"` - E2ETags string `json:"e2e_tags"` - LogToFile bool `json:"log_to_file"` - ArtefactsDir string `json:"artefacts_dir"` + Operator NamespaceOperator `json:"operator"` + E2EImage string `json:"e2e_image"` + E2ENamespace string `json:"e2e_namespace"` + E2EServiceAccount string `json:"e2e_service_account"` + ElasticStackVersion string `json:"elastic_stack_version"` + LogVerbosity int `json:"log_verbosity"` + OperatorImage string `json:"operator_image"` + OperatorImageRepo string `json:"operator_image_repo"` + OperatorImageTag string `json:"operator_image_tag"` + TestLicense string `json:"test_license"` + TestLicensePKeyPath string `json:"test_license_pkey_path"` + TestRegex string `json:"test_regex"` + TestRun string `json:"test_run"` + MonitoringSecrets string `json:"monitoring_secrets"` + TestTimeout time.Duration `json:"test_timeout"` + AutoPortForwarding bool `json:"auto_port_forwarding"` + DeployChaosJob bool `json:"deploy_chaos_job"` + Local bool `json:"local"` + IgnoreWebhookFailures bool `json:"ignore_webhook_failures"` + OcpCluster bool `json:"ocp_cluster"` + Pipeline string `json:"pipeline"` + BuildNumber string `json:"build_number"` + Provider string `json:"provider"` + ClusterName string `json:"clusterName"` + KubernetesVersion version.Version `json:"kubernetes_version"` + GCPCredentialsPath string `json:"gcp_credentials_path"` + AutopilotCluster bool `json:"autopilot_cluster"` + TestEnvTags []string `json:"test_tags"` + E2ETags string `json:"e2e_tags"` + LogToFile bool `json:"log_to_file"` + ArtefactsDir string `json:"artefacts_dir"` } // ManagedNamespace returns the nth managed namespace. @@ -143,27 +142,6 @@ func (c Context) KubernetesMajorMinor() string { return fmt.Sprintf("%d.%d", c.KubernetesVersion.Major, c.KubernetesVersion.Minor) } -// ImageDefinitionFor returns a specific override for the given kind of resource. Defaults to an empty image -// and the global Elastic Stack version under test if no override exists. -func (c Context) ImageDefinitionFor(kind string) ElasticStackImageDefinition { - for _, def := range c.ElasticStackImages { - if kind == def.Kind { - return def - } - } - return ElasticStackImageDefinition{Version: c.ElasticStackVersion} -} - -// ImageDefinitionOrNil returns a specific override for the given kind of resource. Returns nil if no override exists. -func (c Context) ImageDefinitionOrNil(kind string) *ElasticStackImageDefinition { - for _, def := range c.ElasticStackImages { - if kind == def.Kind { - return &def - } - } - return nil -} - // ClusterResource is a generic cluster resource. type ClusterResource struct { Name string `json:"name"` diff --git a/test/e2e/test/elasticsearch/builder.go b/test/e2e/test/elasticsearch/builder.go index 880c3d8207..67369d4343 100644 --- a/test/e2e/test/elasticsearch/builder.go +++ b/test/e2e/test/elasticsearch/builder.go @@ -96,26 +96,16 @@ func newBuilder(name, randSuffix string) Builder { Namespace: test.Ctx().ManagedNamespace(0), Labels: map[string]string{run.TestNameLabel: name}, } - def := test.Ctx().ImageDefinitionFor(esv1.Kind) return Builder{ Elasticsearch: esv1.Elasticsearch{ ObjectMeta: meta, }, }. - WithVersion(def.Version). - WithImage(def.Image). + WithVersion(test.Ctx().ElasticStackVersion). WithSuffix(randSuffix). WithLabel(run.TestNameLabel, name) } -func (b Builder) WithImage(image string) Builder { - // do not override images set e.g. by WithVersion with empty strings - if len(image) > 0 { - b.Elasticsearch.Spec.Image = image - } - return b -} - func (b Builder) WithAnnotation(key, value string) Builder { if b.Elasticsearch.ObjectMeta.Annotations == nil { b.Elasticsearch.ObjectMeta.Annotations = make(map[string]string) @@ -173,6 +163,9 @@ func (b Builder) WithVersion(version string) Builder { b.Elasticsearch.Spec.Version = version if strings.HasSuffix(version, "-SNAPSHOT") { b.Elasticsearch.Spec.Image = test.WithDigestOrDie(container.ElasticsearchImage, version) + } else { + // reset the image in case the builder was set to a SNAPSHOT version at some point + b.Elasticsearch.Spec.Image = "" } return b } diff --git a/test/e2e/test/enterprisesearch/builder.go b/test/e2e/test/enterprisesearch/builder.go index 38e1d34fd5..b682c7ff54 100644 --- a/test/e2e/test/enterprisesearch/builder.go +++ b/test/e2e/test/enterprisesearch/builder.go @@ -81,17 +81,15 @@ func newBuilder(name, randSuffix string) Builder { Name: name, Namespace: test.Ctx().ManagedNamespace(0), } - def := test.Ctx().ImageDefinitionFor(entv1.Kind) b := Builder{ EnterpriseSearch: entv1.EnterpriseSearch{ ObjectMeta: meta, Spec: entv1.EnterpriseSearchSpec{ Count: 1, - Version: def.Version, + Version: test.Ctx().ElasticStackVersion, }, }, }. - WithImage(def.Image). WithSuffix(randSuffix). WithLabel(run.TestNameLabel, name). WithPodLabel(run.TestNameLabel, name). @@ -113,11 +111,6 @@ func (b Builder) Ref() commonv1.ObjectSelector { } } -func (b Builder) WithImage(image string) Builder { - b.EnterpriseSearch.Spec.Image = image - return b -} - func (b Builder) WithSuffix(suffix string) Builder { if suffix != "" { b.EnterpriseSearch.ObjectMeta.Name = b.EnterpriseSearch.ObjectMeta.Name + "-" + suffix diff --git a/test/e2e/test/kibana/builder.go b/test/e2e/test/kibana/builder.go index 9c71332aaf..f7439def73 100644 --- a/test/e2e/test/kibana/builder.go +++ b/test/e2e/test/kibana/builder.go @@ -69,12 +69,11 @@ func newBuilder(name, randSuffix string) Builder { Name: name, Namespace: test.Ctx().ManagedNamespace(0), } - def := test.Ctx().ImageDefinitionFor(kbv1.Kind) return Builder{ Kibana: kbv1.Kibana{ ObjectMeta: meta, Spec: kbv1.KibanaSpec{ - Version: def.Version, + Version: test.Ctx().ElasticStackVersion, PodTemplate: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ SecurityContext: test.DefaultSecurityContext(), @@ -83,7 +82,6 @@ func newBuilder(name, randSuffix string) Builder { }, }, }. - WithImage(def.Image). WithSuffix(randSuffix). WithLabel(run.TestNameLabel, name). WithPodLabel(run.TestNameLabel, name) diff --git a/test/e2e/test/logstash/builder.go b/test/e2e/test/logstash/builder.go index 6127464c5d..5ef0b2b93d 100644 --- a/test/e2e/test/logstash/builder.go +++ b/test/e2e/test/logstash/builder.go @@ -39,17 +39,15 @@ func newBuilder(name, randSuffix string) Builder { Name: name, Namespace: test.Ctx().ManagedNamespace(0), } - def := test.Ctx().ImageDefinitionFor(logstashv1alpha1.Kind) return Builder{ Logstash: logstashv1alpha1.Logstash{ ObjectMeta: meta, Spec: logstashv1alpha1.LogstashSpec{ Count: 1, - Version: def.Version, + Version: test.Ctx().ElasticStackVersion, }, }, }. - WithImage(def.Image). WithSuffix(randSuffix). WithLabel(run.TestNameLabel, name). WithPodLabel(run.TestNameLabel, name). @@ -58,11 +56,6 @@ func newBuilder(name, randSuffix string) Builder { WithTestStorageClass() } -func (b Builder) WithImage(image string) Builder { - b.Logstash.Spec.Image = image - return b -} - func (b Builder) WithSuffix(suffix string) Builder { if suffix != "" { b.Logstash.ObjectMeta.Name = b.Logstash.ObjectMeta.Name + "-" + suffix diff --git a/test/e2e/test/maps/builder.go b/test/e2e/test/maps/builder.go index a0d3eb5444..312aa25900 100644 --- a/test/e2e/test/maps/builder.go +++ b/test/e2e/test/maps/builder.go @@ -36,27 +36,20 @@ func newBuilder(name, randSuffix string) Builder { Name: name, Namespace: test.Ctx().ManagedNamespace(0), } - def := test.Ctx().ImageDefinitionFor(v1alpha1.Kind) return Builder{ EMS: v1alpha1.ElasticMapsServer{ ObjectMeta: meta, Spec: v1alpha1.MapsSpec{ Count: 1, - Version: def.Version, + Version: test.Ctx().ElasticStackVersion, }, }, }. - WithImage(def.Image). WithSuffix(randSuffix). WithLabel(run.TestNameLabel, name). WithPodLabel(run.TestNameLabel, name) } -func (b Builder) WithImage(image string) Builder { - b.EMS.Spec.Image = image - return b -} - func (b Builder) WithSuffix(suffix string) Builder { if suffix != "" { b.EMS.ObjectMeta.Name = b.EMS.ObjectMeta.Name + "-" + suffix