From 4946b8ddecc3e6db30accf715f846014154c271a Mon Sep 17 00:00:00 2001 From: Felix Matouschek Date: Mon, 16 Sep 2024 08:48:57 +0200 Subject: [PATCH] fix(tests,virtctl): Partially revert cleanups This partially reverts the cleanups of be4d5584723cf9205976d37b6c9753285c02ee5c, because the now reverted changes invalidate the results of the changed tests. For the tests to have a meaningful result, the actual virtctl binary needs to run (CreateCommandWithNS) instead of running the virtctl command as part of the test binary (NewRepeatableVirtctlCommand). Signed-off-by: Felix Matouschek --- tests/virtctl/scp.go | 9 +++++++-- tests/virtctl/ssh.go | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/virtctl/scp.go b/tests/virtctl/scp.go index aabadf5a4dc8..b46a61fea4e8 100644 --- a/tests/virtctl/scp.go +++ b/tests/virtctl/scp.go @@ -146,8 +146,13 @@ var _ = Describe("[sig-compute][virtctl]SCP", decorators.SigCompute, func() { ) It("local-ssh flag should be unavailable in virtctl", decorators.ExcludeNativeSsh, func() { - cmd := clientcmd.NewRepeatableVirtctlCommand("scp", "--local1-ssh=false") - Expect(cmd()).To(MatchError("unknown flag: --local-ssh")) + // The built virtctl binary should be tested here, therefore clientcmd.CreateCommandWithNS needs to be used. + // Running the command through NewRepeatableVirtctlCommand would test the test binary instead. + _, cmd, err := clientcmd.CreateCommandWithNS(testsuite.NamespaceTestDefault, "virtctl", "scp", "--local-ssh=false") + Expect(err).ToNot(HaveOccurred()) + out, err := cmd.CombinedOutput() + Expect(err).To(HaveOccurred(), "out[%s]", string(out)) + Expect(string(out)).To(Equal("unknown flag: --local-ssh\n")) }) }) diff --git a/tests/virtctl/ssh.go b/tests/virtctl/ssh.go index c674b6876fb7..9b065c5a209c 100644 --- a/tests/virtctl/ssh.go +++ b/tests/virtctl/ssh.go @@ -101,7 +101,12 @@ var _ = Describe("[sig-compute][virtctl]SSH", decorators.SigCompute, func() { ) It("local-ssh flag should be unavailable in virtctl", decorators.ExcludeNativeSsh, func() { - cmd := clientcmd.NewRepeatableVirtctlCommand("ssh", "--local-ssh=false") - Expect(cmd()).To(MatchError("unknown flag: --local-ssh")) + // The built virtctl binary should be tested here, therefore clientcmd.CreateCommandWithNS needs to be used. + // Running the command through NewRepeatableVirtctlCommand would test the test binary instead. + _, cmd, err := clientcmd.CreateCommandWithNS(testsuite.NamespaceTestDefault, "virtctl", "ssh", "--local-ssh=false") + Expect(err).ToNot(HaveOccurred()) + out, err := cmd.CombinedOutput() + Expect(err).To(HaveOccurred(), "out[%s]", string(out)) + Expect(string(out)).To(Equal("unknown flag: --local-ssh\n")) }) })