Skip to content

Commit

Permalink
Merge pull request #412 from isucon/bench-finalcheck
Browse files Browse the repository at this point in the history
searchlivestreams on final check
  • Loading branch information
kazeburo authored Nov 25, 2023
2 parents 3dccd96 + 28c762f commit 00bcd34
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
9 changes: 4 additions & 5 deletions bench/cmd/bench/supervise.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,10 @@ var supervise = cli.Command{
NotifyWorkerErr(job, err, "", "", "ベンチマーカーの結果送信に失敗。すぐに調査してください。supervisorの処理は継続します")
}

_ = finalcheckBucketName
// log.Println("upload finalcheck result")
// if err := UploadFinalcheckResult(finalcheckBucketName, job.ID, job.Team); err != nil {
// NotifyWorkerErr(job, err, "", "", "FinalCheckの結果送信に失敗。すぐに調査してください。supervisorの処理は継続します")
// }
log.Println("upload finalcheck result")
if err := UploadFinalcheckResult(finalcheckBucketName, job.ID, job.Team); err != nil {
NotifyWorkerErr(job, err, "", "", "FinalCheckの結果送信に失敗。すぐに調査してください。supervisorの処理は継続します")
}

log.Println("cleanup old logs for next job")
os.Remove(config.StaffLogPath)
Expand Down
36 changes: 33 additions & 3 deletions bench/scenario/core_finalcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package scenario

import (
"context"
"encoding/json"
"os"
"time"

"github.com/isucon/isucandar/agent"
"github.com/isucon/isucon13/bench/internal/config"
Expand All @@ -13,6 +15,17 @@ import (

func FinalcheckScenario(ctx context.Context, contestantLogger *zap.Logger, dnsResolver *resolver.DNSResolver) error {

// 3秒待つ
loop:
for {
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(3 * time.Second):
break loop
}
}

client, err := isupipe.NewCustomResolverClient(
contestantLogger,
dnsResolver,
Expand All @@ -21,11 +34,28 @@ func FinalcheckScenario(ctx context.Context, contestantLogger *zap.Logger, dnsRe
if err != nil {
return err
}
// タグ指定なし検索
searchedStream, err := client.SearchLivestreams(ctx, isupipe.WithLimitQueryParam(config.NumSearchLivestreams))
if err != nil {
return err
}
lgr := zap.S()
ids := []int64{}
for _, stream := range searchedStream {
ids = append(ids, stream.ID)
}
b, err := json.Marshal(ids)
if err != nil {
return err
}
lgr.Info("Finalcheck SearchLivestreams IDs:", string(b))

// FIXME: ライブコメント存在チェック
_ = client
b2, err := json.Marshal(searchedStream)
if err != nil {
return err
}

if err := os.WriteFile(config.FinalcheckPath, []byte("{}"), os.ModePerm); err != nil {
if err := os.WriteFile(config.FinalcheckPath, b2, os.ModePerm); err != nil {
return err
}

Expand Down

0 comments on commit 00bcd34

Please sign in to comment.