[ 
https://issues.apache.org/jira/browse/BEAM-13909?focusedWorklogId=736725&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-736725
 ]

ASF GitHub Bot logged work on BEAM-13909:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Mar/22 15:33
            Start Date: 04/Mar/22 15:33
    Worklog Time Spent: 10m 
      Work Description: jrmccluskey commented on a change in pull request 
#17014:
URL: https://github.com/apache/beam/pull/17014#discussion_r819671180



##########
File path: sdks/go/pkg/beam/provision/provision_test.go
##########
@@ -52,3 +58,37 @@ func TestConversions(t *testing.T) {
                }
        }
 }
+
+type ProvisionServiceServicer struct {
+       fnpb.UnimplementedProvisionServiceServer
+}
+
+func (p ProvisionServiceServicer) GetProvisionInfo(ctx context.Context, req 
*fnpb.GetProvisionInfoRequest) (*fnpb.GetProvisionInfoResponse, error) {
+       return &fnpb.GetProvisionInfoResponse{Info: 
&fnpb.ProvisionInfo{RetrievalToken: "token"}}, nil
+}
+
+func setup(addr string, prs *ProvisionServiceServicer) {
+       l, err := net.Listen("tcp", addr)
+       if err != nil {
+               log.Fatalf("failed to listen on addr: %v", err)
+       }
+       server := grpc.NewServer()
+       defer server.Stop()
+       fnpb.RegisterProvisionServiceServer(server, prs)
+       if err := server.Serve(l); err != nil {
+               log.Fatalf("cannot serve the server: %v", err)
+       }
+}
+
+func TestProvisionInfo(t *testing.T) {
+       prs := &ProvisionServiceServicer{}
+       go setup(":9000", prs)

Review comment:
       Hard coding the address is not ideal since the outcome of the test is 
now dependent on localhost:9000 being available. You can instead [poll for an 
open port using net.Listen() like in the expansion service start-up 
code](https://github.com/apache/beam/blob/2aa4da02bc49be72b45e8327c5233c0e4938e59d/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/process.go#L37)




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 736725)
    Time Spent: 1h  (was: 50m)

> Increase unit testing in the provision package
> ----------------------------------------------
>
>                 Key: BEAM-13909
>                 URL: https://issues.apache.org/jira/browse/BEAM-13909
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Jack McCluskey
>            Assignee: Ritesh Ghorse
>            Priority: P2
>              Labels: starter
>             Fix For: 2.38.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Increase unit testing coverage in the [provision 
> package|https://github.com/apache/beam/tree/release-2.36.0/sdks/go/pkg/beam/provision]
> We want code coverage at or above 50%, it is currently at 42.3%.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to