Skip to content

Commit

Permalink
Introduce upgrade tests from released versions (#2955)
Browse files Browse the repository at this point in the history
## What does this PR do?

This PR adds upgrade tests for both standalone and managed agent from
some versions of the current and previous major release to the latest
snapshot.

The tests will select:
- up to 2 versions with the same major version as the current agent
- up to 1 version from a previous major version
These versions are retrieved using the Artifact API and working
backwards through the versions, excluding snapshots.
The _up to_ part is because under certain circumstances (new major
release, for example) we may not find enough versions fitting the
criteria.

The tests `TestStandaloneUpgrade` and `TestFleetManagedUpgrade` will
start a subtest (using `t.Run()`) for each version to be used as a
starting point for the upgrade and then upgrade it to the latest version
of agent.

Current limitations:
- We are currently using the ArtifactFetcher so the starting elastic
agent version all come from the artifact API. For all agent versions
that allow the `--skip-verify` we use the packaged elastic agent as
artifact for the upgrade via `--sourceURI` parameter

## Why is it important?
We need to have automated tests for the common upgrade scenarios to
detect upgrade issues as soon as possible in the development cycle.

## How to test this PR locally

We can run the integration tests using
`AGENT_VERSION="8.10.0-SNAPSHOT" GOTEST_FLAGS="-test.run
^(TestFleetManagedUpgrade|TestStandaloneUpgrade)$" mage
integration:test`
or if you want to run just a specific version upgrade scenario we can
use (for example only standalone upgrade from 8.9.0 to 8.10.0-SNAPSHOT):
`AGENT_VERSION="8.10.0-SNAPSHOT" GOTEST_FLAGS="-test.run
^TestStandaloneUpgrade/Upgrade_8.9.0_to_8.10.0-SNAPSHOT$"`

---------

Co-authored-by: Blake Rouse <[email protected]>
(cherry picked from commit cfd059d)

# Conflicts:
#	testing/integration/upgrade_test.go
  • Loading branch information
pchila committed Aug 3, 2023
1 parent 8f49f9f commit c1fb4a7
Show file tree
Hide file tree
Showing 2 changed files with 439 additions and 83 deletions.
13 changes: 12 additions & 1 deletion pkg/testing/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ type Fixture struct {
allowErrs bool
connectTimout time.Duration

workDir string
srcPackage string
workDir string

installed bool
installOpts *InstallOpts
Expand Down Expand Up @@ -153,6 +154,7 @@ func (f *Fixture) Prepare(ctx context.Context, components ...UsableComponent) er
if err != nil {
return err
}
f.srcPackage = src
filename := filepath.Base(src)
name, _, err := splitFileType(filename)
if err != nil {
Expand Down Expand Up @@ -191,6 +193,15 @@ func (f *Fixture) WorkDir() string {
return f.workDir
}

// SrcPackage returns the location on disk of the elastic agent package used by this fixture.
func (f *Fixture) SrcPackage(ctx context.Context) (string, error) {
err := f.ensurePrepared(ctx)
if err != nil {
return "", err
}
return f.srcPackage, nil
}

func ExtractArtifact(l Logger, artifactFile, outputDir string) error {
filename := filepath.Base(artifactFile)
_, ext, err := splitFileType(filename)
Expand Down
Loading

0 comments on commit c1fb4a7

Please sign in to comment.