Skip to content

Commit

Permalink
fix: use int test app http handle, err cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Engelberg <[email protected]>
  • Loading branch information
jake-engelberg committed Oct 14, 2024
1 parent 5fd9bba commit 92dc48c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pkg/diagnostics/resiliency_monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ func TestResiliencyCountMonitoringCBStates(t *testing.T) {
require.NoError(t, err)
require.Len(t, rows, test.wantNumberOfRows)

rowsCbState, err2 := view.RetrieveData(resiliencyCBStateViewName)
require.NoError(t, err2)
rowsCbState, err := view.RetrieveData(resiliencyCBStateViewName)
require.NoError(t, err)
require.NotNil(t, rowsCbState)

wantedTags := []tag.Tag{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/dapr/dapr/tests/integration/framework"
"github.com/dapr/dapr/tests/integration/framework/client"
"github.com/dapr/dapr/tests/integration/framework/process/daprd"
prochttp "github.com/dapr/dapr/tests/integration/framework/process/http"
"github.com/dapr/dapr/tests/integration/framework/process/http/app"
"github.com/dapr/dapr/tests/integration/suite"
)

Expand All @@ -46,21 +46,20 @@ func (d *defaultcircuitbreaker) Setup(t *testing.T) []framework.Option {
d.callCount1 = &atomic.Int32{}
d.callCount2 = &atomic.Int32{}

handler := http.NewServeMux()
handler.HandleFunc("/circuitbreaker_ok", func(w http.ResponseWriter, r *http.Request) {
d.callCount1.Add(1)
w.WriteHeader(http.StatusOK)
})
handler.HandleFunc("/circuitbreaker_fail", func(w http.ResponseWriter, r *http.Request) {
d.callCount2.Add(1)
if d.callCount2.Load() <= 3 {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
})

srv := prochttp.New(t, prochttp.WithHandler(handler))
app := app.New(t,
app.WithHandlerFunc("/circuitbreaker_ok", func(w http.ResponseWriter, r *http.Request) {
d.callCount1.Add(1)
w.WriteHeader(http.StatusOK)
}),
app.WithHandlerFunc("/circuitbreaker_fail", func(w http.ResponseWriter, r *http.Request) {
d.callCount2.Add(1)
if d.callCount2.Load() <= 3 {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}),
)

resiliency := `
apiVersion: dapr.io/v1alpha1
Expand All @@ -82,19 +81,18 @@ spec:
`

d.daprdClient = daprd.New(t,
daprd.WithAppPort(srv.Port()),
daprd.WithAppPort(app.Port()),
daprd.WithResourceFiles(resiliency),
daprd.WithAppID("client"),
daprd.WithLogLevel("debug"),
)
d.daprdServer = daprd.New(t,
daprd.WithAppPort(srv.Port()),
daprd.WithAppPort(app.Port()),
daprd.WithAppID("server"),
)
// log.Print(d.daprdClient.Metrics(t, context.Background()))

return []framework.Option{
framework.WithProcesses(srv, d.daprdClient, d.daprdServer),
framework.WithProcesses(app, d.daprdClient, d.daprdServer),
}
}

Expand Down

0 comments on commit 92dc48c

Please sign in to comment.