# Issue when trying to use Temporal TestServer

**URL:** <https://community.temporal.io/t/issue-when-trying-to-use-temporal-testserver/14974>\
**Category:** Community Support\
**Tags:** go-sdk\
**Created:** [November 4, 2024, 11:29pm UTC](https://community.temporal.io/t/issue-when-trying-to-use-temporal-testserver/14974 "2024-11-04T23:29:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Zelei](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/nick_zelei/32/4793_2.png) [@Nick\_Zelei](https://community.temporal.io/u/Nick_Zelei)\
**Post date:** [November 4, 2024, 11:29pm UTC](https://community.temporal.io/t/issue-when-trying-to-use-temporal-testserver/14974/1 "2024-11-04T23:29:23Z")

</div>

Hi there, I have a few questions with regards to using the Go temporal testserver.  
I’m doing this so I can test my API’s interactions with the temporal SDK clients.

At the time of writing this post, my go.mod is using the latest available packages that temporal provides:

```auto
go.temporal.io/api v1.41.0
go.temporal.io/sdk v1.30.0
go.temporal.io/sdk/contrib/opentelemetry v0.6.0
go.temporal.io/server v1.25.1

```

However, when I try to start the server within a test, I get this error:

```auto
# go.temporal.io/server/client/frontend
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/client/frontend/client.go:46:47: cannot use (*clientImpl)(nil) (value of type *clientImpl) as workflowservice.WorkflowServiceClient value in variable declaration: *clientImpl does not implement workflowservice.WorkflowServiceClient (missing method PauseActivityById)
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/client/frontend/client.go:60:9: cannot use &clientImpl{…} (value of type *clientImpl) as workflowservice.WorkflowServiceClient value in return statement: *clientImpl does not implement workflowservice.WorkflowServiceClient (missing method PauseActivityById)
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/client/frontend/metric_client.go:40:47: cannot use (*metricClient)(nil) (value of type *metricClient) as workflowservice.WorkflowServiceClient value in variable declaration: *metricClient does not implement workflowservice.WorkflowServiceClient (missing method PauseActivityById)
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/client/frontend/metric_client.go:54:9: cannot use &metricClient{…} (value of type *metricClient) as workflowservice.WorkflowServiceClient value in return statement: *metricClient does not implement workflowservice.WorkflowServiceClient (missing method PauseActivityById)
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/client/frontend/retryable_client.go:33:47: cannot use (*retryableClient)(nil) (value of type *retryableClient) as workflowservice.WorkflowServiceClient value in variable declaration: *retryableClient does not implement workflowservice.WorkflowServiceClient (missing method PauseActivityById)
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/client/frontend/retryable_client.go:43:9: cannot use &retryableClient{…} (value of type *retryableClient) as workflowservice.WorkflowServiceClient value in return statement: *retryableClient does not implement workflowservice.WorkflowServiceClient (missing method PauseActivityById)
# go.temporal.io/server/common/nexus
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/common/nexus/failure.go:177:36: undefined: nexus.HandlerErrorTypeDownstreamTimeout
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/common/nexus/failure.go:215:13: undefined: nexus.StatusDownstreamTimeout
/Users/nick/go/pkg/mod/go.temporal.io/server@v1.25.1/common/nexus/failure.go:216:16: undefined: nexus.HandlerErrorTypeDownstreamTimeout
FAIL	github.com/nucleuscloud/neosync/backend/services/mgmt/v1alpha1/integration_tests [build failed]

```

Also, I’m wondering what port this test server starts on? Will it fail if I already have Temporal running in a separate docker container that is exposed to 7233 on my laptop? Or will it simply use that for testing? Just curious.

The `TestServer` struct exposes a way to get a pre-configured client, which is great, however, I’m trying to figure out how I can correctly build a `NamespaceClient`, which the struct does not expose a way to get this, so I have to build it using the `temporalclient` package.  
However, there doesn’t seem to be a way to retrieve the `HostPort` from the test struct, only the namespace being used.

Any help here is appreciated.

PR I’m working on: [attempt at using temporalserver by nickzelei · Pull Request #2905 · nucleuscloud/neosync · GitHub](https://github.com/nucleuscloud/neosync/pull/2905)

---

<div class="post-metadata">

**Author:** ![laouji](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@laouji](https://community.temporal.io/u/laouji)\
**Post date:** [November 12, 2024, 2:05pm UTC](https://community.temporal.io/t/issue-when-trying-to-use-temporal-testserver/14974/2 "2024-11-12T14:05:22Z")

</div>

The underlying temporalite server scans for an available port and picks the first available, so it won’t be consistent every time you run your tests.

I had a similar issue where I wanted access to the host:port without using the client structs and made a PR to expose the HostPort to users of TestServer which I am waiting to have reviewed by the maintainers:

> <https://github.com/temporalio/temporal/pull/6781>
>
> \## What changed?
> Added a \`GetFrontendHostPort()\` method to the TestServer
> 
> \##… Why?
> For situations where you want to know the port that the test server is running on outside of typical use of client.Client
> 
> \## How did you test it?
> Tested locally
> 
> \## Potential risks
> None
> 
> \## Documentation
> there is currently no documentation for TestServer aside from inline comments
> 
> \## Is hotfix candidate?
> no

But while we are here, in your case, can you not use the TestServer.NewClientWithOptions function and set the namespace via the client.Options?

---

<div class="post-metadata">

**Author:** ![Nick\_Zelei](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/nick_zelei/32/4793_2.png) [@Nick\_Zelei](https://community.temporal.io/u/Nick_Zelei)\
**Post date:** [November 15, 2024, 10:11pm UTC](https://community.temporal.io/t/issue-when-trying-to-use-temporal-testserver/14974/3 "2024-11-15T22:11:06Z")

</div>

Thanks for the response.

In only the simplest of cases could I not use the test server NewClient. It would work on _my_ laptop, but not necessarily in other environments like CI or on someone else’s machine. Trying to set this up to work in automated fashion where I don’t necessarily know or want temporal to be setup prior. I’d like my integration test to setup temporal via this package.  
I may end up trying a different way and having it setup via a testcontainer or something.
