You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/04/13 21:48:58 UTC

[GitHub] [beam] jrmccluskey opened a new pull request, #17370: [BEAM-14306] Add unit testing to pane coder

jrmccluskey opened a new pull request, #17370:
URL: https://github.com/apache/beam/pull/17370

   Adds unit testing to pane coder and makes tweaks to match the spec described in the runner api (https://github.com/apache/beam/blob/master/model/pipeline/src/main/proto/org/apache/beam/model/pipeline/v1/beam_runner_api.proto#L922)
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] riteshghorse commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
riteshghorse commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1102642757

   Small nits but everything else looks good. Thanks for catching the error in coding!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1098545443

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @youngoli for label go.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] riteshghorse commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
riteshghorse commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1102673504

   R: @lostluck 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1099474388

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1098519730

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lostluck commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
lostluck commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1105871922

   The only thing I can think of to improve things is to include hard coded values for the encoded/decoded panes,  (eg the "no firing pane" is `0xf`) etc, so we aren't relying on the round trip for correctness.  (eg. If I say A(B(0)) = 0, all that says is A and B are inverses, but not what they do.)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] jrmccluskey commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
jrmccluskey commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1098545158

   I'm planning on adding test case names to the structs and routing everything through t.Run() before merging, but that will be left for tomorrow


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] codecov[bot] commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1098521214

   # [Codecov](https://codecov.io/gh/apache/beam/pull/17370?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#17370](https://codecov.io/gh/apache/beam/pull/17370?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2877f88) into [master](https://codecov.io/gh/apache/beam/commit/1d3d43b56a0a64e982474f7f6ce871e96a2b99aa?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1d3d43b) will **increase** coverage by `0.06%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #17370      +/-   ##
   ==========================================
   + Coverage   74.00%   74.07%   +0.06%     
   ==========================================
     Files         685      685              
     Lines       89720    89723       +3     
   ==========================================
   + Hits        66393    66458      +65     
   + Misses      22167    22100      -67     
   - Partials     1160     1165       +5     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | go | `50.02% <100.00%> (+0.24%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/17370?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [sdks/go/pkg/beam/core/graph/coder/panes.go](https://codecov.io/gh/apache/beam/pull/17370/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9nby9wa2cvYmVhbS9jb3JlL2dyYXBoL2NvZGVyL3BhbmVzLmdv) | `81.25% <100.00%> (+81.25%)` | :arrow_up: |
   | [sdks/go/pkg/beam/core/runtime/xlangx/registry.go](https://codecov.io/gh/apache/beam/pull/17370/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9nby9wa2cvYmVhbS9jb3JlL3J1bnRpbWUveGxhbmd4L3JlZ2lzdHJ5Lmdv) | `47.32% <0.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/17370?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/17370?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [1d3d43b...2877f88](https://codecov.io/gh/apache/beam/pull/17370?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lostluck merged pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
lostluck merged PR #17370:
URL: https://github.com/apache/beam/pull/17370


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1098519728

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] riteshghorse commented on a diff in pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
riteshghorse commented on code in PR #17370:
URL: https://github.com/apache/beam/pull/17370#discussion_r853068133


##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false

Review Comment:
   This should be set as true?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1098519718

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] jrmccluskey commented on pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
jrmccluskey commented on PR #17370:
URL: https://github.com/apache/beam/pull/17370#issuecomment-1099473602

   R: @riteshghorse 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] riteshghorse commented on a diff in pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
riteshghorse commented on code in PR #17370:
URL: https://github.com/apache/beam/pull/17370#discussion_r853056352


##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false

Review Comment:
   This should be set as true?



##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false
 	}
-	if b&0x02 == 2 {
-		pn.IsLast = true
+	if !(b&0x01 == 1) {
+		pn.IsLast = false

Review Comment:
   This should be set as true?



##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false
 	}
-	if b&0x02 == 2 {
-		pn.IsLast = true
+	if !(b&0x01 == 1) {
+		pn.IsLast = false

Review Comment:
   This should be set as true?



##########
sdks/go/pkg/beam/core/graph/coder/panes_test.go:
##########
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package coder
+
+import (
+	"bytes"
+	"math"
+	"testing"
+
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/core/typex"
+)
+
+func makePaneInfo(timing typex.PaneTiming, first, last bool, index, nsIndex int64) typex.PaneInfo {
+	return typex.PaneInfo{Timing: timing, IsFirst: first, IsLast: last, Index: index, NonSpeculativeIndex: nsIndex}
+}
+
+func equalPanes(left, right typex.PaneInfo) bool {
+	return (left.Timing == right.Timing) && (left.IsFirst == right.IsFirst) && (left.IsLast == right.IsLast) && (left.Index == right.Index) && (left.NonSpeculativeIndex == right.NonSpeculativeIndex)
+}
+
+func TestPaneCoder(t *testing.T) {
+	tests := []struct {
+		name    string
+		timing  typex.PaneTiming
+		first   bool
+		last    bool
+		index   int64
+		nsIndex int64
+	}{
+		{
+			"false bools",
+			typex.PaneUnknown,
+			false,
+			false,
+			0,
+			0,
+		},
+		{
+			"true bools",
+			typex.PaneUnknown,
+			true,
+			true,
+			0,
+			0,
+		},
+		{
+			"first pane",
+			typex.PaneUnknown,
+			true,
+			false,
+			0,
+			0,
+		},
+		{
+			"last pane",
+			typex.PaneUnknown,
+			false,
+			true,
+			0,
+			0,
+		},
+		{
+			"on time, different index and non-speculative",
+			typex.PaneOnTime,
+			false,
+			false,
+			1,
+			2,
+		},
+		{
+			"valid early pane",
+			typex.PaneEarly,
+			true,
+			false,
+			math.MaxInt64,
+			-1,
+		},
+		{
+			"on time, max non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MaxInt64,
+		},
+		{
+			"late pane, max index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MaxInt64,
+			0,
+		},
+		{
+			"on time, min non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MinInt64,
+		},
+		{
+			"late, min index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MinInt64,
+			0,
+		},
+	}
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			input := makePaneInfo(test.timing, test.first, test.last, test.index, test.nsIndex)
+			var buf bytes.Buffer
+			err := EncodePane(input, &buf)
+			if err != nil {
+				t.Fatalf("failed to encode pane %v, got %v", input, err)
+			}
+			got, err := DecodePane(&buf)
+			if err != nil {
+				t.Fatalf("failed to decode pane from buffer %v, got %v", buf, err)
+			}
+			if want := input; !equalPanes(got, want) {
+				t.Errorf("got pane %v, want %v", got, want)
+			}
+		})
+	}
+}
+func TestEncodePane_bad(t *testing.T) {

Review Comment:
   add empty line



##########
sdks/go/pkg/beam/core/graph/coder/panes_test.go:
##########
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package coder
+
+import (
+	"bytes"
+	"math"
+	"testing"
+
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/core/typex"
+)
+
+func makePaneInfo(timing typex.PaneTiming, first, last bool, index, nsIndex int64) typex.PaneInfo {
+	return typex.PaneInfo{Timing: timing, IsFirst: first, IsLast: last, Index: index, NonSpeculativeIndex: nsIndex}
+}
+
+func equalPanes(left, right typex.PaneInfo) bool {
+	return (left.Timing == right.Timing) && (left.IsFirst == right.IsFirst) && (left.IsLast == right.IsLast) && (left.Index == right.Index) && (left.NonSpeculativeIndex == right.NonSpeculativeIndex)
+}
+
+func TestPaneCoder(t *testing.T) {
+	tests := []struct {
+		name    string
+		timing  typex.PaneTiming
+		first   bool
+		last    bool
+		index   int64
+		nsIndex int64
+	}{
+		{
+			"false bools",
+			typex.PaneUnknown,
+			false,
+			false,
+			0,
+			0,
+		},
+		{
+			"true bools",
+			typex.PaneUnknown,
+			true,
+			true,
+			0,
+			0,
+		},
+		{
+			"first pane",
+			typex.PaneUnknown,
+			true,
+			false,
+			0,
+			0,
+		},
+		{
+			"last pane",
+			typex.PaneUnknown,
+			false,
+			true,
+			0,
+			0,
+		},
+		{
+			"on time, different index and non-speculative",
+			typex.PaneOnTime,
+			false,
+			false,
+			1,
+			2,
+		},
+		{
+			"valid early pane",
+			typex.PaneEarly,
+			true,
+			false,
+			math.MaxInt64,
+			-1,
+		},
+		{
+			"on time, max non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MaxInt64,
+		},
+		{
+			"late pane, max index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MaxInt64,
+			0,
+		},
+		{
+			"on time, min non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MinInt64,
+		},
+		{
+			"late, min index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MinInt64,
+			0,
+		},
+	}
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			input := makePaneInfo(test.timing, test.first, test.last, test.index, test.nsIndex)
+			var buf bytes.Buffer
+			err := EncodePane(input, &buf)
+			if err != nil {
+				t.Fatalf("failed to encode pane %v, got %v", input, err)
+			}
+			got, err := DecodePane(&buf)
+			if err != nil {
+				t.Fatalf("failed to decode pane from buffer %v, got %v", buf, err)
+			}
+			if want := input; !equalPanes(got, want) {
+				t.Errorf("got pane %v, want %v", got, want)
+			}
+		})
+	}
+}
+func TestEncodePane_bad(t *testing.T) {

Review Comment:
   ```suggestion
   
   func TestEncodePane_bad(t *testing.T) {
   ```
   ```suggestion
   func TestEncodePane_bad(t *testing.T) {
   ```



##########
sdks/go/pkg/beam/core/graph/coder/panes_test.go:
##########
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package coder
+
+import (
+	"bytes"
+	"math"
+	"testing"
+
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/core/typex"
+)
+
+func makePaneInfo(timing typex.PaneTiming, first, last bool, index, nsIndex int64) typex.PaneInfo {
+	return typex.PaneInfo{Timing: timing, IsFirst: first, IsLast: last, Index: index, NonSpeculativeIndex: nsIndex}
+}
+
+func equalPanes(left, right typex.PaneInfo) bool {
+	return (left.Timing == right.Timing) && (left.IsFirst == right.IsFirst) && (left.IsLast == right.IsLast) && (left.Index == right.Index) && (left.NonSpeculativeIndex == right.NonSpeculativeIndex)
+}
+
+func TestPaneCoder(t *testing.T) {
+	tests := []struct {
+		name    string
+		timing  typex.PaneTiming
+		first   bool
+		last    bool
+		index   int64
+		nsIndex int64
+	}{
+		{
+			"false bools",
+			typex.PaneUnknown,
+			false,
+			false,
+			0,
+			0,
+		},
+		{
+			"true bools",
+			typex.PaneUnknown,
+			true,
+			true,
+			0,
+			0,
+		},
+		{
+			"first pane",
+			typex.PaneUnknown,
+			true,
+			false,
+			0,
+			0,
+		},
+		{
+			"last pane",
+			typex.PaneUnknown,
+			false,
+			true,
+			0,
+			0,
+		},
+		{
+			"on time, different index and non-speculative",
+			typex.PaneOnTime,
+			false,
+			false,
+			1,
+			2,
+		},
+		{
+			"valid early pane",
+			typex.PaneEarly,
+			true,
+			false,
+			math.MaxInt64,
+			-1,
+		},
+		{
+			"on time, max non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MaxInt64,
+		},
+		{
+			"late pane, max index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MaxInt64,
+			0,
+		},
+		{
+			"on time, min non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MinInt64,
+		},
+		{
+			"late, min index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MinInt64,
+			0,
+		},
+	}
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			input := makePaneInfo(test.timing, test.first, test.last, test.index, test.nsIndex)
+			var buf bytes.Buffer
+			err := EncodePane(input, &buf)
+			if err != nil {
+				t.Fatalf("failed to encode pane %v, got %v", input, err)
+			}
+			got, err := DecodePane(&buf)
+			if err != nil {
+				t.Fatalf("failed to decode pane from buffer %v, got %v", buf, err)
+			}
+			if want := input; !equalPanes(got, want) {
+				t.Errorf("got pane %v, want %v", got, want)
+			}
+		})
+	}
+}
+func TestEncodePane_bad(t *testing.T) {

Review Comment:
   ```suggestion
   
   func TestEncodePane_bad(t *testing.T) {
   ```
   ```suggestion
   func TestEncodePane_bad(t *testing.T) {
   ```



##########
sdks/go/pkg/beam/core/graph/coder/panes_test.go:
##########
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package coder
+
+import (
+	"bytes"
+	"math"
+	"testing"
+
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/core/typex"
+)
+
+func makePaneInfo(timing typex.PaneTiming, first, last bool, index, nsIndex int64) typex.PaneInfo {
+	return typex.PaneInfo{Timing: timing, IsFirst: first, IsLast: last, Index: index, NonSpeculativeIndex: nsIndex}
+}
+
+func equalPanes(left, right typex.PaneInfo) bool {
+	return (left.Timing == right.Timing) && (left.IsFirst == right.IsFirst) && (left.IsLast == right.IsLast) && (left.Index == right.Index) && (left.NonSpeculativeIndex == right.NonSpeculativeIndex)
+}
+
+func TestPaneCoder(t *testing.T) {
+	tests := []struct {
+		name    string
+		timing  typex.PaneTiming
+		first   bool
+		last    bool
+		index   int64
+		nsIndex int64
+	}{
+		{
+			"false bools",
+			typex.PaneUnknown,
+			false,
+			false,
+			0,
+			0,
+		},
+		{
+			"true bools",
+			typex.PaneUnknown,
+			true,
+			true,
+			0,
+			0,
+		},
+		{
+			"first pane",
+			typex.PaneUnknown,
+			true,
+			false,
+			0,
+			0,
+		},
+		{
+			"last pane",
+			typex.PaneUnknown,
+			false,
+			true,
+			0,
+			0,
+		},
+		{
+			"on time, different index and non-speculative",
+			typex.PaneOnTime,
+			false,
+			false,
+			1,
+			2,
+		},
+		{
+			"valid early pane",
+			typex.PaneEarly,
+			true,
+			false,
+			math.MaxInt64,
+			-1,
+		},
+		{
+			"on time, max non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MaxInt64,
+		},
+		{
+			"late pane, max index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MaxInt64,
+			0,
+		},
+		{
+			"on time, min non-speculative index",
+			typex.PaneOnTime,
+			false,
+			true,
+			0,
+			math.MinInt64,
+		},
+		{
+			"late, min index",
+			typex.PaneLate,
+			false,
+			false,
+			math.MinInt64,
+			0,
+		},
+	}
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			input := makePaneInfo(test.timing, test.first, test.last, test.index, test.nsIndex)
+			var buf bytes.Buffer
+			err := EncodePane(input, &buf)
+			if err != nil {
+				t.Fatalf("failed to encode pane %v, got %v", input, err)
+			}
+			got, err := DecodePane(&buf)
+			if err != nil {
+				t.Fatalf("failed to decode pane from buffer %v, got %v", buf, err)
+			}
+			if want := input; !equalPanes(got, want) {
+				t.Errorf("got pane %v, want %v", got, want)
+			}
+		})
+	}
+}
+func TestEncodePane_bad(t *testing.T) {

Review Comment:
   add empty line



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] riteshghorse commented on a diff in pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
riteshghorse commented on code in PR #17370:
URL: https://github.com/apache/beam/pull/17370#discussion_r853068133


##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false

Review Comment:
   This should be set as true?



##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false
 	}
-	if b&0x02 == 2 {
-		pn.IsLast = true
+	if !(b&0x01 == 1) {
+		pn.IsLast = false

Review Comment:
   This should be set as true?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] jrmccluskey commented on a diff in pull request #17370: [BEAM-14306] Add unit testing to pane coder

Posted by GitBox <gi...@apache.org>.
jrmccluskey commented on code in PR #17370:
URL: https://github.com/apache/beam/pull/17370#discussion_r853092756


##########
sdks/go/pkg/beam/core/graph/coder/panes.go:
##########
@@ -60,11 +64,11 @@ func EncodePane(v typex.PaneInfo, w io.Writer) error {
 func NewPane(b byte) typex.PaneInfo {
 	pn := typex.NoFiringPane()
 
-	if b&0x01 == 1 {
-		pn.IsFirst = true
+	if !(b&0x02 == 2) {
+		pn.IsFirst = false
 	}
-	if b&0x02 == 2 {
-		pn.IsLast = true
+	if !(b&0x01 == 1) {
+		pn.IsLast = false

Review Comment:
   Discussed offline but documenting here: the NoFiringPane's default for IsFirst and IsLast is true, so when modifying it into the correct pane we we check for the false case. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org