mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-06 05:01:19 +02:00
There were three problems: * cli tests did commands in sequence assuming they all hit the same node, but with load-balancing it's no longer true * restart test was affected, as it hit different node for check after restart, and it succeeded immediately, while on original node process was still starting which resulted in failure in the next tests; replace the check to make sure service is up and healthy, so that test leaves cluster in a good state * restart API response had wrong format (no message returned) which resulted in failures with apid proxy (when used with `-n`) Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
70 lines
1.7 KiB
Go
70 lines
1.7 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 (
|
|
"math/rand"
|
|
"regexp"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/talos-systems/talos/internal/integration/base"
|
|
)
|
|
|
|
// RestartSuite verifies dmesg command.
|
|
type RestartSuite struct {
|
|
base.CLISuite
|
|
}
|
|
|
|
// SuiteName ...
|
|
func (suite *RestartSuite) SuiteName() string {
|
|
return "cli.RestartSuite"
|
|
}
|
|
|
|
// TestSystem restarts system containerd process.
|
|
func (suite *RestartSuite) TestSystem() {
|
|
if testing.Short() {
|
|
suite.T().Skip("skipping in short mode")
|
|
}
|
|
|
|
nodes := suite.DiscoverNodes()
|
|
suite.Require().NotEmpty(nodes)
|
|
|
|
// trustd only runs on control plane nodes
|
|
node := nodes[0]
|
|
|
|
suite.RunCLI([]string{"restart", "-n", node, "trustd"},
|
|
base.StdoutEmpty())
|
|
|
|
time.Sleep(200 * time.Millisecond)
|
|
|
|
suite.RunAndWaitForMatch([]string{"service", "-n", node, "trustd"}, regexp.MustCompile(`EVENTS\s+\[Running\]: Health check successful`), 30*time.Second)
|
|
}
|
|
|
|
// TestKubernetes restarts K8s container.
|
|
func (suite *RestartSuite) TestK8s() {
|
|
if testing.Short() {
|
|
suite.T().Skip("skipping in short mode")
|
|
}
|
|
|
|
nodes := suite.DiscoverNodes()
|
|
suite.Require().NotEmpty(nodes)
|
|
|
|
node := nodes[rand.Intn(len(nodes))]
|
|
|
|
suite.RunCLI([]string{"restart", "-n", node, "-k", "kubelet"},
|
|
base.StdoutEmpty())
|
|
|
|
time.Sleep(200 * time.Millisecond)
|
|
|
|
suite.RunAndWaitForMatch([]string{"service", "-n", node, "kubelet"}, regexp.MustCompile(`EVENTS\s+\[Running\]: Health check successful`), 30*time.Second)
|
|
}
|
|
|
|
func init() {
|
|
allSuites = append(allSuites, new(RestartSuite))
|
|
}
|