Skip to content

Commit

Permalink
Remove stack image defintion feature and fix image overrides (#6997)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pebrc and thbkrkr authored Jul 10, 2023
1 parent e3fa2fa commit 67a4086
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 216 deletions.
6 changes: 0 additions & 6 deletions .buildkite/scripts/test/set-deployer-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -66,4 +61,3 @@ write_deployer_config() {
}

write_deployer_config
write_stack_version_def
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ hack/deployer/config/provider
deployer-config.yml
.env
.registry.env
stack-versions-def.json

# ignore test output
integration-tests.json
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) \
Expand Down
74 changes: 37 additions & 37 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/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
Expand Down Expand Up @@ -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/[email protected]/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
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/dependencies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
58 changes: 28 additions & 30 deletions test/e2e/cmd/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
13 changes: 0 additions & 13 deletions test/e2e/cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
19 changes: 1 addition & 18 deletions test/e2e/test/agent/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 1 addition & 8 deletions test/e2e/test/apmserver/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -74,7 +73,6 @@ func newBuilder(name, randSuffix string) Builder {
},
},
}.
WithImage(def.Image).
WithSuffix(randSuffix).
WithLabel(run.TestNameLabel, name).
WithPodLabel(run.TestNameLabel, name)
Expand All @@ -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
Expand Down
9 changes: 1 addition & 8 deletions test/e2e/test/beat/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit 67a4086

Please sign in to comment.