Skip to content

feat(execute): test support duration for agg window #3177

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

Merged
merged 1 commit into from
Sep 3, 2020

Conversation

fchikwekwe
Copy link
Contributor

Closes #3025.

Adding testing to ensure that windows using monthly durations set bounds properly.

Done checklist

  • Test cases written
Siteproxy
Comment on lines 118 to 127
name: "simple months",
w: MustWindow(
values.ConvertDurationMonths(5),
values.ConvertDurationMonths(5),
values.ConvertDurationMonths(0)),
t: values.ConvertTime(time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)),
want: execute.Bounds{
Start: values.ConvertTime(time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)),
Stop: values.ConvertTime(time.Date(1970, time.June, 1, 0, 0, 0, 0, time.UTC)),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great test case. What bounds does it output for a time that is before Jan 1, 1970? Can you add that test case too?

Copy link
Contributor Author

@fchikwekwe fchikwekwe Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I updated the offset test to test this.

Comment on lines 136 to 139
want: execute.Bounds{
Start: values.ConvertTime(time.Date(1970, time.January, 2, 4, 30, 0, 0, time.UTC)),
Stop: values.ConvertTime(time.Date(1970, time.June, 2, 4, 30, 0, 0, time.UTC)),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why it outputs these bounds? Maybe I don't understand how monthly offsets work, but I would have expected a window with period equal to offset to be the same as a window with that same period and no offset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, sorry I thought I fixed that. Should be fixed now.

Comment on lines +412 to +425
func MustWindow(every, period, offset execute.Duration, months bool) execute.Window {
w, err := execute.NewWindow(every, period, offset, months)
Copy link
Contributor Author

@fchikwekwe fchikwekwe Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlapacik the fix for that bug you saw requires adding awareness of nanoseconds vs months when creating the window.

Comment on lines +21 to +25
func NewWindow(every, period, offset Duration, months bool) (Window, error) {
if !months {
// Normalize nanosecond offsets to a small positive duration
offset = offset.Normalize(every)
}
Copy link
Contributor Author

@fchikwekwe fchikwekwe Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlapacik we need to know if we're working with nanoseconds or not so that we can know whether to scale durations here or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see so it wasn't a bug in GetEarliestBounds? Just in how we were creating the window in the first place? Is it possible to add that test case back in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can add another case that's similar to the initial one.

@codecov-commenter
Copy link

codecov-commenter commented Sep 3, 2020

Codecov Report

Merging #3177 into master will decrease coverage by 0.02%.
The diff coverage is 48.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3177      +/-   ##
==========================================
- Coverage   50.40%   50.38%   -0.03%     
==========================================
  Files         337      337              
  Lines       41237    41246       +9     
==========================================
- Hits        20786    20782       -4     
- Misses      17989    18003      +14     
+ Partials     2462     2461       -1     
Impacted Files Coverage Δ
execute/bounds.go 32.25% <0.00%> (ø)
stdlib/universe/window.go 53.54% <0.00%> (-0.20%) ⬇️
time.go 76.92% <0.00%> (ø)
values/time.go 77.99% <18.18%> (-2.17%) ⬇️
stdlib/date/date.go 48.89% <50.00%> (ø)
execute/window.go 93.44% <100.00%> (+0.10%) ⬆️
internal/gen/input.go 54.32% <100.00%> (ø)
stdlib/experimental/http/http_experimental.go 70.42% <100.00%> (ø)
stdlib/universe/typeconv.go 44.58% <100.00%> (ø)
values/binary.go 91.29% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fdaccd9...fcd36a2. Read the comment docs.

Comment on lines +142 to +151
name: "months with equivalent offset",
w: MustWindow(
values.ConvertDurationMonths(5),
values.ConvertDurationMonths(5),
values.ConvertDurationMonths(5), true),
t: values.ConvertTime(time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)),
want: execute.Bounds{
Start: values.ConvertTime(time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)),
Stop: values.ConvertTime(time.Date(1970, time.June, 1, 0, 0, 0, 0, time.UTC)),
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlapacik here's that original test case.

@fchikwekwe fchikwekwe merged commit 5e15be6 into master Sep 3, 2020
@fchikwekwe fchikwekwe deleted the feat/window-dur branch September 3, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make window logic reusable
3 participants