forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubevirt#7024 from fossedihelm/virctl_print_versio…
…n_not_aligned [virtctl] Warning message for client and server versions not aligned
- Loading branch information
Showing
11 changed files
with
188 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package version_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"kubevirt.io/client-go/testutils" | ||
) | ||
|
||
func TestVersion(t *testing.T) { | ||
testutils.KubeVirtTestSuiteSetup(t) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package version_test | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
goruntime "runtime" | ||
"time" | ||
|
||
"github.com/golang/mock/gomock" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"kubevirt.io/client-go/kubecli" | ||
virt_version "kubevirt.io/client-go/version" | ||
"kubevirt.io/kubevirt/pkg/virtctl" | ||
"kubevirt.io/kubevirt/pkg/virtctl/version" | ||
) | ||
|
||
var _ = Describe("Version", func() { | ||
|
||
var ctrl *gomock.Controller | ||
|
||
BeforeEach(func() { | ||
ctrl = gomock.NewController(GinkgoT()) | ||
kubecli.GetKubevirtClientFromClientConfig = kubecli.GetMockKubevirtClientFromClientConfig | ||
kubecli.MockKubevirtClientInstance = kubecli.NewMockKubevirtClient(ctrl) | ||
serverVersionInterface := kubecli.NewMockServerVersionInterface(ctrl) | ||
kubecli.MockKubevirtClientInstance.EXPECT().ServerVersion().Return(serverVersionInterface).AnyTimes() | ||
serverVersionInterface.EXPECT().Get().Return(&virt_version.Info{ | ||
GitVersion: "v0.46.1", | ||
GitCommit: "fda30004223b51f9e604276419a2b376652cb5ad", | ||
GitTreeState: "clear", | ||
BuildDate: time.Now().Format("%Y-%m-%dT%H:%M:%SZ"), | ||
GoVersion: goruntime.Version(), | ||
Compiler: goruntime.Compiler, | ||
Platform: fmt.Sprintf("%s/%s", goruntime.GOOS, goruntime.GOARCH), | ||
}, nil, | ||
).AnyTimes() | ||
}) | ||
|
||
Context("should print a message if server and client virtctl versions are different", func() { | ||
It("in version command", func() { | ||
var buf bytes.Buffer | ||
cmd, clientConfig := virtctl.NewVirtctlCommand() | ||
cmd.SetOut(&buf) | ||
version.CheckClientServerVersion(&clientConfig) | ||
//Print out the captured output to show the test output also in the console | ||
fmt.Printf(buf.String()) | ||
Expect(buf.String()).To(ContainSubstring("You are using a client virtctl version that is different from the KubeVirt version running in the cluster"), | ||
"Warning message was not shown or has been changed") | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters