mock

package
v0.0.0-...-9750751 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEF_OPCODE     = OpCodeNop
	DEF_STATUS     = uint8(OpStatusNoError)
	DEF_DELAY      = 0
	DEF_VER        = 1
	DEF_NORESPONSE = false
	DEF_SAVE       = false
	DEF_NS         = "ns"
)

Variables

This section is empty.

Functions

func NewMockStorageService

func NewMockStorageService(conf SSConfig, addrs ...string) *service.Service

Types

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

func NewMockClient

func NewMockClient(ssconnInfo [][]string, conf client.Config) *MockClient

func (*MockClient) Batch

func (c *MockClient) Batch(msgs []*proto.OperationalMessage, mp []*MockParams) (responses []*proto.OperationalMessage, err error)

func (*MockClient) BatchCreate

func (c *MockClient) BatchCreate(keys [][]byte, value []byte, ttl uint32) []*proto.OperationalMessage

func (*MockClient) Close

func (c *MockClient) Close()

func (*MockClient) Create

func (c *MockClient) Create(key []byte, value []byte, ttl uint32, mp *MockParams) (context client.IContext, err error)

func (*MockClient) Destroy

func (c *MockClient) Destroy(key []byte, mp *MockParams) error

func (*MockClient) Get

func (c *MockClient) Get(key []byte, mp *MockParams) (value []byte, context client.IContext, err error)

func (*MockClient) NewRequest

func (c *MockClient) NewRequest(op proto.OpCode, key []byte, value []byte, ttl uint32) (request *proto.OperationalMessage)

func (*MockClient) ReSetMockInfo

func (c *MockClient) ReSetMockInfo()

func (*MockClient) ResetClient

func (c *MockClient) ResetClient(ns string)

func (*MockClient) Set

func (c *MockClient) Set(key []byte, value []byte, ttl uint32, mp *MockParams) (client.IContext, error)

func (*MockClient) SetMockInfo

func (c *MockClient) SetMockInfo(conn net.Conn, m *MockInfo) bool

func (*MockClient) Update

func (c *MockClient) Update(key []byte, value []byte, ttl uint32, mp *MockParams) (client.IContext, error)

type MockInfo

type MockInfo struct {
	Namespace    string
	Opcode       OpCode
	Status       uint8
	Delay        uint32
	Version      uint32
	NoResponse   bool
	Save         bool
	Value        []byte // expected value if set
	CreationTime uint32
}

Mock specification for one storage server if opcode is set to OpCodeNop, it will apply to all opcode; otherwise apply to specific opcode

func NewMockInfo

func NewMockInfo() *MockInfo

func (*MockInfo) Decode

func (m *MockInfo) Decode(value *bytes.Buffer) error

func (*MockInfo) Encode

func (m *MockInfo) Encode() (*bytes.Buffer, error)

func (*MockInfo) GetStatusText

func (m *MockInfo) GetStatusText() string

func (*MockInfo) ToString

func (m *MockInfo) ToString() string

type MockParams

type MockParams struct {
	NumSS        uint8
	MockInfoList []MockInfo
}

Mock spec for a group of storage servers (in different rack)

func NewMockParams

func NewMockParams(numss uint8) *MockParams

func (*MockParams) Decode

func (m *MockParams) Decode(value *bytes.Buffer) error

func (*MockParams) Encode

func (m *MockParams) Encode() (*bytes.Buffer, error)

func (*MockParams) Log

func (m *MockParams) Log(t *testing.T)

func (*MockParams) Reset

func (m *MockParams) Reset(numss uint8)

func (*MockParams) SetOpCodeForAll

func (m *MockParams) SetOpCodeForAll(code OpCode)

func (*MockParams) SetStatus

func (m *MockParams) SetStatus(status ...uint8)

func (*MockParams) SetStatusForAll

func (m *MockParams) SetStatusForAll(status uint8)

func (*MockParams) SetValue

func (m *MockParams) SetValue(values ...[]byte)

func (*MockParams) SetValueForAll

func (m *MockParams) SetValueForAll(value []byte)

func (*MockParams) SetVersion

func (m *MockParams) SetVersion(versions ...uint32)

func (*MockParams) SetVersionForAll

func (m *MockParams) SetVersionForAll(version uint32)

type RequestHandler

type RequestHandler struct {
	// contains filtered or unexported fields
}

func NewRequestHandler

func NewRequestHandler(conf *SSConfig) *RequestHandler

func (*RequestHandler) Finish

func (rh *RequestHandler) Finish()

func (*RequestHandler) GetReqCtxCreator

func (rh *RequestHandler) GetReqCtxCreator() io.InboundRequestContextCreator

func (*RequestHandler) Init

func (rh *RequestHandler) Init()

func (*RequestHandler) OnKeepAlive

func (rh *RequestHandler) OnKeepAlive(connector *io.Connector, reqCtx io.IRequestContext) (err error)

func (*RequestHandler) Process

func (rh *RequestHandler) Process(reqCtx io.IRequestContext) error

func (*RequestHandler) ReadAndProcessRequest

func (rh *RequestHandler) ReadAndProcessRequest(magic []byte, c *io.Connector) error

type SSConfig

type SSConfig struct {
	service.Config
	MeanDelay   int
	StdDevDelay int
	ValueSize   int
	StdDevSize  int
	Inbound     io.InboundConfig
	LogLevel    string
}
var (
	DefaultSSConfig SSConfig = SSConfig{
		MeanDelay:   0,
		StdDevDelay: 0,
		ValueSize:   1024,
		StdDevSize:  100,
		Inbound: io.InboundConfig{
			IdleTimeout:    util.Duration{math.MaxUint32 * time.Second},
			ReadTimeout:    util.Duration{math.MaxUint32 * time.Millisecond},
			WriteTimeout:   util.Duration{math.MaxUint32 * time.Millisecond},
			RequestTimeout: util.Duration{600 * time.Millisecond},
		},
		LogLevel: "warning",
	}
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL