From 6150e2d05df17a7b8e4bb8a016fba1a5dba56bf9 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Fri, 18 Aug 2017 11:39:55 +0200 Subject: [PATCH] Add caching to PR data generation and add a separate prdatalong handler --- integrationtests/tools/testserver/server.go | 27 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/integrationtests/tools/testserver/server.go b/integrationtests/tools/testserver/server.go index 20ec7a65..ee6dfaea 100644 --- a/integrationtests/tools/testserver/server.go +++ b/integrationtests/tools/testserver/server.go @@ -12,7 +12,15 @@ import ( . "github.com/onsi/gomega" ) +const ( + dataLen = 500 * 1024 // 500 KB + dataLenLong = 50 * 1024 * 1024 // 50 MB +) + var ( + PRData = GeneratePRData(dataLen) + PRDataLong = GeneratePRData(dataLenLong) + server *h2quic.Server port string ) @@ -21,10 +29,21 @@ func init() { http.HandleFunc("/prdata", func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() sl := r.URL.Query().Get("len") - l, err := strconv.Atoi(sl) - Expect(err).NotTo(HaveOccurred()) - data := GeneratePRData(l) - _, err = w.Write(data) + if sl != "" { + var err error + l, err := strconv.Atoi(sl) + Expect(err).NotTo(HaveOccurred()) + _, err = w.Write(GeneratePRData(l)) + Expect(err).NotTo(HaveOccurred()) + } else { + _, err := w.Write(PRData) + Expect(err).NotTo(HaveOccurred()) + } + }) + + http.HandleFunc("/prdatalong", func(w http.ResponseWriter, r *http.Request) { + defer GinkgoRecover() + _, err := w.Write(PRDataLong) Expect(err).NotTo(HaveOccurred()) }) }