Skip to content

Commit

Permalink
New upgrade test (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Aug 16, 2024
1 parent 1e0061e commit 9a99a62
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 104 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.6" ]
sdk-test-suite: [ "1.7" ]
permissions:
contents: read
issues: read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dev.restate.sdk.common.TerminalException
import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdk.kotlin.resolve
import dev.restate.sdktesting.contracts.AwakeableHolder
import dev.restate.sdk.testservices.contracts.AwakeableHolder

class AwakeableHolderImpl : AwakeableHolder {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import dev.restate.sdk.kotlin.KtSerdes
import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.SharedWorkflowContext
import dev.restate.sdk.kotlin.WorkflowContext
import dev.restate.sdktesting.contracts.BlockAndWaitWorkflow
import dev.restate.sdk.testservices.contracts.BlockAndWaitWorkflow

class BlockAndWaitWorkflowImpl : BlockAndWaitWorkflow {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import dev.restate.sdk.kotlin.Awakeable
import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdk.kotlin.awakeable
import dev.restate.sdktesting.contracts.AwakeableHolderClient
import dev.restate.sdktesting.contracts.BlockingOperation
import dev.restate.sdktesting.contracts.CancelTest
import dev.restate.sdktesting.contracts.CancelTestBlockingServiceClient
import dev.restate.sdk.testservices.contracts.AwakeableHolderClient
import dev.restate.sdk.testservices.contracts.BlockingOperation
import dev.restate.sdk.testservices.contracts.CancelTest
import dev.restate.sdk.testservices.contracts.CancelTestBlockingServiceClient
import kotlin.time.Duration.Companion.days

class CancelTestImpl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import dev.restate.sdk.common.TerminalException
import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdk.kotlin.SharedObjectContext
import dev.restate.sdktesting.contracts.Counter
import dev.restate.sdktesting.contracts.CounterUpdateResponse
import dev.restate.sdk.testservices.contracts.Counter
import dev.restate.sdk.testservices.contracts.CounterUpdateResponse
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ package dev.restate.sdk.testservices
import dev.restate.sdk.common.TerminalException
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdk.kotlin.runBlock
import dev.restate.sdktesting.contracts.Failing
import dev.restate.sdktesting.contracts.FailingClient
import dev.restate.sdk.testservices.contracts.Failing
import dev.restate.sdk.testservices.contracts.FailingClient
import java.util.concurrent.atomic.AtomicInteger
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ package dev.restate.sdk.testservices
import dev.restate.sdk.common.Serde
import dev.restate.sdk.kotlin.Context
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdktesting.contracts.AwakeableHolderClient
import dev.restate.sdktesting.contracts.KillTest
import dev.restate.sdktesting.contracts.KillTestSingletonClient
import dev.restate.sdk.testservices.contracts.AwakeableHolderClient
import dev.restate.sdk.testservices.contracts.KillTest
import dev.restate.sdk.testservices.contracts.KillTestSingletonClient

class KillTestImpl {
class RunnerImpl : KillTest.Runner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package dev.restate.sdk.testservices
import dev.restate.sdk.common.StateKey
import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdktesting.contracts.ListObject
import dev.restate.sdk.testservices.contracts.ListObject

class ListObjectImpl : ListObject {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package dev.restate.sdk.testservices

import dev.restate.sdk.auth.signing.RestateRequestIdentityVerifier
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder
import dev.restate.sdktesting.contracts.*
import dev.restate.sdk.testservices.contracts.*

val KNOWN_SERVICES_FACTORIES: Map<String, () -> Any> =
mapOf(
Expand All @@ -27,7 +27,7 @@ val KNOWN_SERVICES_FACTORIES: Map<String, () -> Any> =
NonDeterministicDefinitions.SERVICE_NAME to { NonDeterministicImpl() },
ProxyDefinitions.SERVICE_NAME to { ProxyImpl() },
TestUtilsServiceDefinitions.SERVICE_NAME to { TestUtilsServiceImpl() },
UpgradeTestDefinitions.SERVICE_NAME to { UpgradeTestImpl() })
)

fun main(args: Array<String>) {
var env = System.getenv("SERVICES")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ package dev.restate.sdk.testservices

import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdktesting.contracts.Entry
import dev.restate.sdktesting.contracts.MapObject
import dev.restate.sdk.testservices.contracts.Entry
import dev.restate.sdk.testservices.contracts.MapObject

class MapObjectImpl : MapObject {
override suspend fun set(context: ObjectContext, entry: Entry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ package dev.restate.sdk.testservices
import dev.restate.sdk.common.StateKey
import dev.restate.sdk.kotlin.KtStateKey
import dev.restate.sdk.kotlin.ObjectContext
import dev.restate.sdktesting.contracts.CounterClient
import dev.restate.sdktesting.contracts.NonDeterministic
import dev.restate.sdk.testservices.contracts.CounterClient
import dev.restate.sdk.testservices.contracts.NonDeterministic
import java.util.concurrent.ConcurrentHashMap
import kotlin.time.Duration.Companion.milliseconds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import dev.restate.sdk.common.Target
import dev.restate.sdk.kotlin.Awaitable
import dev.restate.sdk.kotlin.Context
import dev.restate.sdk.kotlin.awaitAll
import dev.restate.sdktesting.contracts.ManyCallRequest
import dev.restate.sdktesting.contracts.Proxy
import dev.restate.sdktesting.contracts.ProxyRequest
import dev.restate.sdk.testservices.contracts.ManyCallRequest
import dev.restate.sdk.testservices.contracts.Proxy
import dev.restate.sdk.testservices.contracts.ProxyRequest

class ProxyImpl : Proxy {
private fun ProxyRequest.toTarget(): Target {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package dev.restate.sdk.testservices

import dev.restate.sdk.kotlin.*
import dev.restate.sdktesting.contracts.*
import dev.restate.sdk.testservices.contracts.*
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
import kotlin.time.Duration.Companion.milliseconds
Expand Down Expand Up @@ -60,4 +60,22 @@ class TestUtilsServiceImpl : TestUtilsService {

return invokedSideEffects.get()
}

override suspend fun getEnvVariable(context: Context, env: String): String {
return context.runBlock { System.getenv(env) ?: "" }
}

override suspend fun interpretCommands(context: Context, req: InterpretRequest) {
val listClient = ListObjectClient.fromContext(context, req.listName).send()
req.commands.forEach {
when (it) {
is CreateAwakeableAndAwaitIt -> {
val awakeable = context.awakeable<String>()
AwakeableHolderClient.fromContext(context, it.awakeableKey).hold(awakeable.id)
listClient.append(awakeable.await())
}
is GetEnvVariable -> listClient.append(getEnvVariable(context, it.envName))
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Exclusive
import dev.restate.sdk.annotation.VirtualObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Shared
import dev.restate.sdk.annotation.Workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.*
import dev.restate.sdk.annotation.Exclusive
import dev.restate.sdk.annotation.VirtualObject
import dev.restate.sdk.kotlin.ObjectContext
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.VirtualObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.*
import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.Service
import dev.restate.sdk.annotation.VirtualObject
import dev.restate.sdk.kotlin.Context
import dev.restate.sdk.kotlin.ObjectContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.*
import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.VirtualObject
import dev.restate.sdk.kotlin.ObjectContext

@VirtualObject(name = "ListObject")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.VirtualObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.*
import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.VirtualObject
import dev.restate.sdk.kotlin.ObjectContext

@VirtualObject(name = "NonDeterministic")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdktesting.contracts
package dev.restate.sdk.testservices.contracts

import dev.restate.sdk.annotation.Handler
import dev.restate.sdk.annotation.Service
Expand All @@ -31,6 +31,20 @@ data object TimeoutResponse : CreateAwakeableAndAwaitItResponse
@SerialName("result")
data class AwakeableResultResponse(val value: String) : CreateAwakeableAndAwaitItResponse

@Serializable data class InterpretRequest(val listName: String, val commands: List<Command>)

@Serializable sealed interface Command
// This is serialized as `{"type": "createAwakeableAndAwaitIt", ...}`
@Serializable
@SerialName("createAwakeableAndAwaitIt")
data class CreateAwakeableAndAwaitIt(val awakeableKey: String) : Command

// This is serialized as `{"type": "getEnvVariable", ...}`
// Reading an environment variable should be done within a side effect!
@Serializable
@SerialName("getEnvVariable")
data class GetEnvVariable(val envName: String) : Command

/** Collection of various utilities/corner cases scenarios used by tests */
@Service(name = "TestUtilsService")
interface TestUtilsService {
Expand Down Expand Up @@ -61,4 +75,14 @@ interface TestUtilsService {
* This is used to verify acks will suspend when using the always suspend test-suite
*/
@Handler suspend fun countExecutedSideEffects(context: Context, increments: Int): Int

/** Read an environment variable */
@Handler suspend fun getEnvVariable(context: Context, env: String): String

/**
* This handler should iterate through the list of commands and execute them.
*
* For each command, the output should be appended to the given list name.
*/
@Handler suspend fun interpretCommands(context: Context, req: InterpretRequest)
}

This file was deleted.

0 comments on commit 9a99a62

Please sign in to comment.