scenario

package
v0.0.0-...-1011682 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 39 Imported by: 1

Documentation

Overview

Code generated by gen/assets.go; DO NOT EDIT.

Index

Constants

View Source
const (
	// MEMO: 最大でも60秒に一件しか送れないので点数上限になるが、解決できるとは思えないので良い
	PostIntervalSecond     = 60 //Virtual Timeでのpost間隔
	PostIntervalBlurSecond = 5  //Virtual Timeでのpost間隔のブレ幅(+-PostIntervalBlurSecond)
	PostContentNum         = 10 //一回のpostで何要素postするか virtualTimeMulti * timerDuration(20ms) / PostIntervalSecond

)
View Source
const (
	ScoreStartBenchmark        score.ScoreTag = "00.StartBenchmark       "
	ScoreGraphGood             score.ScoreTag = "01.GraphGood            "
	ScoreGraphNormal           score.ScoreTag = "02.GraphNormal          "
	ScoreGraphBad              score.ScoreTag = "03.GraphBad             "
	ScoreGraphWorst            score.ScoreTag = "04.GraphWorst           "
	ScoreTodayGraphGood        score.ScoreTag = "05.TodayGraphGood       "
	ScoreTodayGraphNormal      score.ScoreTag = "06.TodayGraphNormal     "
	ScoreTodayGraphBad         score.ScoreTag = "07.TodayGraphBad        "
	ScoreTodayGraphWorst       score.ScoreTag = "08.TodayGraphWorst      "
	ScoreReadInfoCondition     score.ScoreTag = "09.ReadInfoCondition    "
	ScoreReadWarningCondition  score.ScoreTag = "10.ReadWarningCondition "
	ScoreReadCriticalCondition score.ScoreTag = "11.ReadCriticalCondition"
	ScoreIsuInitialize         score.ScoreTag = "_1.IsuInitialize        " //scoreが0のもの
	ScoreNormalUserInitialize  score.ScoreTag = "_2.NormalUserInitialize " //全てのIsuInitializeが終わってはじめて+1
	ScoreViewerInitialize      score.ScoreTag = "_3.ViewerInitialize     "
	ScoreViewerLoop            score.ScoreTag = "_4.ViewerLoop           "
	ScoreViewerDropout         score.ScoreTag = "_5.ViewerDropout        "
	ScoreRepairIsu             score.ScoreTag = "_6.RepairIsu            "
	ScorePostInfoCondition     score.ScoreTag = "_7.PostInfoCondition    "
	ScorePostWarningCondition  score.ScoreTag = "_8.PostWarningCondition "
	ScorePostCriticalCondition score.ScoreTag = "_9.PostCriticalCondition"
)
View Source
const AddUserCount = 1

User を増やすとき何人増やすか

View Source
const AddUserStep = 500

User を増やすかどうかの閾値

View Source
const ConditionDelayTime = 1

GET /api/isu/:id/graph と GET /api/condition/:id の間で許される condition 反映の遅延

View Source
const ConditionPagingStep = 1

GET /api/isu/:id/condition の

View Source
const IsuCountMax = 9

ユーザーがもってるISUの数の上限

View Source
const NotExistJiaIsuUUID = "9e5c1109-beff-4598-b8f1-658d1994d55f"
View Source
const OneDay = 24 * 60 * 60

一日の秒数

View Source
const ReadConditionTagStep = 50

ReadCondition/PostCondition 系のスコアタグが何件ごとに付与されるか

View Source
const SignoutPercentage = 20
View Source
const TimeoutLimitPerUser = 20

ユーザーが追加されるとき、発生していて良い Timeout のユーザー数に対する上限

View Source
const ViewerAddLoopStep = 1

1ユーザーのループが何回回れば Viewer が増えるか

View Source
const ViewerDropCount = 1

Viewer が何回以上エラーに遭遇したら drop するか

View Source
const ViewerLimitPerUser = 3

Viewer のユーザー数に対する上限

Variables

View Source
var (
	ErrCritical         failure.StringCode = "critical"
	ErrSecurityIncident failure.StringCode = "security incident"
)

Critical Errors

View Source
var (
	ErrChecksum           failure.StringCode = "check-sum"
	ErrInvalidStatusCode  failure.StringCode = "status code"
	ErrInvalidContentType failure.StringCode = "content type"
	ErrInvalidJSON        failure.StringCode = "json"
	ErrInvalidAsset       failure.StringCode = "asset"
	ErrMismatch           failure.StringCode = "mismatch"     //データはあるが、間違っている(名前が違う等)
	ErrInvalid            failure.StringCode = "invalid"      //ロジック的に誤り(存在しないはずのものが有る等)
	ErrBadResponse        failure.StringCode = "bad-response" //不正な書式のレスポンス
	ErrHTTP               failure.StringCode = "http"         //http通信回りのエラー(timeout含む)
)
View Source
var ScoreGraphTimestampCount = IScoreGraphTimestampCount{
	Good:   20,
	Normal: 10,
	Bad:    5,
	Worst:  0,
}

現状 virtualTimeMulti は 30000、で timeout は 5ms、より timeout の間隔で仮想時間では 1500s たっている。 PostConditionIntervalSecond が 60s なので timeout の時間に最高で 1500s / 60s = 25 個の condition が存在する しかし PostConditionNum が 10 なので backend がめちゃくちゃ早くレスポンスを返さないと、理論上存在する 25個の condition は 10個になり点数のソースを失う ScoreGraph で関心がある1時間の condition の timestamp の数については、理論値(60sに一件)は max60個、timeout はするが全件 insert するのは 24個

Functions

func AgentDo

func AgentDo(a *agent.Agent, ctx context.Context, req *http.Request) (*http.Response, error)

func AgentStaticDo

func AgentStaticDo(ctx context.Context, user AgentWithStaticCache, req *http.Request, cachePath string) (*http.Response, error)

User.StaticCachedHash を使って静的ファイルのキャッシュを更新する

func AssertEqual

func AssertEqual(msg string, expected interface{}, actual interface{}) bool

func BrowserAccess

func BrowserAccess(ctx context.Context, user AgentWithStaticCache, rpath string, page PageType) []error

func BrowserAccessIndexHtml

func BrowserAccessIndexHtml(ctx context.Context, user AgentWithStaticCache, rpath string) []error

func CheckError

func CheckError(err error) (critical bool, timeout bool, deduction bool)

func IsValidation

func IsValidation(err error) bool

func RegisterToJiaAPI

func RegisterToJiaAPI(isu *model.Isu, streams *model.StreamsForPoster)

シナリオ Goroutineからの呼び出し

func SetScoreTags

func SetScoreTags(scoreTable score.ScoreTable)

Types

type AgentWithStaticCache

type AgentWithStaticCache interface {
	SetStaticCache(path string, hash uint32)
	GetStaticCache(path string, req *http.Request) (uint32, bool)
	ClearStaticCache()

	GetAgent() *agent.Agent
}

type IScoreGraphTimestampCount

type IScoreGraphTimestampCount struct {
	Good   int
	Normal int
	Bad    int
	Worst  int
}

type IsuDetailInfomation

type IsuDetailInfomation struct {
	Character string `json:"character"`
}

type PageType

type PageType int
const (
	HomePage PageType = iota
	IsuDetailPage
	IsuConditionPage
	IsuGraphPage
	RegisterPage
	TrendPage
)

type ReadConditionCount

type ReadConditionCount struct {
	Info     int32
	Warn     int32
	Critical int32
}

type Scenario

type Scenario struct {
	BaseURL     string        // ベンチ対象 Web アプリの URL
	UseTLS      bool          // ベンチ対象 Web アプリが HTTPS で動いているかどうか (本番時ture/CI時false)
	NoLoad      bool          // Load(ベンチ負荷)を強要しない
	LoadTimeout time.Duration //Loadのcontextの時間

	// 競技者の実装言語
	Language string

	JiaPosterCancel context.CancelFunc
	// contains filtered or unexported fields
}

func NewScenario

func NewScenario(jiaServiceURL *url.URL, loadTimeout time.Duration) (*Scenario, error)

func (*Scenario) AddIsuconUser

func (s *Scenario) AddIsuconUser(ctx context.Context, step *isucandar.BenchmarkStep)

load 中に name が isucon なユーザーを特別に走らせるようにする

func (*Scenario) AddNormalUser

func (s *Scenario) AddNormalUser(ctx context.Context, step *isucandar.BenchmarkStep, count int)

load用 通常ユーザーのシナリオ Goroutineを追加する

func (*Scenario) AddViewer

func (s *Scenario) AddViewer(ctx context.Context, step *isucandar.BenchmarkStep, count int)

load用 非ログインユーザーのシナリオ Goroutineを追加する

func (*Scenario) GetFqdnFromIPAddr

func (s *Scenario) GetFqdnFromIPAddr(ipaddr string) (string, bool)

func (*Scenario) GetIPAddrFromFqdn

func (s *Scenario) GetIPAddrFromFqdn(fqdn string) (string, bool)

func (*Scenario) GetIsuFromID

func (s *Scenario) GetIsuFromID(id int) (*model.Isu, bool)

func (*Scenario) GetRandomActivatedIsu

func (s *Scenario) GetRandomActivatedIsu(randEngine *rand.Rand) *model.Isu

func (*Scenario) InitializeData

func (s *Scenario) InitializeData(ctx context.Context)

func (*Scenario) JiaAPIService

func (s *Scenario) JiaAPIService(ctx context.Context)

func (*Scenario) LenOfIsuFromId

func (s *Scenario) LenOfIsuFromId() int

func (*Scenario) Load

func (s *Scenario) Load(parent context.Context, step *isucandar.BenchmarkStep) error

func (*Scenario) NewAgent

func (s *Scenario) NewAgent(opts ...agent.AgentOption) (*agent.Agent, error)

func (*Scenario) NewIsu

func (s *Scenario) NewIsu(ctx context.Context, step *isucandar.BenchmarkStep, owner *model.User, addToUser bool, retry bool) *model.Isu

新しい登録済みISUの生成 失敗したらnilを返す

func (*Scenario) NewIsuWithCustomImg

func (s *Scenario) NewIsuWithCustomImg(ctx context.Context, step *isucandar.BenchmarkStep, owner *model.User, addToUser bool, img []byte, retry bool) *model.Isu

新しい登録済みISUの生成 失敗したらnilを返す

func (*Scenario) NewUser

func (s *Scenario) NewUser(ctx context.Context, step *isucandar.BenchmarkStep, a *agent.Agent, userType model.UserType, isIsuconUser bool) *model.User

新しい登録済みUserの生成 失敗したらnilを返す

func (*Scenario) Prepare

func (s *Scenario) Prepare(ctx context.Context, step *isucandar.BenchmarkStep) error

func (*Scenario) SetIPAddrAndFqdn

func (s *Scenario) SetIPAddrAndFqdn(str ...string) error

map に対する Setter は main でしか呼ばれないため lock は取らない

func (*Scenario) ToVirtualTime

func (s *Scenario) ToVirtualTime(realTime time.Time) time.Time

func (*Scenario) UpdateIsuFromID

func (s *Scenario) UpdateIsuFromID(isu *model.Isu)

func (*Scenario) WithInitializeTimeout

func (s *Scenario) WithInitializeTimeout(t time.Duration) *Scenario

type TrendHash

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

Jump to

Keyboard shortcuts

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