mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-07 23:27:07 +02:00
This enables golangci-lint via build tags for integration tests (this should have been done long ago!), and fixes the linting errors. Two tests were updated to reduce flakiness: * apply config: wait for nodes to issue "boot done" sequence event before proceeding * recover: kill pods even if they appear after the initial set gets killed (potential race condition with previous test). Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
73 lines
1.6 KiB
Go
73 lines
1.6 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 (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
|
|
"github.com/talos-systems/talos/internal/integration/base"
|
|
)
|
|
|
|
// ValidateSuite verifies dmesg command.
|
|
type ValidateSuite struct {
|
|
base.CLISuite
|
|
|
|
tmpDir string
|
|
savedCwd string
|
|
}
|
|
|
|
// SuiteName ...
|
|
func (suite *ValidateSuite) SuiteName() string {
|
|
return "cli.ValidateSuite"
|
|
}
|
|
|
|
// SetupTest ...
|
|
func (suite *ValidateSuite) SetupTest() {
|
|
var err error
|
|
suite.tmpDir, err = ioutil.TempDir("", "talos")
|
|
suite.Require().NoError(err)
|
|
|
|
suite.savedCwd, err = os.Getwd()
|
|
suite.Require().NoError(err)
|
|
|
|
suite.Require().NoError(os.Chdir(suite.tmpDir))
|
|
}
|
|
|
|
// TearDownTest ...
|
|
func (suite *ValidateSuite) TearDownTest() {
|
|
if suite.savedCwd != "" {
|
|
suite.Require().NoError(os.Chdir(suite.savedCwd))
|
|
}
|
|
|
|
if suite.tmpDir != "" {
|
|
suite.Require().NoError(os.RemoveAll(suite.tmpDir))
|
|
}
|
|
}
|
|
|
|
// TestValidate generates config and validates it for all the modes.
|
|
func (suite *ValidateSuite) TestValidate() {
|
|
suite.RunCLI([]string{"gen", "config", "foobar", "https://10.0.0.1"})
|
|
|
|
for _, configFile := range []string{"init.yaml", "controlplane.yaml", "join.yaml"} {
|
|
configFile := configFile
|
|
|
|
for _, mode := range []string{"cloud", "container"} {
|
|
mode := mode
|
|
|
|
suite.Run(fmt.Sprintf("%s-%s", configFile, mode), func() {
|
|
suite.RunCLI([]string{"validate", "-m", mode, "-c", configFile})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
allSuites = append(allSuites, new(ValidateSuite))
|
|
}
|