Skip to content

Commit a657dfa

Browse files
committed
Add postWatcherSuccessHook to upgrade test
1 parent 0481e67 commit a657dfa

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

testing/upgradetest/upgrader.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ type upgradeOpts struct {
5151
// Disable check that enforces different hashed between the to and from version of upgrade
5252
disableHashCheck bool
5353

54-
preInstallHook func() error
55-
postInstallHook func() error
56-
preUpgradeHook func() error
57-
postUpgradeHook func() error
54+
preInstallHook func() error
55+
postInstallHook func() error
56+
preUpgradeHook func() error
57+
postUpgradeHook func() error
58+
postWatcherSuccessHook func(context.Context, *atesting.Fixture) error
5859
}
5960

6061
type UpgradeOpt func(opts *upgradeOpts)
@@ -125,6 +126,14 @@ func WithPostUpgradeHook(hook func() error) UpgradeOpt {
125126
}
126127
}
127128

129+
// WithPostWatcherSuccessHook sets a hook to be called after the upgrade is successful
130+
// and the upgrade watcher has terminated as well.
131+
func WithPostWatcherSuccessHook(hook func(context.Context, *atesting.Fixture) error) UpgradeOpt {
132+
return func(opts *upgradeOpts) {
133+
opts.postWatcherSuccessHook = hook
134+
}
135+
}
136+
128137
// WithCustomWatcherConfig sets a custom watcher configuration to use.
129138
func WithCustomWatcherConfig(cfg string) UpgradeOpt {
130139
return func(opts *upgradeOpts) {
@@ -435,6 +444,12 @@ func PerformUpgrade(
435444
}
436445
}
437446

447+
if upgradeOpts.postWatcherSuccessHook != nil {
448+
if err := upgradeOpts.postWatcherSuccessHook(ctx, endFixture); err != nil {
449+
return fmt.Errorf("post watcher success hook failed: %w", err)
450+
}
451+
}
452+
438453
return nil
439454
}
440455

0 commit comments

Comments
 (0)