Documentation
¶
Index ¶
- Constants
- Variables
- func IndexEditHookProvider(group string) fx.Annotated
- func IsRecording() bool
- func NewEditingIndexForTestingHook() opensearch.BeforeHook
- func NewRecorder(options ...Options) (*recorder.Recorder, error)
- func SearchDelayerHookProvider(group string, delay time.Duration) (fx.Annotated, fx.Annotated)
- func WithOpenSearchPlayback(options ...Options) test.Options
- type BulkJsonBodyMatcher
- type EditIndexForTestingHook
- type Mode
- type Option
- type Options
- type SearchDelayer
Constants ¶
const IndexSuffix = "_test"
IndexSuffix is the suffix we append to the index name when running opensearch tests, so that we don't corrupt the application's indices.
Variables ¶
var ( ErrCreatingRecorder = errors.New("unable to create recorder") ErrNoCassetteName = errors.New("requires cassette name") )
Functions ¶
func IndexEditHookProvider ¶
func IsRecording ¶
func IsRecording() bool
IsRecording returns true if copyist is currently in recording mode. We wrap the copyist.IsRecording because we re-use the same commandline flag as the copyist library, and flag.Bool doesn't like it when you have two places that listen to the same flag
func NewEditingIndexForTestingHook ¶
func NewEditingIndexForTestingHook() opensearch.BeforeHook
func NewRecorder ¶
NewRecorder will create a recorder configured by the RecordOptions
func WithOpenSearchPlayback ¶
WithOpenSearchPlayback will setup the recorder, similar to crdb's copyist functionality where actual interactions with opensearch will be recorded, and then when the mode is set to ModeReplaying, the recorder will respond with its recorded responses. the parameter recordDelay defines how long of a delay is needed between a write to opensearch, and a read. opensearch does not immediately have writes available, so the only solution right now is to delay and reads that happen immediately after a write. For some reason, the refresh options on the index to opensearch are not working.
To control what is being matched in the http vcr, this function will provide a *MatcherBodyModifiers to uber.FX.
Types ¶
type BulkJsonBodyMatcher ¶
type BulkJsonBodyMatcher struct {
Delegate ittest.RecordBodyMatcher
}
BulkJsonBodyMatcher special body matcher for OpenSearch's _bulk API See https://opensearch.org/docs/2.11/api-reference/document-apis/bulk/
func (BulkJsonBodyMatcher) Matches ¶
func (m BulkJsonBodyMatcher) Matches(out []byte, record []byte) error
func (BulkJsonBodyMatcher) Support ¶
func (m BulkJsonBodyMatcher) Support(contentType string) bool
type EditIndexForTestingHook ¶
type EditIndexForTestingHook struct {
Suffix string
}
func (*EditIndexForTestingHook) Before ¶
func (e *EditIndexForTestingHook) Before(ctx context.Context, before opensearch.BeforeContext) context.Context
func (*EditIndexForTestingHook) Order ¶
func (e *EditIndexForTestingHook) Order() int
type Options ¶
type Options func(opt *Option)
func FuzzyJsonPaths ¶
FuzzyJsonPaths ignore part of JSON body with JSONPath notation during playback mode. Useful for search queries with time-sensitive fields e.g. FuzzyJsonPaths("$.query.*.Time") JSONPath Syntax: https://goessner.net/articles/JsonPath/
func ReplayMode ¶
ReplayMode override recording/playback mode. Default is ModeCommandline
func SetRecordDelay ¶
SetRecordDelay add delay between each request. Note: original request latency is applied by default. This is the additional delay between each requests
func SetRecordMode ¶
func SkipRequestLatency ¶
SkipRequestLatency disable mimic request latency in playback mode. Has no effect during recording By default, original request latency during recording is applied in playback mode.
type SearchDelayer ¶
SearchDelayer will ensure that all searches that happen after inserting a document will have a delay so that the search can find all the documents.
func SearchDelayerHook ¶
func SearchDelayerHook(delay time.Duration) *SearchDelayer
func (*SearchDelayer) After ¶
func (s *SearchDelayer) After(ctx context.Context, afterContext opensearch.AfterContext) context.Context
func (*SearchDelayer) Before ¶
func (s *SearchDelayer) Before(ctx context.Context, beforeContext opensearch.BeforeContext) context.Context