[
https://issues.apache.org/jira/browse/BEAM-13534?focusedWorklogId=706336&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-706336
]
ASF GitHub Bot logged work on BEAM-13534:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Jan/22 17:27
Start Date: 10/Jan/22 17:27
Worklog Time Spent: 10m
Work Description: jrmccluskey commented on a change in pull request
#16470:
URL: https://github.com/apache/beam/pull/16470#discussion_r781398709
##########
File path: sdks/go/pkg/beam/core/runtime/xlangx/expansionx/process.go
##########
@@ -30,20 +31,40 @@ type ExpansionServiceRunner struct {
serviceCommand *exec.Cmd
}
+func findOpenPort() (int, error) {
+ listener, err := net.Listen("tcp", ":0")
+ if err != nil {
+ return 0, err
+ }
+ defer listener.Close()
+ return listener.Addr().(*net.TCPAddr).Port, nil
+}
+
// NewExpansionServiceRunner builds an ExpansionServiceRunner struct for a
given gradle target and
-// Beam version and returns a pointer to it.
-func NewExpansionServiceRunner(jarPath, servicePort string)
*ExpansionServiceRunner {
+// Beam version and returns a pointer to it. Passing an empty string as
servicePort will request an
+// open port to be assigned to the service.
+func NewExpansionServiceRunner(jarPath, servicePort string)
(*ExpansionServiceRunner, error) {
if servicePort == "" {
- servicePort = "8097"
+ port, err := findOpenPort()
+ if err != nil {
+ return nil, fmt.Errorf("failed to find open port for
service, got %v", err)
+ }
+ servicePort = fmt.Sprintf("%d", port)
}
serviceCommand := exec.Command("java", "-jar", jarPath, servicePort)
- return &ExpansionServiceRunner{jarPath: jarPath, servicePort:
servicePort, serviceCommand: serviceCommand}
+ return &ExpansionServiceRunner{jarPath: jarPath, servicePort:
servicePort, serviceCommand: serviceCommand}, nil
}
func (e *ExpansionServiceRunner) String() string {
return fmt.Sprintf("JAR: %v, Port: %v, Process: %v", e.jarPath,
e.servicePort, e.serviceCommand.Process)
}
+// GetPort returns the formatted port the ExpansionServiceRunner is set to
start the expansion
Review comment:
Missed that one, whoops
--
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: 706336)
Time Spent: 5h (was: 4h 50m)
> TestAutomatedExpansionService framework does not work on Samza or Spark
> -----------------------------------------------------------------------
>
> Key: BEAM-13534
> URL: https://issues.apache.org/jira/browse/BEAM-13534
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Reporter: Jack McCluskey
> Assignee: Jack McCluskey
> Priority: P3
> Fix For: 2.37.0
>
> Time Spent: 5h
> Remaining Estimate: 0h
>
> The setup for the TestAutomatedExpansionService integration test currently
> spins up a JAR, pings that it is alive and accepting connections, then stops
> the service. In the Samza and Spark environments, however, the command to
> ping the service's port fails with exit code 1.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)