Skip to content

Commit

Permalink
Some small improvements to intests
Browse files Browse the repository at this point in the history
Only use stdout when fetching the kubeconfig in GetKubeConfig. This make
the command work even when it logs something to stderr.

When clientcmd.RESTConfigFromKubeConfig failed, the error was checked
too late, resulting in a panic.

Be fail-fast on some boostrap errors in one inttesst.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Dec 21, 2024
1 parent c84a0ea commit 60e3c91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions inttest/common/bootloosesuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,15 @@ func (s *BootlooseSuite) GetKubeConfig(node string, k0sKubeconfigArgs ...string)
defer ssh.Disconnect()

kubeConfigCmd := fmt.Sprintf("%s kubeconfig admin %s", s.K0sFullPath, strings.Join(k0sKubeconfigArgs, " "))
kubeConf, err := ssh.ExecWithOutput(s.Context(), kubeConfigCmd)
if err != nil {
var kubeConf bytes.Buffer
if err := ssh.Exec(s.Context(), kubeConfigCmd, SSHStreams{Out: &kubeConf}); err != nil {
return nil, err
}
cfg, err := clientcmd.RESTConfigFromKubeConfig([]byte(kubeConf))
cfg, err := clientcmd.RESTConfigFromKubeConfig(kubeConf.Bytes())
s.Require().NoError(err)
// The tests are querying the API server quite a lot, so we need to increase the QPS and Burst
cfg.QPS = 40.0
cfg.Burst = 400.0
s.Require().NoError(err)

hostURL, err := url.Parse(cfg.Host)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions inttest/containerdimports/containerd_imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ func (s *ContainerdImportsSuite) TestK0sGetsUp() {
s.Require().NoError(err)
defer ssh.Disconnect()

s.NoError(s.InitController(0))
s.Require().NoError(s.InitController(0))

s.NoError(s.RunWorkers())
s.Require().NoError(s.RunWorkers())

kc, err := s.KubeClient(s.ControllerNode(0))
if err != nil {
s.FailNow("failed to obtain Kubernetes client", err)
}

err = s.WaitForNodeReady(s.WorkerNode(0), kc)
s.NoError(err)
s.Require().NoError(s.WaitForNodeReady(s.WorkerNode(0), kc))

s.AssertSomeKubeSystemPods(kc)

Expand Down

0 comments on commit 60e3c91

Please sign in to comment.