Merge pull request #10507 from mmustafasenoglu/fix/install-wait-default
Run the E2E test on kind / setup-test-matrix (push) Failing after 2s
e2e-test-kind.yaml / extract (push) Failing after 6s
Run the E2E test on kind / get-go-version (push) Failing after 7s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 6s
Main CI / Build (push) Skipped
Scorecard supply-chain security / Scorecard analysis (push) Skipped

install: clarify --wait flag behavior, default false
This commit is contained in:
Xun Jiang/Bruce Jiang
2026-09-16 11:04:48 +08:00
committed by GitHub
3 changed files with 64 additions and 0 deletions
@@ -0,0 +1 @@
Add --wait flag to velero install to wait for Velero deployment to be ready
+1
View File
@@ -372,6 +372,7 @@ All namespaced resources will be placed in the 'velero' namespace by default.
The '--namespace' flag can be used to specify a different namespace to install into.
By default, the command returns immediately after creating resources.
Use '--wait' to wait for the Velero Deployment to be ready before proceeding.
Use '-o yaml' or '-o json' with '--dry-run' to output all generated resources as text instead of sending the resources to the server.
+62
View File
@@ -263,3 +263,65 @@ func TestNewCommandRunClosureOrder(t *testing.T) {
// looks up the ConfigMap in targetNS (succeeds), Run returns early via DryRun.
require.NoError(t, c.Execute())
}
// TestWaitDefaultsToFalse verifies that --wait defaults to false,
// consistent with velero backup create and velero restore create.
func TestWaitDefaultsToFalse(t *testing.T) {
o := NewInstallOptions()
assert.False(t, o.Wait, "--wait should default to false")
}
func TestWaitFlag(t *testing.T) {
tests := []struct {
name string
args []string
expectedWait bool
}{
{
name: "default: wait is false",
args: []string{},
expectedWait: false,
},
{
name: "--wait enables wait",
args: []string{"--wait"},
expectedWait: true,
},
{
name: "--wait=false disables wait",
args: []string{"--wait=false"},
expectedWait: false,
},
{
name: "--wait=true enables wait",
args: []string{"--wait=true"},
expectedWait: true,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
o := NewInstallOptions()
o.NoDefaultBackupLocation = true
o.UseVolumeSnapshots = false
o.NoSecret = true
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
o.BindFlags(flags)
err := flags.Parse(tc.args)
require.NoError(t, err)
c := makeValidateCmd()
c.SetContext(context.Background())
f := &factorymocks.Factory{}
f.On("Namespace").Return("velero")
f.On("KubebuilderClient").Return(velerotest.NewFakeControllerRuntimeClient(t), nil)
require.NoError(t, o.Complete([]string{}, f))
err = o.Validate(c, []string{}, f)
require.NoError(t, err)
assert.Equal(t, tc.expectedWait, o.Wait)
})
}
}