Skip to content

Commit

Permalink
Adjust test to start from older version
Browse files Browse the repository at this point in the history
  • Loading branch information
ycombinator committed Sep 26, 2023
1 parent d10b9f0 commit 1b94889
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions testing/integration/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,24 +1047,29 @@ type CustomPGP struct {
// to initiate a second upgrade. The test expects Elastic Agent to not allow
// the second upgrade.
func TestStandaloneUpgradeFailsWhenUpgradeIsInProgress(t *testing.T) {
upgradeToVersion := twoMinorsPrevious(t, ctx)

define.Require(t, define.Requirements{
Local: false, // requires Agent installation
Isolate: false,
Sudo: true, // requires Agent installation
})

upgradeFromVersion, err := version.ParseVersion(define.Version())
require.NoError(t, err)
// For this test we start with a version of Agent that's two minors older
// than the current version and upgrade to the current version. Then we attempt
// upgrading to the current version again, expecting Elastic Agent to disallow
// this second upgrade.

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

upgradeToVersion := twoMinorsPrevious(t, ctx)
upgradeFromVersion, err := version.ParseVersion(twoMinorsPrevious(t, ctx))
require.NoError(t, err)

upgradeToVersion, err := version.ParseVersion(define.Version())
require.NoError(t, err)

t.Logf("Testing Elastic Agent upgrade from %s to %s...", upgradeFromVersion, upgradeToVersion)

agentFixture, err := define.NewFixture(t, define.Version())
agentFixture, err := atesting.NewFixture(t, upgradeFromVersion.String())
require.NoError(t, err)

err = agentFixture.Prepare(ctx)
Expand All @@ -1086,7 +1091,7 @@ func TestStandaloneUpgradeFailsWhenUpgradeIsInProgress(t *testing.T) {

// Upgrade Elastic Agent via commandline
toVersion := upgradeToVersion.String()
t.Logf("Upgrading Agent to %s", toVersion)
t.Logf("Upgrading Agent to %s for the first time", toVersion)
var wg sync.WaitGroup
go func() {
wg.Add(1)
Expand Down

0 comments on commit 1b94889

Please sign in to comment.