Skip to content

Commit

Permalink
Add FrontendHostPort method to DevServer (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein authored Mar 28, 2023
1 parent 3d9a1ef commit 88a40de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
16 changes: 13 additions & 3 deletions testsuite/devserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ type DevServerOptions struct {

// Temporal CLI based DevServer
type DevServer struct {
cmd *exec.Cmd
client client.Client
cmd *exec.Cmd
client client.Client
frontendHostPort string
}

// StartDevServer starts a Temporal CLI dev server process. This may download the server if not already downloaded.
Expand Down Expand Up @@ -121,7 +122,11 @@ func StartDevServer(ctx context.Context, options DevServerOptions) (*DevServer,
return nil, err
}
clientOptions.Logger.Info("DevServer ready")
return &DevServer{client: returnedClient, cmd: cmd}, nil
return &DevServer{
client: returnedClient,
cmd: cmd,
frontendHostPort: clientOptions.HostPort,
}, nil
}

func prepareCommand(options *DevServerOptions, host, port, namespace string) []string {
Expand Down Expand Up @@ -366,3 +371,8 @@ func (s *DevServer) Stop() error {
func (s *DevServer) Client() client.Client {
return s.client
}

// FrontendHostPort returns the host:port for this server.
func (s *DevServer) FrontendHostPort() string {
return s.frontendHostPort
}
12 changes: 12 additions & 0 deletions testsuite/devserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ func TestStartDevServer_CustomNamespace(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "testing", info.NamespaceInfo.Name)
}

func TestStartDevServer_FrontendHostPort(t *testing.T) {
server, err := testsuite.StartDevServer(context.Background(), testsuite.DevServerOptions{})
require.NoError(t, err)
defer func() { _ = server.Stop() }()
hostPort := server.FrontendHostPort()
client, err := client.Dial(client.Options{HostPort: hostPort})
require.NoError(t, err)
info, err := client.WorkflowService().GetSystemInfo(context.Background(), &workflowservice.GetSystemInfoRequest{})
require.NoError(t, err)
require.NotNil(t, info.Capabilities)
}

0 comments on commit 88a40de

Please sign in to comment.