From 6bfb2b1e46676f81fcc68152a5ae36206cadd764 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Wed, 16 Sep 2020 18:41:41 -0500 Subject: [PATCH] Use Bufio Large Buffer Instead of Scanner for Large Files in E2E (#7254) * use readline * Fix * max file buffer size --- endtoend/helpers/helpers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/endtoend/helpers/helpers.go b/endtoend/helpers/helpers.go index db82f13c97..1b4bb41ccc 100644 --- a/endtoend/helpers/helpers.go +++ b/endtoend/helpers/helpers.go @@ -25,6 +25,8 @@ const ( filePollingInterval = 500 * time.Millisecond memoryHeapFileName = "node_heap_%d.pb.gz" cpuProfileFileName = "node_cpu_profile_%d.pb.gz" + fileBufferSize = 64 * 1024 + maxFileBufferSize = 1024 * 1024 ) // KillProcesses finds the passed in process IDs and kills the process. @@ -79,6 +81,8 @@ func WaitForTextInFile(file *os.File, text string) error { return fmt.Errorf("could not find requested text \"%s\" in logs:\n%s", text, contents) case <-ticker.C: fileScanner := bufio.NewScanner(file) + buf := make([]byte, 0, fileBufferSize) + fileScanner.Buffer(buf, maxFileBufferSize) for fileScanner.Scan() { scanned := fileScanner.Text() if strings.Contains(scanned, text) {