talos/internal/integration/cli/support.go
Andrey Smirnov badbc51e63
refactor: rewrite code to include preliminary support for multi-doc
`config.Container` implements a multi-doc container which implements
both `Container` interface (encoding, validation, etc.), and `Conifg`
interface (accessing parts of the config).

Refactor `generate` and `bundle` packages to support multi-doc, and
provide backwards compatibility.

Implement a first (mostly example) machine config document for
SideroLink API URL.

Many places don't properly support multi-doc yet (e.g. config patches).

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2023-05-31 18:38:05 +04:00

87 lines
2.0 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/.
//go:build integration_cli
package cli
import (
"archive/zip"
"fmt"
"path/filepath"
"strings"
"github.com/siderolabs/talos/internal/integration/base"
"github.com/siderolabs/talos/pkg/machinery/config/machine"
)
// SupportSuite verifies support command.
type SupportSuite struct {
base.CLISuite
}
// SuiteName ...
func (suite *SupportSuite) SuiteName() string {
return "cli.SupportSuite"
}
// TestSupport does successful support run.
func (suite *SupportSuite) TestSupport() {
tempDir := suite.T().TempDir()
output := filepath.Join(tempDir, "support.zip")
node := suite.RandomDiscoveredNodeInternalIP(machine.TypeControlPlane)
suite.RunCLI([]string{"support", "--nodes", node, "-w", "5", "-O", output},
base.StderrNotEmpty(),
)
archive, err := zip.OpenReader(output)
suite.Require().NoError(err)
defer archive.Close() //nolint:errcheck
files := map[string]struct{}{}
for _, f := range archive.File {
files[f.Name] = struct{}{}
if strings.HasSuffix(f.Name, "dmesg.log") {
suite.Require().Greater(f.UncompressedSize64, uint64(0), "dmesg log is empty")
}
}
for _, name := range []string{
"dmesg.log",
"controller-runtime.log",
"apid.log",
"apid.state",
"machined.log",
"machined.state",
"kubelet.log",
"kubelet.state",
"talosResources/kernelparamstatuses.runtime.talos.dev.yaml",
"kube-system/kube-apiserver.log",
"mounts",
"processes",
"io",
"summary",
} {
n := fmt.Sprintf("%s/%s", node, name)
suite.Require().Contains(files, n, "File %s doesn't exist in the support bundle", n)
}
for _, name := range []string{
"cluster/kubernetesResources/nodes.yaml",
"cluster/kubernetesResources/systemPods.yaml",
} {
suite.Require().Contains(files, name, "File %s doesn't exist in the support bundle", name)
}
}
func init() {
allSuites = append(allSuites, new(SupportSuite))
}