[
https://issues.apache.org/jira/browse/BEAM-13419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488318#comment-17488318
]
Danny McCormick commented on BEAM-13419:
----------------------------------------
[~danoliveira] I haven't been able to repro this yet.
> ptest.Run and beam.Run seem to just instantly pass without a problem when
> beam.Init hasn't been called.
I don't think this is actually universally true - ptest.Run just calls beam.Run
-
[https://github.com/apache/beam/blob/7e2b6370b7c98a820c905a5c19abd3cc486b9d77/sdks/go/pkg/beam/testing/ptest/ptest.go#L86]
- so we basically just need to look at that. beam.Run then shells out to the
runners Execute functions, which seem to have a range of behavior:
1) Universal - checks if initialized and panics if not. This fails the test -
[https://github.com/apache/beam/blob/7e2b6370b7c98a820c905a5c19abd3cc486b9d77/sdks/go/pkg/beam/runners/universal/universal.go#L48]
2) Direct - just warns if not initialized. Importantly, because no hooks are
necessary for the direct runner, the tests still run normally; I was able to
remove the ptest.Main call and run our integration tests on the direct runner,
and they still succeeded/failed as expected -
[https://github.com/apache/beam/blob/7e2b6370b7c98a820c905a5c19abd3cc486b9d77/sdks/go/pkg/beam/runners/direct/direct.go#L44]
- I'd make the case that if we're just warning in the mainline case, then we
shouldn't be throwing in the testing case.
3) Dataflow - doesn't seem to have any sort of Initialized check, so I'm
guessing this is where you saw this behavior. Even with that, though, I was
able to remove the ptest.Main call and it still ran the pipeline/failed a test
when it should have.
Given what I'm seeing, I don't think we should add a check like this unless I'm
missing something, we'd be better off just letting the Execute functions handle
their desired behavior. I'm wondering if what happened is that because
ptest.Main wasn't called, m.Run also wasn't called and that's what led to this
perceived behavior (I only suspect that because I ran into that issue a couple
times trying to repro, and I haven't seen anything else that could cause this
kind of behavior. That's the only interesting thing ptest.Run does other than
call beam.Init()
[https://github.com/apache/beam/blob/98e5fc5d3a3229a3185005d7557f0f5c34ef7ec5/sdks/go/pkg/beam/testing/ptest/ptest.go#L131]).
[~danoliveira] are you still able to repro? If so, any chance you could help me
out here? If not, can we close this one?
> Add Go integration test errors when forgetting ptest.Main/beam.Init
> -------------------------------------------------------------------
>
> Key: BEAM-13419
> URL: https://issues.apache.org/jira/browse/BEAM-13419
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Reporter: Daniel Oliveira
> Assignee: Danny McCormick
> Priority: P2
>
> Currently when someone writes an integration test and forgets to put
> ptest.Main into TestMain (or their own code calling beam.Init), then the SDK
> harness runs the tests as unit tests and ends up passing them because
> ptest.Run and beam.Run seem to just instantly pass without a problem when
> beam.Init hasn't been called.
> The end result is that SDK harnesses in this setup just instantly pass all
> the tests and then close without any error messages.
> This code path should have an error added so that if beam.Init hasn't been
> run when ptest.Run executes, then it fails with an error.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)