Remove BaseDendrite (#3023)

Removes `BaseDendrite` to, hopefully, make testing and composing of
components easier in the future.
This commit is contained in:
Till 2023-03-22 09:21:32 +01:00 committed by GitHub
parent ec6879e5ae
commit 5e85a00cb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 1186 additions and 1002 deletions

View file

@ -13,8 +13,10 @@ import (
"time"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/httputil"
basepkg "github.com/matrix-org/dendrite/setup/base"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/test/testrig"
"github.com/matrix-org/dendrite/setup/process"
"github.com/stretchr/testify/assert"
)
@ -30,8 +32,10 @@ func TestLandingPage_Tcp(t *testing.T) {
})
assert.NoError(t, err)
b, _, _ := testrig.Base(nil)
defer b.Close()
processCtx := process.NewProcessContext()
routers := httputil.NewRouters()
cfg := config.Dendrite{}
cfg.Defaults(config.DefaultOpts{Generate: true, SingleDatabase: true})
// hack: create a server and close it immediately, just to get a random port assigned
s := httptest.NewServer(nil)
@ -40,7 +44,7 @@ func TestLandingPage_Tcp(t *testing.T) {
// start base with the listener and wait for it to be started
address, err := config.HTTPAddress(s.URL)
assert.NoError(t, err)
go b.SetupAndServeHTTP(address, nil, nil)
go basepkg.SetupAndServeHTTP(processCtx, &cfg, routers, address, nil, nil)
time.Sleep(time.Millisecond * 10)
// When hitting /, we should be redirected to /_matrix/static, which should contain the landing page
@ -70,15 +74,17 @@ func TestLandingPage_UnixSocket(t *testing.T) {
})
assert.NoError(t, err)
b, _, _ := testrig.Base(nil)
defer b.Close()
processCtx := process.NewProcessContext()
routers := httputil.NewRouters()
cfg := config.Dendrite{}
cfg.Defaults(config.DefaultOpts{Generate: true, SingleDatabase: true})
tempDir := t.TempDir()
socket := path.Join(tempDir, "socket")
// start base with the listener and wait for it to be started
address, err := config.UnixSocketAddress(socket, "755")
assert.NoError(t, err)
go b.SetupAndServeHTTP(address, nil, nil)
go basepkg.SetupAndServeHTTP(processCtx, &cfg, routers, address, nil, nil)
time.Sleep(time.Millisecond * 100)
client := &http.Client{