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 2021/07/23 14:58:21 UTC

[GitHub] [beam] riteshghorse commented on a change in pull request #15206: [Beam-10166] Improve execution time errors

riteshghorse commented on a change in pull request #15206:
URL: https://github.com/apache/beam/pull/15206#discussion_r675630522



##########
File path: sdks/go/pkg/beam/core/runtime/exec/util_test.go
##########
@@ -0,0 +1,71 @@
+// 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 exec
+
+import (
+	"context"
+	"errors"
+	"strings"
+	"testing"
+
+	"github.com/apache/beam/sdks/go/pkg/beam/util/errorx"
+)
+
+// testSimpleError tests for a simple case that
+// doesn't panic
+func testSimpleError(ctx context.Context, t *testing.T) {
+	expected := errors.New("Sample error.")
+	actual := callNoPanic(ctx, func(c context.Context) error { return errors.New("Simple error.") })
+
+	if errors.Unwrap(actual) != errors.Unwrap(expected) {
+		t.Errorf("Simple error reporting failed.")
+	}
+}
+
+// testPanicError tests for the case in which a normal
+// error is passed to panic, resulting in panic trace.
+func testPanicError(ctx context.Context, t *testing.T) {
+	actual := callNoPanic(ctx, func(c context.Context) error { panic("Panic error") })
+	if !strings.Contains(actual.Error(), "panic:") {
+		t.Errorf("Caught in panic.")
+	}
+}
+
+// testWrapPanicError tests for the case in which error
+// is passed to panic from DoFn, resulting in
+// formatted error message for DoFn.
+func testWrapPanicError(ctx context.Context, t *testing.T) {
+	parDoError := doFnError{
+		doFn: "sumFn",
+		err:  errors.New("SumFn error"),
+		uid:  1,
+		pid:  "Plan ID",
+	}
+	var err errorx.GuardedError
+	err.TrySetError(&parDoError)
+	actual := callNoPanic(ctx, func(c context.Context) error { panic(parDoError) })
+
+	if strings.Contains(actual.Error(), "panic:") {
+		t.Errorf("Error not wrapped! Caught in panic")
+	}
+}
+
+func TestCallNoPanic(t *testing.T) {

Review comment:
       Got it.




-- 
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