mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fnlb/k8s grouper (#563)
* WIP: add k8s grouper - This shares a great deal of behaviour with allGrouper. Once it's tested, refactor that to share as much as possible - Glide hell. Checked in the yaml and lock files but a glide i -v will be required to bring vendor/ up-to-date. Will address once this is ready. * Update README. Make the watch tracking work. (To follow: add the junk that was pulled in via the glide update.) * Vendor updates. * go fmt * Use the allGrouper with a k8s-backed DBStore instead. This is much tidier :-) * Fix up go vet
This commit is contained in:
157
vendor/github.com/ugorji/go/codec/helper_test.go
generated
vendored
157
vendor/github.com/ugorji/go/codec/helper_test.go
generated
vendored
@@ -5,14 +5,171 @@ package codec
|
||||
|
||||
// All non-std package dependencies related to testing live in this file,
|
||||
// so porting to different environment is easy (just update functions).
|
||||
//
|
||||
// This file sets up the variables used, including testInitFns.
|
||||
// Each file should add initialization that should be performed
|
||||
// after flags are parsed.
|
||||
//
|
||||
// init is a multi-step process:
|
||||
// - setup vars (handled by init functions in each file)
|
||||
// - parse flags
|
||||
// - setup derived vars (handled by pre-init registered functions - registered in init function)
|
||||
// - post init (handled by post-init registered functions - registered in init function)
|
||||
// This way, no one has to manage carefully control the initialization
|
||||
// using file names, etc.
|
||||
//
|
||||
// Tests which require external dependencies need the -tag=x parameter.
|
||||
// They should be run as:
|
||||
// go test -tags=x -run=. <other parameters ...>
|
||||
// Benchmarks should also take this parameter, to include the sereal, xdr, etc.
|
||||
// To run against codecgen, etc, make sure you pass extra parameters.
|
||||
// Example usage:
|
||||
// go test "-tags=x codecgen unsafe" -bench=. <other parameters ...>
|
||||
//
|
||||
// To fully test everything:
|
||||
// go test -tags=x -benchtime=100ms -tv -bg -bi -brw -bu -v -run=. -bench=.
|
||||
|
||||
// Handling flags
|
||||
// codec_test.go will define a set of global flags for testing, including:
|
||||
// - Use Reset
|
||||
// - Use IO reader/writer (vs direct bytes)
|
||||
// - Set Canonical
|
||||
// - Set InternStrings
|
||||
// - Use Symbols
|
||||
//
|
||||
// This way, we can test them all by running same set of tests with a different
|
||||
// set of flags.
|
||||
//
|
||||
// Following this, all the benchmarks will utilize flags set by codec_test.go
|
||||
// and will not redefine these "global" flags.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type testHED struct {
|
||||
H Handle
|
||||
E *Encoder
|
||||
D *Decoder
|
||||
}
|
||||
|
||||
var (
|
||||
testNoopH = NoopHandle(8)
|
||||
testMsgpackH = &MsgpackHandle{}
|
||||
testBincH = &BincHandle{}
|
||||
testSimpleH = &SimpleHandle{}
|
||||
testCborH = &CborHandle{}
|
||||
testJsonH = &JsonHandle{}
|
||||
|
||||
testHandles []Handle
|
||||
testPreInitFns []func()
|
||||
testPostInitFns []func()
|
||||
|
||||
testOnce sync.Once
|
||||
|
||||
testHEDs []testHED
|
||||
)
|
||||
|
||||
// variables used by tests
|
||||
var (
|
||||
testVerbose bool
|
||||
testInitDebug bool
|
||||
testUseIoEncDec bool
|
||||
testStructToArray bool
|
||||
testCanonical bool
|
||||
testUseReset bool
|
||||
testWriteNoSymbols bool
|
||||
testSkipIntf bool
|
||||
testInternStr bool
|
||||
testUseMust bool
|
||||
testCheckCircRef bool
|
||||
testJsonIndent int
|
||||
)
|
||||
|
||||
func init() {
|
||||
testHEDs = make([]testHED, 0, 32)
|
||||
testHandles = append(testHandles,
|
||||
testNoopH, testMsgpackH, testBincH, testSimpleH,
|
||||
testCborH, testJsonH)
|
||||
}
|
||||
|
||||
func testHEDGet(h Handle) *testHED {
|
||||
for i := range testHEDs {
|
||||
v := &testHEDs[i]
|
||||
if v.H == h {
|
||||
return v
|
||||
}
|
||||
}
|
||||
testHEDs = append(testHEDs, testHED{h, NewEncoder(nil, h), NewDecoder(nil, h)})
|
||||
return &testHEDs[len(testHEDs)-1]
|
||||
}
|
||||
|
||||
func testInitAll() {
|
||||
flag.Parse()
|
||||
for _, f := range testPreInitFns {
|
||||
f()
|
||||
}
|
||||
for _, f := range testPostInitFns {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
func testCodecEncode(ts interface{}, bsIn []byte,
|
||||
fn func([]byte) *bytes.Buffer, h Handle) (bs []byte, err error) {
|
||||
// bs = make([]byte, 0, approxSize)
|
||||
var e *Encoder
|
||||
var buf *bytes.Buffer
|
||||
if testUseReset {
|
||||
e = testHEDGet(h).E
|
||||
} else {
|
||||
e = NewEncoder(nil, h)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
buf = fn(bsIn)
|
||||
e.Reset(buf)
|
||||
} else {
|
||||
bs = bsIn
|
||||
e.ResetBytes(&bs)
|
||||
}
|
||||
if testUseMust {
|
||||
e.MustEncode(ts)
|
||||
} else {
|
||||
err = e.Encode(ts)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
bs = buf.Bytes()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func testCodecDecode(bs []byte, ts interface{}, h Handle) (err error) {
|
||||
var d *Decoder
|
||||
var buf *bytes.Reader
|
||||
if testUseReset {
|
||||
d = testHEDGet(h).D
|
||||
} else {
|
||||
d = NewDecoder(nil, h)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
buf = bytes.NewReader(bs)
|
||||
d.Reset(buf)
|
||||
} else {
|
||||
d.ResetBytes(bs)
|
||||
}
|
||||
if testUseMust {
|
||||
d.MustDecode(ts)
|
||||
} else {
|
||||
err = d.Decode(ts)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ----- functions below are used only by tests (not benchmarks)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user