Skip to content

Commit 2f2631b

Browse files
authored
Restart elastic-agent matching version in TestStandaloneUpgradeRollbackOnRestarts (#11324)
Replace the fixed amount of restarts with restarting based on elastic-agent version. This has been already successfully implemented in fixing TestFleetManagedUpgradeRollbackOnRestarts and it's now being extended to the standalone tests. This removes the +-1 restarts needed based on elastic-agent watcher timing, test timing, platform differences etc.
1 parent b04ef07 commit 2f2631b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

testing/integration/ess/upgrade_rollback_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,14 @@ func managedRollbackRestartTest(ctx context.Context, t *testing.T, info *define.
576576

577577
func standaloneRollbackRestartTest(ctx context.Context, t *testing.T, startFixture *atesting.Fixture, endFixture *atesting.Fixture) {
578578
standaloneRollbackTest(ctx, t, startFixture, endFixture, reallyFastWatcherCfg, details.ReasonWatchFailed,
579-
func(ctx context.Context, t *testing.T, _ client.Client, _ *atesting.Fixture, _ *atesting.Fixture) {
580-
restartAgentNTimes(t, 3, 10*time.Second)
579+
func(ctx context.Context, t *testing.T, _ client.Client, from *atesting.Fixture, to *atesting.Fixture) {
580+
installedAgentClient := from.NewClient()
581+
targetVersion, err := to.ExecVersion(ctx)
582+
require.NoError(t, err, "failed to get target version")
583+
restartContext, cancel := context.WithTimeout(t.Context(), 1*time.Minute)
584+
defer cancel()
585+
// restart the agent only if it matches the (upgraded) target version
586+
restartAgentVersion(restartContext, t, installedAgentClient, targetVersion.Binary, 10*time.Second)
581587
})
582588
}
583589

0 commit comments

Comments
 (0)