Skip to content

Commit

Permalink
Remove endpoint setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Sep 28, 2024
1 parent 0eba596 commit 713d68f
Showing 1 changed file with 0 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

package io.temporal.workflow

import com.google.protobuf.ByteString
import io.nexusrpc.Operation
import io.nexusrpc.Service
import io.nexusrpc.handler.OperationContext
Expand All @@ -29,13 +28,6 @@ import io.nexusrpc.handler.OperationImpl
import io.nexusrpc.handler.OperationStartDetails
import io.nexusrpc.handler.ServiceImpl
import io.nexusrpc.handler.SynchronousOperationFunction
import io.temporal.api.common.v1.Payload
import io.temporal.api.nexus.v1.Endpoint
import io.temporal.api.nexus.v1.EndpointSpec
import io.temporal.api.nexus.v1.EndpointTarget
import io.temporal.api.operatorservice.v1.CreateNexusEndpointRequest
import io.temporal.api.operatorservice.v1.CreateNexusEndpointResponse
import io.temporal.api.operatorservice.v1.DeleteNexusEndpointRequest
import io.temporal.client.WorkflowClientOptions
import io.temporal.client.WorkflowOptions
import io.temporal.common.converter.DefaultDataConverter
Expand All @@ -44,9 +36,7 @@ import io.temporal.common.converter.KotlinObjectMapperFactory
import io.temporal.internal.async.FunctionWrappingUtil
import io.temporal.internal.sync.AsyncInternal
import io.temporal.testing.internal.SDKTestWorkflowRule
import org.junit.After
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import java.time.Duration
Expand All @@ -65,8 +55,6 @@ class KotlinAsyncNexusTest {
)
.build()

private var endpoint: Endpoint? = null

@Service
interface TestNexusService {
@Operation
Expand Down Expand Up @@ -95,7 +83,6 @@ class KotlinAsyncNexusTest {
val nexusService = Workflow.newNexusServiceStub(
TestNexusService::class.java,
NexusServiceOptions {
setEndpoint("test-endpoint-" + Workflow.getInfo().taskQueue)
setOperationOptions(
NexusOperationOptions {
setScheduleToCloseTimeout(Duration.ofSeconds(10))
Expand All @@ -122,48 +109,4 @@ class KotlinAsyncNexusTest {
val workflowStub = client.newWorkflowStub(TestWorkflow::class.java, options)
workflowStub.execute()
}

@Before
fun setUp() {
endpoint = createTestEndpoint(
getTestEndpointSpecBuilder("test-endpoint-" + testWorkflowRule.taskQueue)
)
}

@After
fun tearDown() {
testWorkflowRule
.testEnvironment
.operatorServiceStubs
.blockingStub()
.deleteNexusEndpoint(
DeleteNexusEndpointRequest.newBuilder()
.setId(endpoint!!.id)
.setVersion(endpoint!!.version)
.build()
)
}

private fun getTestEndpointSpecBuilder(name: String): EndpointSpec.Builder {
return EndpointSpec.newBuilder()
.setName(name)
.setDescription(Payload.newBuilder().setData(ByteString.copyFromUtf8("test endpoint")))
.setTarget(
EndpointTarget.newBuilder()
.setWorker(
EndpointTarget.Worker.newBuilder()
.setNamespace(testWorkflowRule.testEnvironment.namespace)
.setTaskQueue(testWorkflowRule.taskQueue)
)
)
}

private fun createTestEndpoint(spec: EndpointSpec.Builder): Endpoint {
val resp: CreateNexusEndpointResponse = testWorkflowRule
.testEnvironment
.operatorServiceStubs
.blockingStub()
.createNexusEndpoint(CreateNexusEndpointRequest.newBuilder().setSpec(spec).build())
return resp.endpoint
}
}

0 comments on commit 713d68f

Please sign in to comment.