Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the implementation to pre-generate the data required for testing #22

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading