Skip to content

Commit

Permalink
add option to curl opts to limit log pollution (#30) (#31)
Browse files Browse the repository at this point in the history
* add option to curl opts to limit log polution

* adding issue to changlog - work is slightly related but issue link is required
  • Loading branch information
ianmacclancy authored Jan 12, 2023
1 parent 945b1be commit 36bee32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/4362
description: Added LogResponses as an option to curl ops - in order to log out response you can set this value to true. Reduces log polution
5 changes: 3 additions & 2 deletions testutils/helper/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type CurlOpts struct {
ReturnHeaders bool
ConnectionTimeout int
Verbose bool
LogResponses bool
// WithoutStats sets the -s flag to prevent download stats from printing
WithoutStats bool
// Optional SNI name to resolve domain to when sending request
Expand Down Expand Up @@ -112,11 +113,11 @@ func (t *testContainer) CurlEventuallyShouldRespond(opts CurlOpts, substr string
default:
break
case <-tick:
if opts.Verbose {
if opts.LogResponses {
log.GreyPrintf("running: %v\nwant %v\nhave: %s", opts, substr, res)
}
}
if strings.Contains(res, substr) {
if strings.Contains(res, substr) && opts.LogResponses {
log.GreyPrintf("success: %v", res)
}
return res
Expand Down
9 changes: 1 addition & 8 deletions testutils/helper/test_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var _ = Describe("test container tests", func() {
Expect(err).NotTo(HaveOccurred())
})
Context("test runner", func() {

var (
testRunner *testRunner
)
Expand All @@ -52,12 +51,10 @@ var _ = Describe("test container tests", func() {
err = testRunner.Deploy(time.Minute * 2)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
err := testRunner.Terminate()
Expect(err).NotTo(HaveOccurred())
})

It("can install and uninstall the testrunner", func() {
// responseString := fmt.Sprintf(`"%s":"%s.%s.svc.cluster.local:%v"`,
// linkerd.HeaderKey, helper.HttpEchoName, testHelper.InstallNamespace, helper.HttpEchoPort)
Expand All @@ -72,11 +69,9 @@ var _ = Describe("test container tests", func() {
ConnectionTimeout: 10,
}, SimpleHttpResponse, 1, 120*time.Second)
})

})

Context("http ehco", func() {

var (
httpEcho *echoPod
)
Expand All @@ -87,7 +82,6 @@ var _ = Describe("test container tests", func() {
err = httpEcho.deploy(time.Minute)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
err := httpEcho.Terminate()
Expect(err).NotTo(HaveOccurred())
Expand All @@ -104,12 +98,12 @@ var _ = Describe("test container tests", func() {
Service: HttpEchoName,
Port: HttpEchoPort,
ConnectionTimeout: 10,
Verbose: true,
}, responseString, 1, 120*time.Second)
})
})

Context("tcp ehco", func() {

var (
tcpEcho *echoPod
)
Expand All @@ -120,7 +114,6 @@ var _ = Describe("test container tests", func() {
err = tcpEcho.deploy(time.Minute)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
err := tcpEcho.Terminate()
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit 36bee32

Please sign in to comment.