Documentation ¶
Overview ¶
Package integration holds test-only code for running tests on an integrated system of the CT personality and a Trillian log.
Index ¶
- Constants
- Variables
- func CertsFromPEM(data []byte) []ct.ASN1Cert
- func GetChain(dir, path string) ([]ct.ASN1Cert, error)
- func HammerCTLog(cfg HammerConfig) error
- func MakeSigner(testdir string) (crypto.Signer, error)
- func RunCTIntegrationForLog(cfg *configpb.LogConfig, servers, metricsServers, testdir string, ...) error
- func RunCTLifecycleForLog(cfg *configpb.LogConfig, servers, metricsServers, adminServer string, ...) error
- type CTLogEnv
- type Choice
- type ClientPool
- type HammerBias
- type HammerConfig
- type Limiter
- type RandomPool
Constants ¶
const ( ParamTooBig = Choice("ParamTooBig") Param2TooBig = Choice("Param2TooBig") ParamNegative = Choice("ParamNegative") ParamInvalid = Choice("ParamInvalid") ParamsInverted = Choice("ParamsInverted") InvalidBase64 = Choice("InvalidBase64") EmptyChain = Choice("EmptyChain") CertNotPrecert = Choice("CertNotPrecert") PrecertNotCert = Choice("PrecertNotCert") NoChainToRoot = Choice("NoChainToRoot") UnparsableCert = Choice("UnparsableCert") SignatureNotCorrect = Choice("SignatureNotCorrect") NewCert = Choice("NewCert") LastCert = Choice("LastCert") FirstCert = Choice("FirstCert") )
Constants for per-operation choices.
Variables ¶
var DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, MaxIdleConns: 1000, MaxIdleConnsPerHost: 1000, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }
DefaultTransport is a http Transport more suited for use in the hammer context. In particular it increases the number of reusable connections to the same host. This helps to prevent starvation of ports through TIME_WAIT when using the hammer with a high number of parallel chain submissions.
var Verifier = merkle.NewLogVerifier(rfc6962.DefaultHasher)
Verifier is used to verify Merkle tree calculations.
Functions ¶
func CertsFromPEM ¶
CertsFromPEM loads X.509 certificates from the provided PEM-encoded data.
func HammerCTLog ¶
func HammerCTLog(cfg HammerConfig) error
HammerCTLog performs load/stress operations according to given config.
func MakeSigner ¶
MakeSigner creates a signer using the private key in the test directory.
func RunCTIntegrationForLog ¶
func RunCTIntegrationForLog(cfg *configpb.LogConfig, servers, metricsServers, testdir string, mmd time.Duration, stats *logStats) error
RunCTIntegrationForLog tests against the log with configuration cfg, with a set of comma-separated server addresses given by servers, assuming that testdir holds a variety of test data files. nolint: gocyclo
func RunCTLifecycleForLog ¶ added in v1.0.20
func RunCTLifecycleForLog(cfg *configpb.LogConfig, servers, metricsServers, adminServer string, testDir string, mmd time.Duration, stats *logStats) error
RunCTLifecycleForLog does a simple log lifecycle test. The log is assumed to be newly created when this test runs. A random number of entries are then submitted to build up a queue. The log is set to DRAINING state and the test checks that all the entries are integrated into the tree and we can verify a consistency proof to the latest entry.
Types ¶
type CTLogEnv ¶
type CTLogEnv struct { CTAddr string // contains filtered or unexported fields }
CTLogEnv is a test environment that contains both a log server and a CT personality connected to it.
func NewCTLogEnv ¶
func NewCTLogEnv(ctx context.Context, cfgs []*configpb.LogConfig, numSequencers int, testID string) (*CTLogEnv, error)
NewCTLogEnv creates a fresh DB, log server, and CT personality. testID should be unique to each unittest package so as to allow parallel tests. Created logIDs will be set to cfgs.
type Choice ¶ added in v1.0.21
type Choice string
Choice represents a random decision about a hammer operation.
type ClientPool ¶
type ClientPool interface { // Next returns the next LogClient instance to be used. Next() *client.LogClient }
ClientPool describes an entity which produces LogClient instances.
func NewRandomPool ¶
NewRandomPool creates a pool which returns a random client from list of servers.
type HammerBias ¶
type HammerBias struct { Bias map[ctfe.EntrypointName]int // InvalidChance gives the odds of performing an invalid operation, as the N in 1-in-N. InvalidChance map[ctfe.EntrypointName]int // contains filtered or unexported fields }
HammerBias indicates the bias for selecting different log operations.
func (HammerBias) Choose ¶
func (hb HammerBias) Choose() ctfe.EntrypointName
Choose randomly picks an operation to perform according to the biases.
func (HammerBias) Invalid ¶
func (hb HammerBias) Invalid(ep ctfe.EntrypointName) bool
Invalid randomly chooses whether an operation should be invalid.
type HammerConfig ¶
type HammerConfig struct { // Configuration for the log. LogCfg *configpb.LogConfig // How to create process-wide metrics. MetricFactory monitoring.MetricFactory // Maximum merge delay. MMD time.Duration // Leaf certificate chain to use as template. LeafChain []ct.ASN1Cert // Parsed leaf certificate to use as template. LeafCert *x509.Certificate // Intermediate CA certificate chain to use as re-signing CA. CACert *x509.Certificate Signer crypto.Signer // ClientPool provides the clients used to make requests. ClientPool ClientPool // Bias values to favor particular log operations. EPBias HammerBias // Range of how many entries to get. MinGetEntries, MaxGetEntries int // OversizedGetEntries governs whether get-entries requests that go beyond the // current tree size are allowed (with a truncated response expected). OversizedGetEntries bool // Number of operations to perform. Operations uint64 // Rate limiter Limiter Limiter // MaxParallelChains sets the upper limit for the number of parallel // add-*-chain requests to make when the biasing model says to perfom an add. MaxParallelChains int // EmitInterval defines how frequently stats are logged. EmitInterval time.Duration // IgnoreErrors controls whether a hammer run fails immediately on any error. IgnoreErrors bool // MaxRetryDuration governs how long to keep retrying when IgnoreErrors is true. MaxRetryDuration time.Duration // NotAfterOverride is used as cert and precert's NotAfter if not zeroed. // It takes precedence over automatic NotAfter fixing for temporal logs. NotAfterOverride time.Time }
HammerConfig provides configuration for a stress/load test.
type Limiter ¶
type Limiter interface {
Wait()
}
Limiter is an interface to allow different rate limiters to be used with the hammer.
type RandomPool ¶
RandomPool holds a collection of CT LogClient instances.
func (RandomPool) Next ¶
func (p RandomPool) Next() *client.LogClient
Next picks a random client from the pool.