Skip to content

Commit

Permalink
Merge pull request #22 from naver/fix-loggen-test
Browse files Browse the repository at this point in the history
fix the implementation to pre-generate the data required for testing
  • Loading branch information
sharkpc138 authored Dec 12, 2024
2 parents d0df58b + b10cb39 commit de0af31
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions pkg/loggen/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,26 @@ type Stub interface {

func generateLogs(logger *log.Logger, conf Config, stopChan chan struct{}, logFormatter func(string) string) {
ticker := time.NewTicker(*conf.LogGenerationInterval)
number := uint(0)
index := uint(0)
logSequences := []string{}

for i := 0; i < 10; i++ {
var str strings.Builder

for str.Len() < *conf.LogSize {
str.WriteString(fmt.Sprintf("%d", i))
}

logSequences = append(logSequences, logFormatter(str.String()))
}

for {
select {
case <-ticker.C:
var str strings.Builder
index = (index + 1) % 10

number = (number + 1) % 10
for str.Len() < *conf.LogSize {
str.WriteString(fmt.Sprintf("%d", number))
}
for i := 0; i < *conf.LogLines; i++ {
logger.Print(logFormatter(str.String()))
logger.Print(logSequences[index])
}

case <-stopChan:
Expand Down

0 comments on commit de0af31

Please sign in to comment.