diff --git a/bench/cmd/bench/bench.go b/bench/cmd/bench/bench.go index 71da66862..3eeb9a706 100644 --- a/bench/cmd/bench/bench.go +++ b/bench/cmd/bench/bench.go @@ -326,6 +326,7 @@ var run = cli.Command{ numResolves := benchscore.GetByTag(benchscore.DNSResolve) numDNSFailed := benchscore.GetByTag(benchscore.DNSFailed) msgs = append(msgs, fmt.Sprintf("名前解決成功数 %d", numResolves)) + lgr.Infof("DNSAttacker並列数: %d", benchmarker.attackParallelis) lgr.Infof("名前解決成功数: %d", numResolves) lgr.Infof("名前解決失敗数: %d", numDNSFailed) diff --git a/bench/cmd/bench/benchmarker.go b/bench/cmd/bench/benchmarker.go index 0b0808df4..c0e9d1a7a 100644 --- a/bench/cmd/bench/benchmarker.go +++ b/bench/cmd/bench/benchmarker.go @@ -236,23 +236,25 @@ func (b *benchmarker) loadAttack(ctx context.Context, asize int64, httpClient *h return nil } +var prevNumResolved = int64(0) + func (b *benchmarker) loadAttackCoordinator(ctx context.Context) { - ticker := time.NewTicker(1 * time.Second) + ticker := time.NewTicker(2 * time.Second) defer ticker.Stop() loop: for { select { case <-ticker.C: failRate := float64(benchscore.NumDNSFailed()) / float64(benchscore.NumResolves()+benchscore.NumDNSFailed()+1) - if failRate < 0.01 { - now := time.Now() - d := now.Sub(b.startAt) / time.Second - new := int(2.0 * (1.0 + float64(d)/8.0)) - if new > 16 { - new = 16 + avg := float64(benchscore.NumResolves()-prevNumResolved) / 2.0 + prevNumResolved = benchscore.NumResolves() + if failRate < 0.01 && avg/float64(b.attackParallelis) > 50.0 { + new := int(float64(b.attackParallelis) * 1.5) + if new > 15 { + new = 15 } if new != b.attackParallelis { - b.contestantLogger.Info("DNS水責め負荷が上昇します") + b.contestantLogger.Info("DNS水責め負荷が上昇します", zap.Int("parallelis", new)) b.attackParallelis = new } } @@ -354,8 +356,7 @@ func (b *benchmarker) run(ctx context.Context) error { violateCh := make(chan error) // とめておく bencherror.RunViolationChecker(ctx) loadAttackHTTPClient := b.loadAttackHTTPClient() - // FIXME: LIMITは負荷をみて調整したい - loadAttackLimiter := rate.NewLimiter(rate.Limit(1500), 1) + loadAttackLimiter := rate.NewLimiter(rate.Limit(3000), 1) go func() { b.loadAttackCoordinator(ctx) }() for { diff --git a/bench/scenario/core_pretest_normal.go b/bench/scenario/core_pretest_normal.go index eadb36fa6..6520c13e9 100644 --- a/bench/scenario/core_pretest_normal.go +++ b/bench/scenario/core_pretest_normal.go @@ -148,6 +148,15 @@ func NormalLivestreamPretest(ctx context.Context, contestantLogger *zap.Logger, return err } + clientNoSession, err := isupipe.NewCustomResolverClient( + contestantLogger, + dnsResolver, + agent.WithTimeout(config.PretestTimeout), + ) + if err != nil { + return err + } + if err := client.Login(ctx, &isupipe.LoginRequest{ Username: testUser.Name, Password: defaultPasswordOrPretest(testUser.Name), @@ -192,6 +201,20 @@ func NormalLivestreamPretest(ctx context.Context, contestantLogger *zap.Logger, } } + { + tagr, err := clientNoSession.GetTags(ctx) + if err != nil { + return err + } + tagn := map[int64]string{} + for _, tag := range tagr.Tags { + tagn[tag.ID] = tag.Name + } + if !reflect.DeepEqual(tagn, poolTags) { + return fmt.Errorf("取得した tag 一覧が正しくありません。過不足があります") + } + } + tags := []int64{1, 103} for len(tags) <= 10 { t := rand.Intn(len(tagResponse.Tags)) @@ -322,7 +345,7 @@ func NormalLivestreamPretest(ctx context.Context, contestantLogger *zap.Logger, { //検索2回目 - searchedStream, err := client.SearchLivestreams(ctx, isupipe.WithSearchTagQueryParam("ライブ配信")) // ID:1 + searchedStream, err := clientNoSession.SearchLivestreams(ctx, isupipe.WithSearchTagQueryParam("ライブ配信")) // ID:1 if err != nil { return err } @@ -410,6 +433,22 @@ func NormalLivestreamPretest(ctx context.Context, contestantLogger *zap.Logger, return fmt.Errorf("タグ指定なし検索結果の%d番目のlivestream.idが一致しません (expected:%d actual:%d)", randNumber+1, reserveStreams[randNumber], searchedStream[randNumber].ID) } } + } + { + // タグ指定なし検索 + searchedStream, err := clientNoSession.SearchLivestreams(ctx, isupipe.WithLimitQueryParam(config.NumSearchLivestreams)) + if err != nil { + return err + } + if len(searchedStream) != config.NumSearchLivestreams { + return fmt.Errorf("タグ指定なし検索結果の数が想定外です (expected:%d actual:%d)", config.NumSearchLivestreams, len(searchedStream)) + } + for i := 0; i < 5; i++ { + randNumber := rand.Intn(20) + if searchedStream[randNumber].ID != reserveStreams[randNumber] { + return fmt.Errorf("タグ指定なし検索結果の%d番目のlivestream.idが一致しません (expected:%d actual:%d)", randNumber+1, reserveStreams[randNumber], searchedStream[randNumber].ID) + } + } for i := 0; i < 5; i++ { randNumber := rand.Intn(20) + 25 livestreamID := int64(scheduler.GetLivestreamLength() + len(reserveStreams) - randNumber)