github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/pkg/loadtest/scenario.go (about) 1 package loadtest 2 3 import ( 4 "fmt" 5 6 vegeta "github.com/tsenart/vegeta/v12/lib" 7 ) 8 9 const FileCountInCommit = 20 10 11 type Scenario interface { 12 Play(loader Loader, stopCh chan struct{}) <-chan vegeta.Target 13 } 14 15 type SimpleScenario struct { 16 FileCountInCommit int 17 } 18 19 func (s *SimpleScenario) Play(serverAddress string, repoName string, stopCh chan struct{}) <-chan vegeta.Target { 20 targetGenerator := TargetGenerator{ServerAddress: serverAddress} 21 out := make(chan vegeta.Target) 22 go func() { 23 defer close(out) 24 for i := 0; true; i++ { 25 for _, tgt := range targetGenerator.GenerateCreateFileTargets(repoName, "main", FileCountInCommit) { 26 out <- tgt 27 } 28 commitMsg := fmt.Sprintf("commit%d", i) 29 out <- targetGenerator.GenerateCommitTarget(repoName, "main", commitMsg) 30 branchName := fmt.Sprintf("branch%d", i) 31 out <- targetGenerator.GenerateBranchTarget(repoName, branchName) 32 33 for _, tgt := range targetGenerator.GenerateCreateFileTargets(repoName, branchName, FileCountInCommit) { 34 out <- tgt 35 } 36 out <- targetGenerator.GenerateCommitTarget(repoName, branchName, commitMsg) 37 out <- targetGenerator.GenerateMergeToMasterTarget(repoName, branchName) 38 out <- targetGenerator.GenerateListTarget(repoName, "main", 100) //nolint: mnd 39 out <- targetGenerator.GenerateListTarget(repoName, "main", 1000) //nolint: mnd 40 out <- targetGenerator.GenerateDiffTarget(repoName, "main") 41 42 select { 43 case <-stopCh: 44 return 45 default: 46 } 47 } 48 }() 49 return out 50 }