mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
fix integration test, the delay for new senders was causing our db open to fail
This commit is contained in:
parent
6df4b454d5
commit
cafccefad1
2 changed files with 13 additions and 3 deletions
|
@ -8,14 +8,18 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
bolt "go.etcd.io/bbolt"
|
||||||
|
|
||||||
"github.com/mjl-/bstore"
|
"github.com/mjl-/bstore"
|
||||||
|
|
||||||
"github.com/mjl-/mox/mlog"
|
"github.com/mjl-/mox/mlog"
|
||||||
|
@ -35,7 +39,8 @@ func tcheck(t *testing.T, err error, msg string) {
|
||||||
// We check if we receive the message.
|
// We check if we receive the message.
|
||||||
func TestDeliver(t *testing.T) {
|
func TestDeliver(t *testing.T) {
|
||||||
mlog.Logfmt = true
|
mlog.Logfmt = true
|
||||||
mox.Context = context.Background()
|
mox.Context, mox.ContextCancel = context.WithCancel(context.Background())
|
||||||
|
mox.Shutdown, mox.ShutdownCancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
// Remove state.
|
// Remove state.
|
||||||
os.RemoveAll("testdata/integration/run")
|
os.RemoveAll("testdata/integration/run")
|
||||||
|
@ -43,6 +48,7 @@ func TestDeliver(t *testing.T) {
|
||||||
|
|
||||||
// Load mox config.
|
// Load mox config.
|
||||||
mox.ConfigStaticPath = "testdata/integration/mox.conf"
|
mox.ConfigStaticPath = "testdata/integration/mox.conf"
|
||||||
|
filepath.Join(filepath.Dir(mox.ConfigStaticPath), "domains.conf")
|
||||||
if errs := mox.LoadConfig(mox.Context); len(errs) > 0 {
|
if errs := mox.LoadConfig(mox.Context); len(errs) > 0 {
|
||||||
t.Fatalf("loading mox config: %v", errs)
|
t.Fatalf("loading mox config: %v", errs)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +77,11 @@ func TestDeliver(t *testing.T) {
|
||||||
latestMsgID := func(username string) int64 {
|
latestMsgID := func(username string) int64 {
|
||||||
// We open the account index database created by mox for the test user. And we keep looking for the email we sent.
|
// We open the account index database created by mox for the test user. And we keep looking for the email we sent.
|
||||||
dbpath := fmt.Sprintf("testdata/integration/run/accounts/%s/index.db", username)
|
dbpath := fmt.Sprintf("testdata/integration/run/accounts/%s/index.db", username)
|
||||||
db, err := bstore.Open(dbpath, &bstore.Options{Timeout: 5 * time.Second}, store.Message{}, store.Recipient{}, store.Mailbox{}, store.Password{})
|
db, err := bstore.Open(dbpath, &bstore.Options{Timeout: 3 * time.Second}, store.Message{}, store.Recipient{}, store.Mailbox{}, store.Password{})
|
||||||
|
if err != nil && errors.Is(err, bolt.ErrTimeout) {
|
||||||
|
log.Printf("db open timeout (normal delay for new sender with account and db file kept open)")
|
||||||
|
return 0
|
||||||
|
}
|
||||||
tcheck(t, err, "open test account database")
|
tcheck(t, err, "open test account database")
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
|
2
testdata/integration/mox.conf
vendored
2
testdata/integration/mox.conf
vendored
|
@ -1,5 +1,5 @@
|
||||||
DataDir: ./run
|
DataDir: ./run
|
||||||
LogLevel: info
|
LogLevel: trace
|
||||||
Hostname: moxmail1.mox1.example
|
Hostname: moxmail1.mox1.example
|
||||||
TLS:
|
TLS:
|
||||||
CA:
|
CA:
|
||||||
|
|
Loading…
Reference in a new issue