-
Notifications
You must be signed in to change notification settings - Fork 432
/
debug_suite.go
69 lines (52 loc) · 1.78 KB
/
debug_suite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package glooctl
import (
"context"
"os"
"path/filepath"
"github.com/solo-io/gloo/test/kubernetes/e2e"
"github.com/stretchr/testify/suite"
)
var _ e2e.NewSuiteFunc = NewDebugSuite
// debugSuite contains the set of tests to validate the behavior of `glooctl debug`
// These tests attempt to mirror: https://github.com/solo-io/gloo/blob/v1.16.x/test/kube2e/glooctl/debug_test.go
type debugSuite struct {
suite.Suite
tmpDir string
ctx context.Context
testInstallation *e2e.TestInstallation
}
func NewDebugSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &debugSuite{
ctx: ctx,
testInstallation: testInst,
}
}
func (s *debugSuite) SetupSuite() {
var err error
s.tmpDir, err = os.MkdirTemp(s.testInstallation.GeneratedFiles.TempDir, "debug-suite-dir")
s.Require().NoError(err)
}
func (s *debugSuite) TearDownSuite() {
_ = os.RemoveAll(s.tmpDir)
}
func (s *debugSuite) TestLogsNoPanic() {
err := s.testInstallation.Actions.Glooctl().DebugLogs(s.ctx,
"-n", s.testInstallation.Metadata.InstallNamespace)
s.NoError(err)
}
func (s *debugSuite) TestLogsZipFile() {
outputFile := filepath.Join(s.tmpDir, "log.tgz")
err := s.testInstallation.Actions.Glooctl().DebugLogs(s.ctx,
"-n", s.testInstallation.Metadata.InstallNamespace, "--file", outputFile, "--zip", "true")
s.NoError(err)
_, err = os.Stat(outputFile)
s.NoError(err, "Output file should have been generated")
}
func (s *debugSuite) TestLogsFile() {
outputFile := filepath.Join(s.tmpDir, "log.txt")
err := s.testInstallation.Actions.Glooctl().DebugLogs(s.ctx,
"-n", s.testInstallation.Metadata.InstallNamespace, "--file", outputFile, "--zip", "false")
s.NoError(err)
_, err = os.Stat(outputFile)
s.NoError(err, "Output file should have been generated")
}