Skip to content

Commit

Permalink
Refactor: remove unneeded fields from FunctionalTestBase (temporalio#…
Browse files Browse the repository at this point in the history
…7170)

## What changed?
<!-- Describe what has changed in this PR -->
Refactor: remove unneeded fields from `FunctionalTestBase`.

## Why?
<!-- Tell your future self why have you made these changes -->
Simplify function test base struct.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Build and run tests.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
No risks.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
No.

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No.
  • Loading branch information
alexshtin authored Jan 28, 2025
1 parent 4bb5867 commit 519fb71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
33 changes: 12 additions & 21 deletions tests/testcore/functional_test_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,10 @@ type (
testClusterFactory TestClusterFactory
testCluster *TestCluster
testClusterConfig *TestClusterConfig
frontendClient workflowservice.WorkflowServiceClient
adminClient adminservice.AdminServiceClient
operatorClient operatorservice.OperatorServiceClient
httpAPIAddress string
namespace namespace.Name
namespaceID namespace.ID
foreignNamespace namespace.Name

namespace namespace.Name
namespaceID namespace.ID
foreignNamespace namespace.Name
}
// TestClusterParams contains the variables which are used to configure test cluster via the TestClusterOption type.
TestClusterParams struct {
Expand Down Expand Up @@ -146,19 +143,19 @@ func (s *FunctionalTestBase) GetTestClusterConfig() *TestClusterConfig {
}

func (s *FunctionalTestBase) FrontendClient() workflowservice.WorkflowServiceClient {
return s.frontendClient
return s.testCluster.FrontendClient()
}

func (s *FunctionalTestBase) AdminClient() adminservice.AdminServiceClient {
return s.adminClient
return s.testCluster.AdminClient()
}

func (s *FunctionalTestBase) OperatorClient() operatorservice.OperatorServiceClient {
return s.operatorClient
return s.testCluster.OperatorClient()
}

func (s *FunctionalTestBase) HttpAPIAddress() string {
return s.httpAPIAddress
return s.testCluster.Host().FrontendHTTPAddress()
}

func (s *FunctionalTestBase) Namespace() namespace.Name {
Expand Down Expand Up @@ -230,12 +227,6 @@ func (s *FunctionalTestBase) SetupSuiteWithCluster(clusterConfigFile string, opt
s.foreignNamespace = namespace.Name(RandomizeStr("foreign-namespace"))
_, err = s.RegisterNamespace(s.ForeignNamespace(), 1, enumspb.ARCHIVAL_STATE_DISABLED, "", "")
s.Require().NoError(err)

// Setup test cluster clients.
s.frontendClient = s.testCluster.FrontendClient()
s.adminClient = s.testCluster.AdminClient()
s.operatorClient = s.testCluster.OperatorClient()
s.httpAPIAddress = s.testCluster.Host().FrontendHTTPAddress()
}

// All test suites that inherit FunctionalTestBase and overwrite SetupTest must
Expand Down Expand Up @@ -421,7 +412,7 @@ func (s *FunctionalTestBase) MarkNamespaceAsDeleted(
) error {
ctx, cancel := rpc.NewContextWithTimeoutAndVersionHeaders(10000 * time.Second)
defer cancel()
_, err := s.frontendClient.UpdateNamespace(ctx, &workflowservice.UpdateNamespaceRequest{
_, err := s.FrontendClient().UpdateNamespace(ctx, &workflowservice.UpdateNamespaceRequest{
Namespace: nsName.String(),
UpdateInfo: &namespacepb.UpdateNamespaceInfo{
State: enumspb.NAMESPACE_STATE_DELETED,
Expand All @@ -433,7 +424,7 @@ func (s *FunctionalTestBase) MarkNamespaceAsDeleted(

func (s *FunctionalTestBase) GetHistoryFunc(namespace string, execution *commonpb.WorkflowExecution) func() []*historypb.HistoryEvent {
return func() []*historypb.HistoryEvent {
historyResponse, err := s.frontendClient.GetWorkflowExecutionHistory(NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{
historyResponse, err := s.FrontendClient().GetWorkflowExecutionHistory(NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{
Namespace: namespace,
Execution: execution,
MaximumPageSize: 5, // Use small page size to force pagination code path
Expand All @@ -442,7 +433,7 @@ func (s *FunctionalTestBase) GetHistoryFunc(namespace string, execution *commonp

events := historyResponse.History.Events
for historyResponse.NextPageToken != nil {
historyResponse, err = s.frontendClient.GetWorkflowExecutionHistory(NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{
historyResponse, err = s.FrontendClient().GetWorkflowExecutionHistory(NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{
Namespace: namespace,
Execution: execution,
NextPageToken: historyResponse.NextPageToken,
Expand Down Expand Up @@ -566,7 +557,7 @@ func (s *FunctionalTestBase) WaitForChannel(ctx context.Context, ch chan struct{
// TODO (alex): change to nsName namespace.Name
func (s *FunctionalTestBase) SendSignal(nsName string, execution *commonpb.WorkflowExecution, signalName string,
input *commonpb.Payloads, identity string) error {
_, err := s.frontendClient.SignalWorkflowExecution(NewContext(), &workflowservice.SignalWorkflowExecutionRequest{
_, err := s.FrontendClient().SignalWorkflowExecution(NewContext(), &workflowservice.SignalWorkflowExecutionRequest{
Namespace: nsName,
WorkflowExecution: execution,
SignalName: signalName,
Expand Down
2 changes: 1 addition & 1 deletion tests/testcore/functional_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ type (

func (s *FunctionalTestSuite) SetupTest() {
s.FunctionalTestBase.SetupTest()
s.TaskPoller = taskpoller.New(s.T(), s.frontendClient, s.Namespace().String())
s.TaskPoller = taskpoller.New(s.T(), s.FrontendClient(), s.Namespace().String())
}

0 comments on commit 519fb71

Please sign in to comment.