Skip to content
Draft
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
25 changes: 19 additions & 6 deletions generator/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,25 @@ func CurrentTimeMicros() int64 {
func GenerateDocs(batchSize int, destination, identifier string, idMode string) ([]interface{}, error) {
var docs = make([]interface{}, batchSize, batchSize)

for i := 0; i < batchSize; i++ {
doc, err := GenerateDoc(destination, identifier, idMode)
if err != nil {
return nil, err
}
docs[i] = doc
i := 0
for i < batchSize {
// Choose between 10 and 20 documents to have the same field value
numSameField := rand.Intn(11) + 10
// Use uuid so that different kubernetes replicas won't generate the same values
claimedBy := guuid.New().String()
for j := 0; j < numSameField; j++ {
doc, err := GenerateDoc(destination, identifier, idMode)
if err != nil {
return nil, err
}
doc.(map[string]interface{})["claimedBy"] = claimedBy
docs[i] = doc
i++
// Break early once we reach the batch size
if (i >= batchSize) {
break
}
}
}

return docs, nil
Expand Down