diff --git a/testing/integration/upgrade_standalone_retry_test.go b/testing/integration/upgrade_standalone_retry_test.go index fcd12be2214..a062dd14d24 100644 --- a/testing/integration/upgrade_standalone_retry_test.go +++ b/testing/integration/upgrade_standalone_retry_test.go @@ -8,7 +8,6 @@ package integration import ( "context" - "errors" "fmt" "net" "net/http" @@ -23,9 +22,7 @@ import ( atesting "github.com/elastic/elastic-agent/pkg/testing" "github.com/elastic/elastic-agent/pkg/testing/define" - "github.com/elastic/elastic-agent/pkg/testing/tools" "github.com/elastic/elastic-agent/pkg/testing/tools/testcontext" - "github.com/elastic/elastic-agent/pkg/version" "github.com/elastic/elastic-agent/testing/upgradetest" ) @@ -41,27 +38,16 @@ func TestStandaloneUpgradeRetryDownload(t *testing.T) { // Start at the build version as we want to test the retry // logic that is in the build. - startVersion, err := version.ParseVersion(define.Version()) - require.NoError(t, err) startFixture, err := define.NewFixture(t, define.Version()) require.NoError(t, err) - startVersionInfo, err := startFixture.ExecVersion(ctx) - require.NoError(t, err, "failed to get end agent build version info") - - // Upgrade to an older snapshot build of same version but with a different commit hash - aac := tools.NewArtifactAPIClient(tools.WithLogFunc(t.Logf)) - buildInfo, err := aac.FindBuild(ctx, startVersion.VersionWithPrerelease(), startVersionInfo.Binary.Commit, 0) - if errors.Is(err, tools.ErrBuildNotFound) { - t.Skipf("there is no other build with a non-matching commit hash in the given version %s", define.Version()) - return - } - require.NoError(t, err) - t.Logf("found build %q available for testing", buildInfo.Build.BuildID) - endVersion := versionWithBuildID(t, startVersion, buildInfo.Build.BuildID) + // The end version does not matter much but it must not match + // the commit hash of the current build. + endVersion, err := upgradetest.PreviousMinor() + require.NoError(t, err) endFixture, err := atesting.NewFixture( t, - endVersion, + endVersion.String(), atesting.WithFetcher(atesting.ArtifactFetcher()), ) require.NoError(t, err) diff --git a/testing/integration/upgrade_uninstall_test.go b/testing/integration/upgrade_uninstall_test.go index 9f26c49bc47..d7ad0964d4f 100644 --- a/testing/integration/upgrade_uninstall_test.go +++ b/testing/integration/upgrade_uninstall_test.go @@ -20,7 +20,6 @@ import ( atesting "github.com/elastic/elastic-agent/pkg/testing" "github.com/elastic/elastic-agent/pkg/testing/define" - "github.com/elastic/elastic-agent/pkg/testing/tools" "github.com/elastic/elastic-agent/testing/upgradetest" ) @@ -41,8 +40,6 @@ func TestStandaloneUpgradeUninstallKillWatcher(t *testing.T) { defer cancel() // Upgrades to build under test. - endVersion, err := version.ParseVersion(define.Version()) - require.NoError(t, err) endFixture, err := define.NewFixture(t, define.Version()) require.NoError(t, err) endVersionInfo, err := endFixture.ExecVersion(ctx) @@ -50,20 +47,12 @@ func TestStandaloneUpgradeUninstallKillWatcher(t *testing.T) { // Start on a snapshot build, we want this test to upgrade to our // build to ensure that the uninstall will kill the watcher. - // We need a snapshot with a non-matching commit hash to perform the upgrade - aac := tools.NewArtifactAPIClient(tools.WithLogFunc(t.Logf)) - buildInfo, err := aac.FindBuild(ctx, endVersion.VersionWithPrerelease(), endVersionInfo.Binary.Commit, 0) - if errors.Is(err, tools.ErrBuildNotFound) { - t.Skipf("there is no other build with a non-matching commit hash in the given version %s", endVersion.VersionWithPrerelease()) - return - } + // We need a version with a non-matching commit hash to perform the upgrade + startVersion, err := upgradetest.PreviousMinor() require.NoError(t, err) - - t.Logf("found build %q available for testing", buildInfo.Build.BuildID) - startVersion := versionWithBuildID(t, endVersion, buildInfo.Build.BuildID) startFixture, err := atesting.NewFixture( t, - startVersion, + startVersion.String(), atesting.WithFetcher(atesting.ArtifactFetcher()), ) require.NoError(t, err)