youngoli commented on pull request #16111:
URL: https://github.com/apache/beam/pull/16111#issuecomment-985284872


   I think I figured out the problem you're having. I noticed that when I ran 
this, the SDK harness was outputting "PASS". This means it's running tests in 
the SDK harness instead of acting as an SDK harness, which led me to find the 
culprit:
   
   You need the following code in your test file:
   ```
   func TestMain(m *testing.M) {
        ptest.Main(m)
   }
   ```
   To give a short version of why, the SDK harness is actually executing the 
exact binary that the code is originally executed from. Normally in our files 
we have a call in beam.Init to check if it's the SDK harness or user code, and 
if the binary is run as the SDK harness it behaves differently.
   
   To get the same thing working for our tests, we need to replace TestMain 
with ptest.Main, otherwise it will try to execute all the tests before we can 
run beam.Init. ptest.Main handles that for us by calling beam.Init before 
deferring to the normal TestMain behavior. This means any kind of integration 
test we write for the Go SDK needs to call that snippet, or something 
equivalent, because we absolutely need beam.Init to get called before going to 
the normal test framework logic, otherwise SDK harnesses built for those 
integration tests will attempt to run tests instead of actually act as an SDK 
harness.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to