Documentation
¶
Overview ¶
Package dialtest is the test support of the kinds of segment store (`segmentstore.Kind`): a loopback store that speaks enough RESP for go-redis and valkey-go, and the cases that every kind must pass, run by the tests of each kind (`redisdial`, `valkeydial`) in its own package, so that each is measured by its own tests.
Index ¶
- Constants
- func AssertClientSpans(t *testing.T, sink *tracetest.SpanRecorder, parent trace.SpanContext, ...)
- func CABundles(t *testing.T) func(string) ([]byte, error)
- func Connection(t *testing.T, suite Suite, address, extra string) *bootstrap.Connection
- func Kinds(t *testing.T, kinds ...segmentstore.Kind) segmentstore.Kinds
- func NewTracing(t *testing.T) (tracing.Providers, *tracetest.SpanRecorder)
- func Run(t *testing.T, suite Suite)
- func SecretEnv(name string) (string, bool)
- func StateOf(conns *segmentstore.Connections, name string) string
- type Cluster
- type Stub
- func (s *Stub) Address() string
- func (s *Stub) Answer(raw string)
- func (s *Stub) Commands() [][]string
- func (s *Stub) Delete(key string)
- func (s *Stub) FailCommand(name, raw string)
- func (s *Stub) FailKey(key, raw string)
- func (s *Stub) HoldKey(key string, hold func(ctx context.Context))
- func (s *Stub) Put(key, value string)
- func (s *Stub) PutSet(key string, members ...string)
- func (s *Stub) RequireAuth(user, password string)
- func (s *Stub) StallKey(key string, stall func(ctx context.Context))
- type Suite
Constants ¶
const ( // WaitFor is the bound of a wait of a test for an outcome that must come. WaitFor = 10 * time.Second // Tick is the retry interval of the dial loop in the tests. Tick = 5 * time.Millisecond )
const (
// Password is the secret of the connections of the suite: it must be in no error and in no span.
Password = "s3cr3t-pass"
)
Variables ¶
This section is empty.
Functions ¶
func AssertClientSpans ¶
func AssertClientSpans(t *testing.T, sink *tracetest.SpanRecorder, parent trace.SpanContext, secrets ...string)
AssertClientSpans checks the spans that the sink recorded: the spans that are children of parent exist, are client spans of the trace of parent, and no span carries one of the secrets in any text.
func CABundles ¶
CABundles serves the CA bundle files of the suite: "/ca.pem" is a real certificate, "/notpem" is not PEM, and any other name cannot be read.
func Connection ¶
Connection parses one connection named "store" of the kind: its addresses, the settings of the suite, and extra (more settings, may be empty).
func Kinds ¶
func Kinds(t *testing.T, kinds ...segmentstore.Kind) segmentstore.Kinds
Kinds are the kinds of the arguments by type.
func NewTracing ¶
NewTracing returns tracing providers that record into the returned recorder; they are shut down with the test.
func StateOf ¶
func StateOf(conns *segmentstore.Connections, name string) string
StateOf is the state of the connection of that name, empty for a name that has none.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is stubs that answer as the nodes of a Redis cluster do (CLUSTER SLOTS, MOVED).
func StartCluster ¶
StartCluster starts a cluster of n stubs.
type Stub ¶
type Stub struct {
// contains filtered or unexported fields
}
Stub is a loopback store. Its listener is open from the start and it is closed when the test ends. It speaks the handshake of go-redis and valkey-go (HELLO, CLIENT, SELECT, CLUSTER, PING) and the commands of the segment providers (SMISMEMBER, GET) over the sets and values it was given; Stub.Answer replaces every reply.
func StartStub ¶
StartStub starts a stub that holds the sets (a key and its members) and the string values (a key and its value).
func StartTLSStub ¶
StartTLSStub is StartStub over TLS: the certificate of the stub (for 127.0.0.1) is signed by a CA that is the second result, a PEM bundle.
func (*Stub) Answer ¶
Answer makes the stub reply to every command, the handshake included, with raw (RESP bytes); an empty reply makes it close the connection at the first command, like a store that is not a store.
func (*Stub) Commands ¶
Commands is the commands the stub received, each as its arguments, in order.
func (*Stub) FailCommand ¶
FailCommand makes every command of that name (SCAN, GET) answer with raw until it is called again with an empty reply.
func (*Stub) FailKey ¶
FailKey makes every GET of the key answer with raw (RESP bytes, for example "-NOPERM no permission\r\n") until it is called again for the key with an empty reply.
func (*Stub) HoldKey ¶
HoldKey makes a GET of the key call hold before it is answered, with a context that ends when the client closes the connection (a cancelled or timed out read); the answer follows when hold returns. A nil hold clears it.
func (*Stub) RequireAuth ¶
RequireAuth makes the stub refuse every command of a connection that did not authenticate with the user (empty for the default user) and the password: HELLO 3 AUTH or AUTH. A connection that is open keeps its login when the password changes, as on a real server.
type Suite ¶
type Suite struct {
// Kind is the kind under test.
Kind segmentstore.Kind
// package of the kind.
Unavailable error
// Settings are the settings that a connection of the kind needs besides its addresses, as the body of a YAML flow
// mapping (a connection of the kind that fails fast, for example); may be empty.
Settings string
}
Suite describes a kind for Run.