replayed

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReqStatusIgnored    = "ignored..."
	ReqStatusNotMatched = "not matched..."
	ReqStatusMissed     = "missed..."

	LogStatusRepeated = "match repeated"
	LogStatusMissed   = "match missed"
)

Variables

View Source
var (
	// standard error type
	HasDiffErr          = errors.New("Has Diff")
	HasDiffButIgnoreErr = errors.New("Has Diff but ignore")

	// user-defined error type
	EmptyJsonErr              = errors.New("empty json obj")
	EmptyBodyErr              = errors.New("empty test request or response")
	PublicLogFormatErr        = errors.New("malformed public log")
	PublicLogNotDefinedErr    = errors.New("log path not defined")
	PublicLogKeyNotDefinedErr = errors.New("key not defined")
	PublicLogPathErr          = errors.New("logpath not set")
)

Functions

func BinaryDiff

func BinaryDiff(a, b []byte) ([]byte, error)

十六进制后diff整合

func Judge

func Judge(diffs []*DiffRecord) bool

func ParseGzip

func ParseGzip(ctx context.Context, data []byte) ([]byte, error)

ParseGzip 解析gzip数据

func QDEFormat

func QDEFormat(sid string, isSuccess bool, diffs []*DiffRecord) interface{}

func ToBinary

func ToBinary(text []byte) ([]byte, error)

十六进制转换

func UnzipHttpRepsonse

func UnzipHttpRepsonse(ctx context.Context, data []byte) []byte

UnzipHttpRepsonse 尝试解压gzip数据,忽略失败

Types

type CommonItem

type CommonItem struct {
	Project string `json:"project"`
	Request string `json:"request"`
}

type Composer

type Composer struct {
	// guard MatchedIndex
	sync.RWMutex
	// control workflow
	sync.WaitGroup

	Project      string
	RequestMark  string
	NoiseInfo    map[string]nuwaplt.NoiseInfo
	MatchedIndex map[int]bool
	PublogCnt    map[string]int

	Sess *Session
}

func (*Composer) DiffAppendFile

func (c *Composer) DiffAppendFile(ctx context.Context, ajaxs []*DiffRecord, cnt int) []*DiffRecord

func (*Composer) DiffInbound

func (c *Composer) DiffInbound(ctx context.Context, ajaxs []*DiffRecord)

func (*Composer) DiffOther

func (c *Composer) DiffOther(ctx context.Context, ajaxs []*DiffRecord, cnt int) []*DiffRecord

func (*Composer) DiffOutbounds

func (c *Composer) DiffOutbounds(ctx context.Context, ajaxs []*DiffRecord, cnt int)

func (*Composer) GetMatchedIndex

func (c *Composer) GetMatchedIndex(id int) bool

func (*Composer) SetMatchedIndex

func (c *Composer) SetMatchedIndex(id int)

type Diff

type Diff struct {
	A, B                       string
	Noise                      map[string]nuwaplt.NoiseInfo
	CallFromInboundRequestMark string
}

func (*Diff) CompareProtocol

func (d *Diff) CompareProtocol() (compared []*FormatDiff, requestMark string, err error, protocal string)

解析协议并对比,通过打平数组diff

func (*Diff) ParseProtocol

func (d *Diff) ParseProtocol(body string) (map[string]json.RawMessage, string, error, string)

type DiffItem

type DiffItem struct {
	SubRequest string     `json:"sub_request"`
	Pairs      []PairItem `json:"pairs"`
}

type DiffRecord

type DiffRecord struct {
	Id              int           `json:"id"`
	Project         string        `json:"project"`
	RequestMark     string        `json:"requestMark"`
	Noise           string        `json:"noise"`
	Diff            string        `json:"diff"`
	FormatDiff      []*FormatDiff `json:"formatDiff"`
	OnlineReq       string        `json:"onlineReq"`
	BinaryOnlineReq string        `json:"binaryOnlineReq"`
	TestReq         string        `json:"testReq"`
	BinaryTestReq   string        `json:"binaryTestReq"`
	OnlineRes       string        `json:"onlineRes"`
	BinaryOnlineRes string        `json:"binaryOnlineRes"`
	TestRes         string        `json:"testRes"`
	BinaryTestRes   string        `json:"binaryTestRes"`
	MockedRes       string        `json:"mockedRes"`
	BinaryMockedRes string        `json:"binaryMockedRes"`
	IsDiff          int           `json:"isDiff"`
	Protocol        string        `json:"protocol"`
	ScorePercentage string        `json:"scorePercentage"`
	NoWebDisplay    bool          `json:"noWebDisplay"`
	MatchedIndex    int           `json:"matchedIndex"`
}

func DiffReplayed

func DiffReplayed(ctx context.Context, sess *Session, project string) []*DiffRecord

*

  • 回放结果进行diff、binary、missing、extend转换 *
  • @Return

type FailedItem

type FailedItem struct {
	CommonItem
	SessionId string     `json:"session_id"`
	Url       string     `json:"url"`
	Diffs     []DiffItem `json:"diff"`
}

type FormatDiff

type FormatDiff struct {
	Key      string                    `json:"label"`
	Children [2]map[string]interface{} `json:"children"`
	Is       int                       `json:"is"`
	NoiseId  int                       `json:"noiseId"`
	NoiseUri string                    `json:"noiseUri"`
	Noise    string                    `json:"noiseData"`
	Project  string                    `json:"noiseProject"`
}

type PairItem

type PairItem struct {
	Key    string `json:"key"`
	Online string `json:"online"`
	Test   string `json:"test"`
}

type Session

type Session struct {
	SessionId         string
	Context           string
	Request           []byte
	OnlineResponse    []byte
	TestResponse      []byte
	Outbounds         []*replaying.CallOutbound
	OnlineOutbounds   []*recording.CallOutbound
	OnlineAppendFiles []*recording.AppendFile
}

type SuccessItem

type SuccessItem struct {
	CommonItem
	SubRequests []string `json:"sub_request"`
}

Jump to

Keyboard shortcuts

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