Skip to content

Commit

Permalink
Update test tool to 1.8, with new delayed calls test (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Aug 19, 2024
1 parent 9a99a62 commit 9c71385
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
name: "Features integration test (sdk-test-suite version ${{ matrix.sdk-test-suite }})"
strategy:
matrix:
sdk-test-suite: [ "1.7" ]
sdk-test-suite: [ "1.8" ]
permissions:
contents: read
issues: read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import dev.restate.sdk.kotlin.awaitAll
import dev.restate.sdk.testservices.contracts.ManyCallRequest
import dev.restate.sdk.testservices.contracts.Proxy
import dev.restate.sdk.testservices.contracts.ProxyRequest
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

class ProxyImpl : Proxy {
private fun ProxyRequest.toTarget(): Target {
Expand All @@ -31,15 +33,23 @@ class ProxyImpl : Proxy {
}

override suspend fun oneWayCall(context: Context, request: ProxyRequest) {
context.send(request.toTarget(), Serde.RAW, request.message)
context.send(
request.toTarget(),
Serde.RAW,
request.message,
request.delayMillis?.milliseconds ?: Duration.ZERO)
}

override suspend fun manyCalls(context: Context, requests: List<ManyCallRequest>) {
val toAwait = mutableListOf<Awaitable<ByteArray>>()

for (request in requests) {
if (request.oneWayCall) {
context.send(request.proxyRequest.toTarget(), Serde.RAW, request.proxyRequest.message)
context.send(
request.proxyRequest.toTarget(),
Serde.RAW,
request.proxyRequest.message,
request.proxyRequest.delayMillis?.milliseconds ?: Duration.ZERO)
} else {
val awaitable =
context.callAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,11 @@ import kotlinx.serialization.Serializable
@Serializable
data class ProxyRequest(
val serviceName: String,
val virtualObjectKey: String?, // If null, the request is to a service
val virtualObjectKey: String? = null, // If null, the request is to a service
val handlerName: String,
val message: ByteArray
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is ProxyRequest) return false

if (serviceName != other.serviceName) return false
if (virtualObjectKey != other.virtualObjectKey) return false
if (handlerName != other.handlerName) return false
if (!message.contentEquals(other.message)) return false

return true
}

override fun hashCode(): Int {
var result = serviceName.hashCode()
result = 31 * result + (virtualObjectKey?.hashCode() ?: 0)
result = 31 * result + handlerName.hashCode()
result = 31 * result + message.contentHashCode()
return result
}
}
val message: ByteArray,
val delayMillis: Int? = null
)

@Serializable
data class ManyCallRequest(
Expand Down

0 comments on commit 9c71385

Please sign in to comment.