...
1
16
17
18
19 package init
20
21 import (
22 "context"
23 "sync"
24 "time"
25
26 "github.com/onsi/ginkgo/v2"
27 "k8s.io/kubernetes/test/e2e/framework"
28 e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
29 )
30
31 func init() {
32 framework.NewFrameworkExtensions = append(framework.NewFrameworkExtensions,
33 func(f *framework.Framework) {
34 f.DumpAllNamespaceInfo = func(ctx context.Context, f *framework.Framework, ns string) {
35 e2edebug.DumpAllNamespaceInfo(ctx, f.ClientSet, ns)
36 }
37
38 if framework.TestContext.GatherLogsSizes {
39 ginkgo.BeforeEach(func() {
40 var wg sync.WaitGroup
41 wg.Add(1)
42 ctx, cancel := context.WithCancel(context.Background())
43 verifier := e2edebug.NewLogsVerifier(ctx, f.ClientSet)
44 go func() {
45 defer wg.Done()
46 verifier.Run(ctx)
47 }()
48 ginkgo.DeferCleanup(func() {
49 ginkgo.By("Gathering log sizes data", func() {
50 cancel()
51 wg.Wait()
52 f.TestSummaries = append(f.TestSummaries, verifier.GetSummary())
53 })
54 })
55 })
56 }
57
58 if framework.TestContext.GatherKubeSystemResourceUsageData != "false" &&
59 framework.TestContext.GatherKubeSystemResourceUsageData != "none" {
60 ginkgo.BeforeEach(func(ctx context.Context) {
61 var nodeMode e2edebug.NodesSet
62 switch framework.TestContext.GatherKubeSystemResourceUsageData {
63 case "master":
64 nodeMode = e2edebug.MasterNodes
65 case "masteranddns":
66 nodeMode = e2edebug.MasterAndDNSNodes
67 default:
68 nodeMode = e2edebug.AllNodes
69 }
70
71 gatherer, err := e2edebug.NewResourceUsageGatherer(ctx, f.ClientSet, e2edebug.ResourceGathererOptions{
72 InKubemark: framework.ProviderIs("kubemark"),
73 Nodes: nodeMode,
74 ResourceDataGatheringPeriod: 60 * time.Second,
75 ProbeDuration: 15 * time.Second,
76 PrintVerboseLogs: false,
77 }, nil)
78 if err != nil {
79 framework.Logf("Error while creating NewResourceUsageGatherer: %v", err)
80 return
81 }
82
83 go gatherer.StartGatheringData(ctx)
84 ginkgo.DeferCleanup(func() {
85 ginkgo.By("Collecting resource usage data", func() {
86 summary, resourceViolationError := gatherer.StopAndSummarize([]int{90, 99, 100}, nil )
87
88 f.TestSummaries = append(f.TestSummaries, summary)
89
90 framework.ExpectNoError(resourceViolationError)
91 })
92 })
93 })
94 }
95 },
96 )
97 }
98
View as plain text