mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-19 05:31:14 +02:00
I added tests for all the commands which work reliably in container mode. Some tests are naive, some are more sophisticated. While going through the tests, I think I found a small bug in `osctl gen keypair`. When we get reliable KVM tests, I can revisit and add missing tests for time, reboot, shutdown and friends. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
// +build integration_cli
|
|
|
|
package cli
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"regexp"
|
|
|
|
"github.com/talos-systems/talos/internal/integration/base"
|
|
)
|
|
|
|
// KubeconfigSuite verifies dmesg command
|
|
type KubeconfigSuite struct {
|
|
base.CLISuite
|
|
}
|
|
|
|
// SuiteName ...
|
|
func (suite *KubeconfigSuite) SuiteName() string {
|
|
return "cli.KubeconfigSuite"
|
|
}
|
|
|
|
// TestDirectory generates kubeconfig in specified directory.
|
|
func (suite *KubeconfigSuite) TestDirectory() {
|
|
tempDir, err := ioutil.TempDir("", "talos")
|
|
suite.Require().NoError(err)
|
|
|
|
defer os.RemoveAll(tempDir) //nolint: errcheck
|
|
|
|
suite.RunOsctl([]string{"kubeconfig", tempDir},
|
|
base.StdoutEmpty())
|
|
|
|
suite.Require().FileExists(filepath.Join(tempDir, "kubeconfig"))
|
|
|
|
// TODO: launch kubectl with config to verify it
|
|
}
|
|
|
|
// TestCwd generates kubeconfig in cwd.
|
|
func (suite *KubeconfigSuite) TestCwd() {
|
|
tempDir, err := ioutil.TempDir("", "talos")
|
|
suite.Require().NoError(err)
|
|
|
|
defer os.RemoveAll(tempDir) //nolint: errcheck
|
|
|
|
savedCwd, err := os.Getwd()
|
|
suite.Require().NoError(err)
|
|
|
|
defer os.Chdir(savedCwd) //nolint: errcheck
|
|
|
|
suite.Require().NoError(os.Chdir(tempDir))
|
|
|
|
suite.RunOsctl([]string{"kubeconfig"},
|
|
base.StdoutEmpty())
|
|
|
|
suite.Require().FileExists(filepath.Join(tempDir, "kubeconfig"))
|
|
}
|
|
|
|
// TestMultiNodeFail verifies that command fails with multiple nodes.
|
|
func (suite *KubeconfigSuite) TestMultiNodeFail() {
|
|
suite.RunOsctl([]string{"kubeconfig", "--nodes", "127.0.0.1", "--nodes", "127.0.0.1", "."},
|
|
base.ShouldFail(),
|
|
base.StderrNotEmpty(),
|
|
base.StdoutEmpty(),
|
|
base.StderrShouldMatch(regexp.MustCompile(`is not supported with multiple nodes`)))
|
|
}
|
|
|
|
func init() {
|
|
allSuites = append(allSuites, new(KubeconfigSuite))
|
|
}
|