e2e framework: move log size verification into framework/debug

This helps getting rid of the ssh dependency. The same init package as for
dumping namespaces takes care of adding the functionality back to framework
instances.
This commit is contained in:
Patrick Ohly
2022-08-25 18:19:16 +02:00
parent 802451b6ca
commit f9bc4f837b
3 changed files with 39 additions and 33 deletions

View File

@@ -14,10 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package init sets debug.DumpAllNamespaceInfo as implementation in the framework.
// Package init sets debug.DumpAllNamespaceInfo as implementation in the framework
// and enables log size verification.
package init
import (
"sync"
"github.com/onsi/ginkgo/v2"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/debug"
)
@@ -28,6 +32,31 @@ func init() {
f.DumpAllNamespaceInfo = func(f *framework.Framework, ns string) {
debug.DumpAllNamespaceInfo(f.ClientSet, ns)
}
if framework.TestContext.GatherLogsSizes {
var (
wg sync.WaitGroup
closeChannel chan bool
verifier *debug.LogsSizeVerifier
)
ginkgo.BeforeEach(func() {
wg.Add(1)
closeChannel = make(chan bool)
verifier = debug.NewLogsVerifier(f.ClientSet, closeChannel)
go func() {
defer wg.Done()
verifier.Run()
}()
ginkgo.DeferCleanup(func() {
ginkgo.By("Gathering log sizes data", func() {
close(closeChannel)
wg.Wait()
f.TestSummaries = append(f.TestSummaries, verifier.GetSummary())
})
})
})
}
},
)
}