Issue when trying to use Temporal TestServer

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:

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:

# 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

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:

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

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.