mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
refactor: update GMSL (#3058)
Sister PR to https://github.com/matrix-org/gomatrixserverlib/pull/364 Read this commit by commit to avoid going insane.
This commit is contained in:
parent
9fa39263c0
commit
72285b2659
306 changed files with 2117 additions and 1934 deletions
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/test/testrig"
|
||||
"github.com/matrix-org/gomatrixserverlib/fclient"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
"go.uber.org/atomic"
|
||||
"gotest.tools/v3/poll"
|
||||
|
||||
|
@ -91,7 +92,7 @@ func (f *stubFederationClient) SendTransaction(ctx context.Context, t gomatrixse
|
|||
return fclient.RespSend{}, result
|
||||
}
|
||||
|
||||
func (f *stubFederationClient) P2PSendTransactionToRelay(ctx context.Context, u gomatrixserverlib.UserID, t gomatrixserverlib.Transaction, forwardingServer gomatrixserverlib.ServerName) (res fclient.EmptyResp, err error) {
|
||||
func (f *stubFederationClient) P2PSendTransactionToRelay(ctx context.Context, u spec.UserID, t gomatrixserverlib.Transaction, forwardingServer spec.ServerName) (res fclient.EmptyResp, err error) {
|
||||
var result error
|
||||
if !f.shouldTxRelaySucceed {
|
||||
result = fmt.Errorf("relay transaction failed")
|
||||
|
@ -113,7 +114,7 @@ func mustCreatePDU(t *testing.T) *gomatrixserverlib.HeaderedEvent {
|
|||
|
||||
func mustCreateEDU(t *testing.T) *gomatrixserverlib.EDU {
|
||||
t.Helper()
|
||||
return &gomatrixserverlib.EDU{Type: gomatrixserverlib.MTyping}
|
||||
return &gomatrixserverlib.EDU{Type: spec.MTyping}
|
||||
}
|
||||
|
||||
func testSetup(failuresUntilBlacklist uint32, failuresUntilAssumedOffline uint32, shouldTxSucceed bool, shouldTxRelaySucceed bool, t *testing.T, dbType test.DBType, realDatabase bool) (storage.Database, *stubFederationClient, *OutgoingQueues, *process.ProcessContext, func()) {
|
||||
|
@ -143,7 +144,7 @@ func testSetup(failuresUntilBlacklist uint32, failuresUntilAssumedOffline uint32
|
|||
func TestSendPDUOnSuccessRemovedFromDB(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, true, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -152,7 +153,7 @@ func TestSendPDUOnSuccessRemovedFromDB(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -172,7 +173,7 @@ func TestSendPDUOnSuccessRemovedFromDB(t *testing.T) {
|
|||
func TestSendEDUOnSuccessRemovedFromDB(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, true, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -181,7 +182,7 @@ func TestSendEDUOnSuccessRemovedFromDB(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -201,7 +202,7 @@ func TestSendEDUOnSuccessRemovedFromDB(t *testing.T) {
|
|||
func TestSendPDUOnFailStoredInDB(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -210,7 +211,7 @@ func TestSendPDUOnFailStoredInDB(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -231,7 +232,7 @@ func TestSendPDUOnFailStoredInDB(t *testing.T) {
|
|||
func TestSendEDUOnFailStoredInDB(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -240,7 +241,7 @@ func TestSendEDUOnFailStoredInDB(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -261,7 +262,7 @@ func TestSendEDUOnFailStoredInDB(t *testing.T) {
|
|||
func TestSendPDUAgainDoesntInterruptBackoff(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -270,7 +271,7 @@ func TestSendPDUAgainDoesntInterruptBackoff(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -289,7 +290,7 @@ func TestSendPDUAgainDoesntInterruptBackoff(t *testing.T) {
|
|||
|
||||
fc.shouldTxSucceed = true
|
||||
ev = mustCreatePDU(t)
|
||||
err = queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err = queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
pollEnd := time.Now().Add(1 * time.Second)
|
||||
|
@ -312,7 +313,7 @@ func TestSendPDUAgainDoesntInterruptBackoff(t *testing.T) {
|
|||
func TestSendEDUAgainDoesntInterruptBackoff(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -321,7 +322,7 @@ func TestSendEDUAgainDoesntInterruptBackoff(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -340,7 +341,7 @@ func TestSendEDUAgainDoesntInterruptBackoff(t *testing.T) {
|
|||
|
||||
fc.shouldTxSucceed = true
|
||||
ev = mustCreateEDU(t)
|
||||
err = queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err = queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
pollEnd := time.Now().Add(1 * time.Second)
|
||||
|
@ -363,7 +364,7 @@ func TestSendEDUAgainDoesntInterruptBackoff(t *testing.T) {
|
|||
func TestSendPDUMultipleFailuresBlacklisted(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(2)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -372,7 +373,7 @@ func TestSendPDUMultipleFailuresBlacklisted(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -395,7 +396,7 @@ func TestSendPDUMultipleFailuresBlacklisted(t *testing.T) {
|
|||
func TestSendEDUMultipleFailuresBlacklisted(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(2)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -404,7 +405,7 @@ func TestSendEDUMultipleFailuresBlacklisted(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -427,7 +428,7 @@ func TestSendEDUMultipleFailuresBlacklisted(t *testing.T) {
|
|||
func TestSendPDUBlacklistedWithPriorExternalFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(2)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -438,7 +439,7 @@ func TestSendPDUBlacklistedWithPriorExternalFailure(t *testing.T) {
|
|||
queues.statistics.ForServer(destination).Failure()
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -461,7 +462,7 @@ func TestSendPDUBlacklistedWithPriorExternalFailure(t *testing.T) {
|
|||
func TestSendEDUBlacklistedWithPriorExternalFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(2)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -472,7 +473,7 @@ func TestSendEDUBlacklistedWithPriorExternalFailure(t *testing.T) {
|
|||
queues.statistics.ForServer(destination).Failure()
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -495,7 +496,7 @@ func TestSendEDUBlacklistedWithPriorExternalFailure(t *testing.T) {
|
|||
func TestRetryServerSendsPDUSuccessfully(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(1)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -507,7 +508,7 @@ func TestRetryServerSendsPDUSuccessfully(t *testing.T) {
|
|||
// before it is blacklisted and deleted.
|
||||
dest := queues.getQueue(destination)
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
checkBlacklisted := func(log poll.LogT) poll.Result {
|
||||
|
@ -546,7 +547,7 @@ func TestRetryServerSendsPDUSuccessfully(t *testing.T) {
|
|||
func TestRetryServerSendsEDUSuccessfully(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(1)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -558,7 +559,7 @@ func TestRetryServerSendsEDUSuccessfully(t *testing.T) {
|
|||
// before it is blacklisted and deleted.
|
||||
dest := queues.getQueue(destination)
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
checkBlacklisted := func(log poll.LogT) poll.Result {
|
||||
|
@ -597,7 +598,7 @@ func TestRetryServerSendsEDUSuccessfully(t *testing.T) {
|
|||
func TestSendPDUBatches(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
|
||||
// test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
// db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, true, t, dbType, true)
|
||||
|
@ -608,7 +609,7 @@ func TestSendPDUBatches(t *testing.T) {
|
|||
<-pc.WaitForShutdown()
|
||||
}()
|
||||
|
||||
destinations := map[gomatrixserverlib.ServerName]struct{}{destination: {}}
|
||||
destinations := map[spec.ServerName]struct{}{destination: {}}
|
||||
// Populate database with > maxPDUsPerTransaction
|
||||
pduMultiplier := uint32(3)
|
||||
for i := 0; i < maxPDUsPerTransaction*int(pduMultiplier); i++ {
|
||||
|
@ -620,7 +621,7 @@ func TestSendPDUBatches(t *testing.T) {
|
|||
}
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -641,7 +642,7 @@ func TestSendPDUBatches(t *testing.T) {
|
|||
func TestSendEDUBatches(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
|
||||
// test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
// db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, true, t, dbType, true)
|
||||
|
@ -652,7 +653,7 @@ func TestSendEDUBatches(t *testing.T) {
|
|||
<-pc.WaitForShutdown()
|
||||
}()
|
||||
|
||||
destinations := map[gomatrixserverlib.ServerName]struct{}{destination: {}}
|
||||
destinations := map[spec.ServerName]struct{}{destination: {}}
|
||||
// Populate database with > maxEDUsPerTransaction
|
||||
eduMultiplier := uint32(3)
|
||||
for i := 0; i < maxEDUsPerTransaction*int(eduMultiplier); i++ {
|
||||
|
@ -664,7 +665,7 @@ func TestSendEDUBatches(t *testing.T) {
|
|||
}
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -685,7 +686,7 @@ func TestSendEDUBatches(t *testing.T) {
|
|||
func TestSendPDUAndEDUBatches(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
|
||||
// test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
// db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, true, t, dbType, true)
|
||||
|
@ -696,7 +697,7 @@ func TestSendPDUAndEDUBatches(t *testing.T) {
|
|||
<-pc.WaitForShutdown()
|
||||
}()
|
||||
|
||||
destinations := map[gomatrixserverlib.ServerName]struct{}{destination: {}}
|
||||
destinations := map[spec.ServerName]struct{}{destination: {}}
|
||||
// Populate database with > maxEDUsPerTransaction
|
||||
multiplier := uint32(3)
|
||||
for i := 0; i < maxPDUsPerTransaction*int(multiplier)+1; i++ {
|
||||
|
@ -716,7 +717,7 @@ func TestSendPDUAndEDUBatches(t *testing.T) {
|
|||
}
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -739,7 +740,7 @@ func TestSendPDUAndEDUBatches(t *testing.T) {
|
|||
func TestExternalFailureBackoffDoesntStartQueue(t *testing.T) {
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, true, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -749,7 +750,7 @@ func TestExternalFailureBackoffDoesntStartQueue(t *testing.T) {
|
|||
|
||||
dest := queues.getQueue(destination)
|
||||
queues.statistics.ForServer(destination).Failure()
|
||||
destinations := map[gomatrixserverlib.ServerName]struct{}{destination: {}}
|
||||
destinations := map[spec.ServerName]struct{}{destination: {}}
|
||||
ev := mustCreatePDU(t)
|
||||
headeredJSON, _ := json.Marshal(ev)
|
||||
nid, _ := db.StoreJSON(pc.Context(), string(headeredJSON))
|
||||
|
@ -775,8 +776,8 @@ func TestQueueInteractsWithRealDatabasePDUAndEDU(t *testing.T) {
|
|||
// NOTE : Only one test case against real databases can be run at a time.
|
||||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(1)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destinations := map[gomatrixserverlib.ServerName]struct{}{destination: {}}
|
||||
destination := spec.ServerName("remotehost")
|
||||
destinations := map[spec.ServerName]struct{}{destination: {}}
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilBlacklist+1, false, false, t, dbType, true)
|
||||
// NOTE : These defers aren't called if go test is killed so the dbs may not get cleaned up.
|
||||
|
@ -790,7 +791,7 @@ func TestQueueInteractsWithRealDatabasePDUAndEDU(t *testing.T) {
|
|||
// before it is blacklisted and deleted.
|
||||
dest := queues.getQueue(destination)
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
// NOTE : The server can be blacklisted before this, so manually inject the event
|
||||
|
@ -843,7 +844,7 @@ func TestSendPDUMultipleFailuresAssumedOffline(t *testing.T) {
|
|||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(7)
|
||||
failuresUntilAssumedOffline := uint32(2)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilAssumedOffline, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -852,7 +853,7 @@ func TestSendPDUMultipleFailuresAssumedOffline(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -876,7 +877,7 @@ func TestSendEDUMultipleFailuresAssumedOffline(t *testing.T) {
|
|||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(7)
|
||||
failuresUntilAssumedOffline := uint32(2)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilAssumedOffline, false, false, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -885,7 +886,7 @@ func TestSendEDUMultipleFailuresAssumedOffline(t *testing.T) {
|
|||
}()
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -909,7 +910,7 @@ func TestSendPDUOnRelaySuccessRemovedFromDB(t *testing.T) {
|
|||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
failuresUntilAssumedOffline := uint32(1)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilAssumedOffline, false, true, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -917,11 +918,11 @@ func TestSendPDUOnRelaySuccessRemovedFromDB(t *testing.T) {
|
|||
<-pc.WaitForShutdown()
|
||||
}()
|
||||
|
||||
relayServers := []gomatrixserverlib.ServerName{"relayserver"}
|
||||
relayServers := []spec.ServerName{"relayserver"}
|
||||
queues.statistics.ForServer(destination).AddRelayServers(relayServers)
|
||||
|
||||
ev := mustCreatePDU(t)
|
||||
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEvent(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
@ -948,7 +949,7 @@ func TestSendEDUOnRelaySuccessRemovedFromDB(t *testing.T) {
|
|||
t.Parallel()
|
||||
failuresUntilBlacklist := uint32(16)
|
||||
failuresUntilAssumedOffline := uint32(1)
|
||||
destination := gomatrixserverlib.ServerName("remotehost")
|
||||
destination := spec.ServerName("remotehost")
|
||||
db, fc, queues, pc, close := testSetup(failuresUntilBlacklist, failuresUntilAssumedOffline, false, true, t, test.DBTypeSQLite, false)
|
||||
defer close()
|
||||
defer func() {
|
||||
|
@ -956,11 +957,11 @@ func TestSendEDUOnRelaySuccessRemovedFromDB(t *testing.T) {
|
|||
<-pc.WaitForShutdown()
|
||||
}()
|
||||
|
||||
relayServers := []gomatrixserverlib.ServerName{"relayserver"}
|
||||
relayServers := []spec.ServerName{"relayserver"}
|
||||
queues.statistics.ForServer(destination).AddRelayServers(relayServers)
|
||||
|
||||
ev := mustCreateEDU(t)
|
||||
err := queues.SendEDU(ev, "localhost", []gomatrixserverlib.ServerName{destination})
|
||||
err := queues.SendEDU(ev, "localhost", []spec.ServerName{destination})
|
||||
assert.NoError(t, err)
|
||||
|
||||
check := func(log poll.LogT) poll.Result {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue