Documentation
¶
Overview ¶
Package rpctest runs a real notesd API server (store, blobs, broker, vaults, engine and rpcserver) on a temporary socket, for tests of clients such as notesctl. The socket, the serving goroutine and its stop are lodge's kit's (github.com/frostyard/lodge/kit/rpctest).
Index ¶
Constants ¶
const Name = "notesd rpctest"
Name is what the test server reports from rpc.hello.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
kitrpctest.Options[api.Services]
// Log receives the server's logs; nil discards them.
Log *slog.Logger
// DataDir holds the database; empty means a fresh temporary directory.
// Reusing one after Stop restarts notesd on the same data.
DataDir string
// Now, when set, is the clock for stored timestamps.
Now func() time.Time
// Vault tunes the vaults' actors (intervals, batch size); its DB,
// Blobs, Log, Publish and, when Now is set, Now are filled in.
Vault vault.Config
// HubListen serves the hub's endpoints on a loopback port, at
// Server.HubURL, as notesd --hub does; HubAddr, when set, is the
// address, so a restarted hub keeps its URL.
HubListen bool
HubAddr string
// Crash is the simulation's crash points (vault.Config.Crash and its
// syncer and hub counterparts).
Crash func(point string) bool
// Syncer tunes the device's sync loops (quiet periods, backoff, the
// device's name); its stores, broker, secrets, log and, when Now is
// set, Now are filled in.
Syncer syncer.Config
// Build is what rpc.hello reports as build (rpcserver.Options.Build).
Build string
}
Options configure a test server. Their Services, when set, edit the engine's services before the router is built, so a client's tests can serve a fake domain.
type Server ¶
type Server struct {
Socket string
Run *kitrpctest.Run
DB *store.DB
Blobs *blobs.Store
Broker *events.Broker
Vaults *vault.Manager
RPC *rpcserver.Server
// Router serves every domain; pass it to RPC.ServeConn to test a
// connection of another caller kind.
Router *api.Router
// Hub and Syncer are this notesd's hub role and sync loops; Secrets
// keeps its device tokens, in a file. HubURL is set with HubListen.
Hub *hub.Hub
Syncer *syncer.Syncer
Secrets secrets.Store
HubURL string
// contains filtered or unexported fields
}
Server is a running test server; it stops when the test ends.
func StartWith ¶
StartWith runs a server with a fresh database, on a socket of its own (SocketPath).
func (*Server) DialAs ¶
DialAs connects as a connection its listener authenticated as id (a session or an agent behind lodge, a device) over an in-process pipe, and completes rpc.hello; the client closes when the test ends.