Skip to content

Commit

Permalink
refactored version constraints in upgrade integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pchila committed Jul 17, 2023
1 parent 8a0659c commit 2384643
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions testing/integration/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ agent.upgrade.watcher:

// notable versions used in tests
var version_8_0_0 = version.NewParsedSemVer(8, 0, 0, "", "")
var version_8_7_0 = version.NewParsedSemVer(8, 7, 0, "", "")
var version_8_9_0_SNAPSHOT = version.NewParsedSemVer(8, 9, 0, "SNAPSHOT", "")

func TestFleetManagedUpgrade(t *testing.T) {
Expand Down Expand Up @@ -194,7 +195,7 @@ func TestStandaloneUpgrade(t *testing.T) {
err = agentFixture.Configure(ctx, []byte(fastWatcherCfg))
require.NoError(t, err, "error configuring agent fixture")

testUpgrade(ctx, t, agentFixture, v, define.Version(), "")
testStandaloneUpgrade(ctx, t, agentFixture, v, define.Version(), "")
})
}
}
Expand Down Expand Up @@ -297,7 +298,7 @@ func TestStandaloneUpgradeToSpecificSnapshotBuild(t *testing.T) {
buildFragments[1],
)

testUpgrade(ctx, t, agentFixture, upgradeInputVersion.String(), define.Version(), expectedAgentHashAfterUpgrade)
testStandaloneUpgrade(ctx, t, agentFixture, upgradeInputVersion.String(), define.Version(), expectedAgentHashAfterUpgrade)

}

Expand Down Expand Up @@ -331,7 +332,7 @@ func getUpgradableAndLatestVersions(ctx context.Context, t *testing.T) (upgradab
return
}

func testUpgrade(ctx context.Context, t *testing.T, f *atesting.Fixture, fromVersion, toVersion, expectedAgentHashAfterUpgrade string) {
func testStandaloneUpgrade(ctx context.Context, t *testing.T, f *atesting.Fixture, fromVersion, toVersion, expectedAgentHashAfterUpgrade string) {
parsedFromVersion, err := version.ParseVersion(fromVersion)
require.NoErrorf(t, err, "unable to parse version %w", fromVersion)
parsedUpgradeVersion, err := version.ParseVersion(toVersion)
Expand All @@ -353,14 +354,23 @@ func testUpgrade(ctx context.Context, t *testing.T, f *atesting.Fixture, fromVer

t.Logf("Upgrading to version %q", toVersion)

tof, err := define.NewFixture(t, toVersion)
require.NoError(t, err)
sourceURI := ""
skipVerify := false
if version_8_7_0.Less(*parsedFromVersion) {
// if we are upgrading from a version > 8.7.0 (min version to skip signature verification) we pass :
// - a file:// sourceURI pointing the agent package under test
// - flag --skip-verify to bypass pgp signature verification (we don't produce signatures for PR/main builds)
tof, err := define.NewFixture(t, toVersion)
require.NoError(t, err)

srcPkg, err := tof.SrcPackage(ctx)
require.NoError(t, err)
srcPkg, err := tof.SrcPackage(ctx)
require.NoError(t, err)
sourceURI = "file://" + filepath.Dir(srcPkg)
t.Logf("set sourceURI to : %q", sourceURI)
skipVerify = true
}

t.Logf("src package folder: %q", "file://"+filepath.Dir(srcPkg))
_, err = c.Upgrade(ctx, toVersion, "file://"+filepath.Dir(srcPkg), true)
_, err = c.Upgrade(ctx, toVersion, sourceURI, skipVerify)
require.NoErrorf(t, err, "error triggering agent upgrade to version %q", toVersion)

require.Eventuallyf(t, func() bool {
Expand Down

0 comments on commit 2384643

Please sign in to comment.