Skip to content

Commit

Permalink
pprof sanity test (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored May 7, 2024
1 parent 9d3bf19 commit 8772943
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions quesma/quesma/quesma_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package quesma

import (
"context"
"github.com/stretchr/testify/assert"
"mitmproxy/quesma/quesma/config"
"mitmproxy/quesma/telemetry"
"mitmproxy/quesma/tracing"
"net/http"
"testing"
)

func TestShouldExposePprof(t *testing.T) {
quesma := NewQuesmaTcpProxy(telemetry.NoopPhoneHomeAgent(), config.QuesmaConfiguration{
PublicTcpPort: 8080,
Elasticsearch: config.ElasticsearchConfiguration{Url: &config.Url{}},
}, make(<-chan tracing.LogWithLevel), false)
quesma.Start()
t.Cleanup(func() {
quesma.Close(context.Background())
})
response, err := http.Get("http://localhost:9999/debug/pprof/")
if err != nil {
t.Fatal("could not reach /debug/pprof:", err)
}

assert.Equal(t, 200, response.StatusCode)
}
4 changes: 4 additions & 0 deletions quesma/telemetry/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (d emptyMultiCounter) AggregateTopValues() MultiCounterTopValuesStats {
return MultiCounterTopValuesStats{}
}

func NoopPhoneHomeAgent() PhoneHomeAgent {
return &emptyAgent{}
}

type emptyAgent struct {
}

Expand Down

0 comments on commit 8772943

Please sign in to comment.