aboutsummaryrefslogtreecommitdiff
path: root/cmd/roomserver-integration-tests/main.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-04-22 13:00:05 +0100
committerGitHub <noreply@github.com>2020-04-22 13:00:05 +0100
commita466e9e9cc86e04b4d28de45cd44199916664768 (patch)
tree70e234ac80ade783acdccadb24f27395712b5748 /cmd/roomserver-integration-tests/main.go
parent71f9d35b7c2f1531b383f115ad3ab23e8d1ed0a5 (diff)
LRU cache for room versions in RS query API (#976)
* Experimental LRU cache for room versions * Don't accidentally try to type-assert nil * Also reduce hits on query API * Use hashicorp implementation which mutexes for us * Define const for max cache entries * Rename to be specifically immutable, panic if we try to mutate a cache entry * Review comments * Remove nil guards, give roomserver integration test a cache * go mod tidy
Diffstat (limited to 'cmd/roomserver-integration-tests/main.go')
-rw-r--r--cmd/roomserver-integration-tests/main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmd/roomserver-integration-tests/main.go b/cmd/roomserver-integration-tests/main.go
index df5607bc..682fc622 100644
--- a/cmd/roomserver-integration-tests/main.go
+++ b/cmd/roomserver-integration-tests/main.go
@@ -28,6 +28,7 @@ import (
"net/http"
+ "github.com/matrix-org/dendrite/common/caching"
"github.com/matrix-org/dendrite/common/test"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
@@ -253,6 +254,11 @@ func testRoomserver(input []string, wantOutput []string, checkQueries func(api.R
panic(err)
}
+ cache, err := caching.NewImmutableInMemoryLRUCache()
+ if err != nil {
+ panic(err)
+ }
+
doInput := func() {
fmt.Printf("Roomserver is ready to receive input, sending %d events\n", len(input))
if err = writeToRoomServer(input, cfg.RoomServerURL()); err != nil {
@@ -270,7 +276,7 @@ func testRoomserver(input []string, wantOutput []string, checkQueries func(api.R
cmd.Args = []string{"dendrite-room-server", "--config", filepath.Join(dir, test.ConfigFile)}
gotOutput, err := runAndReadFromTopic(cmd, cfg.RoomServerURL()+"/metrics", doInput, outputTopic, len(wantOutput), func() {
- queryAPI, _ := api.NewRoomserverQueryAPIHTTP("http://"+string(cfg.Listen.RoomServer), &http.Client{Timeout: timeoutHTTP})
+ queryAPI, _ := api.NewRoomserverQueryAPIHTTP("http://"+string(cfg.Listen.RoomServer), &http.Client{Timeout: timeoutHTTP}, cache)
checkQueries(queryAPI)
})
if err != nil {