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(utils): generate time values in the correct range #389

Merged
merged 1 commit into from
Jul 12, 2023
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
9 changes: 5 additions & 4 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ func RandDate(rnd *rand.Rand) time.Time {
return time.Unix(rnd.Int63n(1<<63-2), rnd.Int63n(999999999)).UTC()
}

// RandTime generates time in string representation
// it is done in such way because we wanted to make JSON statement to work
// but scylla supports only string representation of time in JSON format
// According to the CQL binary protocol, time is an int64 in range [0;86399999999999]
// https://github.com/apache/cassandra/blob/f5df4b219e063cb24b9cc0c22b6e614506b8d903/doc/native_protocol_v4.spec#L941
// An 8 byte two's complement long representing nanoseconds since midnight.
// Valid values are in the range 0 to 86399999999999
func RandTime(rnd *rand.Rand) int64 {
return rnd.Int63()
return rnd.Int63n(86400000000000)
}

func RandIPV4Address(rnd *rand.Rand, v, pos int) string {
Expand Down