Fixed interface conversion for ipQueue in monitor which caused panics.

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-09-02 11:43:08 -07:00
parent 7f13ecc87b
commit 2c81224262
2 changed files with 27 additions and 5 deletions

View File

@@ -4981,3 +4981,22 @@ func TestHealthzStatusUnavailable(t *testing.T) {
checkHealthzEndpoint(t, s.MonitorAddr().String(), http.StatusServiceUnavailable, "unavailable")
}
// When we converted ipq to use generics we still were using sync.Map. Currently you can not convert
// interface{} or any to a generic parameterized type. So this stopped working and panics.
func TestIpqzWithGenerics(t *testing.T) {
opts := DefaultMonitorOptions()
opts.JetStream = true
s := RunServer(opts)
defer s.Shutdown()
url := fmt.Sprintf("http://%s/ipqueuesz?all=1", s.MonitorAddr().String())
body := readBody(t, url)
require_True(t, len(body) > 0)
queues := map[string]*monitorIPQueue{}
require_NoError(t, json.Unmarshal(body, &queues))
require_True(t, len(queues) >= 4)
require_True(t, queues["SendQ"] != nil)
}