Skip to content

Commit

Permalink
Revert "skip test while snapshot downloader cannot handle downgrades (#…
Browse files Browse the repository at this point in the history
…3314)"

This reverts commit a8d8fce.
  • Loading branch information
blakerouse authored Sep 8, 2023
1 parent 94764be commit cde7a09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 9 additions & 4 deletions internal/pkg/agent/application/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ func (u *Upgrader) Upgrade(ctx context.Context, version string, sourceURI string
u.log.Errorw("Unable to clean downloads before update", "error.message", err, "downloads.path", paths.Downloads())
}

if sourceURI != "" {
sourceURI = u.settings.SourceURI
}

sourceURI = u.sourceURI(sourceURI)
archivePath, err := u.downloadArtifact(ctx, version, sourceURI, skipVerifyOverride, skipDefaultPgp, pgpBytes...)
if err != nil {
// Run the same pre-upgrade cleanup task to get rid of any newly downloaded files
Expand Down Expand Up @@ -217,6 +214,14 @@ func (u *Upgrader) Ack(ctx context.Context, acker acker.Acker) error {
return saveMarker(marker)
}

func (u *Upgrader) sourceURI(retrievedURI string) string {
if retrievedURI != "" {
return retrievedURI
}

return u.settings.SourceURI
}

func rollbackInstall(ctx context.Context, log *logger.Logger, hash string) {
os.RemoveAll(filepath.Join(paths.Data(), fmt.Sprintf("%s-%s", agentName, hash)))
_ = ChangeSymlink(ctx, log, release.ShortCommit())
Expand Down
13 changes: 5 additions & 8 deletions testing/integration/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,25 @@ func TestStandaloneUpgrade(t *testing.T) {
}
}

func TestStandaloneDowngradeWithGPGFallback(t *testing.T) {
func TestStandaloneUpgradeWithGPGFallback(t *testing.T) {
define.Require(t, define.Requirements{
Local: false, // requires Agent installation
Sudo: true, // requires Agent installation
})

t.Skip("snapshot downloader has a bug which break this test between releases: " +
"https://github.com/elastic/elastic-agent/issues/3313")

minVersion := version_8_10_0_SNAPSHOT
fromVersion, err := version.ParseVersion(define.Version())
parsedVersion, err := version.ParseVersion(define.Version())
require.NoError(t, err)

if fromVersion.Less(*minVersion) {
if parsedVersion.Less(*minVersion) {
t.Skipf("Version %s is lower than min version %s", define.Version(), minVersion)
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// previous
toVersion, err := fromVersion.GetPreviousMinor()
toVersion, err := parsedVersion.GetPreviousMinor()
require.NoError(t, err, "failed to get previous minor")
agentFixture, err := define.NewFixture(
t,
Expand Down Expand Up @@ -276,7 +273,7 @@ func TestStandaloneDowngradeWithGPGFallback(t *testing.T) {
1,
)

testStandaloneUpgrade(ctx, t, agentFixture, fromVersion, toVersion, "", false, false, true, customPGP)
testStandaloneUpgrade(ctx, t, agentFixture, parsedVersion, toVersion, "", false, false, true, customPGP)
}

func TestStandaloneDowngradeToPreviousSnapshotBuild(t *testing.T) {
Expand Down

0 comments on commit cde7a09

Please sign in to comment.