diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 187b361426..08dde02e03 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,7 @@ jobs: GOPROXY: https://proxy.golang.org JDK_VER: ${{ matrix.java }} DAPR_CLI_VER: 1.10.0 - DAPR_RUNTIME_VER: 1.10.0 + DAPR_RUNTIME_VER: 1.10.6-rc.2 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.10.0/install/install.sh DAPR_CLI_REF: DAPR_REF: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 447716cf68..951aa644cd 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -38,7 +38,7 @@ jobs: GOPROXY: https://proxy.golang.org JDK_VER: ${{ matrix.java }} DAPR_CLI_VER: 1.10.0 - DAPR_RUNTIME_VER: 1.10.0 + DAPR_RUNTIME_VER: 1.10.6-rc.2 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.10.0/install/install.sh DAPR_CLI_REF: DAPR_REF: diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java index 1deba637aa..0f4ce44eee 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java @@ -19,36 +19,85 @@ import io.dapr.it.AppRun; import io.dapr.it.BaseIT; import io.dapr.it.DaprRun; +import io.dapr.it.actors.app.ActorReminderDataParam; import io.dapr.it.actors.app.MyActorService; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; import static io.dapr.it.Retry.callWithRetry; -import static io.dapr.it.actors.MyActorTestUtils.countMethodCalls; -import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs; -import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls; +import static io.dapr.it.actors.MyActorTestUtils.*; +@RunWith(Parameterized.class) public class ActorReminderRecoveryIT extends BaseIT { private static final Logger logger = LoggerFactory.getLogger(ActorReminderRecoveryIT.class); private static final String METHOD_NAME = "receiveReminder"; + /** + * Parameters for this test. + * Param #1: useGrpc. + * + * @return Collection of parameter tuples. + */ + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList(new Object[][] { + { + "MyActorTest", + new ActorReminderDataParam("36", "String"), + "36" + }, + { + "MyActorTest", + new ActorReminderDataParam("\"my_text\"", "String"), + "\"my_text\"" + }, + { + "MyActorBinaryTest", + new ActorReminderDataParam(new byte[]{0, 1}, "Binary"), + "AAE=" + }, + { + "MyActorObjectTest", + new ActorReminderDataParam("{\"name\":\"abc\",\"age\":30}", "Object"), + "abc,30" + }, + }); + } + + public String actorType; + + public ActorReminderDataParam reminderDataParam; + + public String expectedReminderStateText; + + public String reminderName = UUID.randomUUID().toString(); + private ActorProxy proxy; private ImmutablePair runs; private DaprRun clientRun; + public ActorReminderRecoveryIT( + String actorType, + ActorReminderDataParam reminderDataParam, + String expectedReminderStateText) { + this.actorType = actorType; + this.reminderDataParam = reminderDataParam; + this.expectedReminderStateText = expectedReminderStateText; + } + @Before public void init() throws Exception { runs = startSplitDaprAndApp( @@ -66,11 +115,10 @@ public void init() throws Exception { Thread.sleep(3000); ActorId actorId = new ActorId(UUID.randomUUID().toString()); - String actorType="MyActorTest"; logger.debug("Creating proxy builder"); ActorProxyBuilder proxyBuilder = - new ActorProxyBuilder(actorType, ActorProxy.class, newActorClient()); + new ActorProxyBuilder(this.actorType, ActorProxy.class, newActorClient()); logger.debug("Creating actorId"); logger.debug("Building proxy"); proxy = proxyBuilder.build(actorId); @@ -80,7 +128,7 @@ public void init() throws Exception { public void tearDown() { // call unregister logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invokeMethod("stopReminder", "myReminder").block(); + proxy.invokeMethod("stopReminder", this.reminderName).block(); } /** @@ -90,7 +138,9 @@ public void tearDown() { @Test public void reminderRecoveryTest() throws Exception { logger.debug("Invoking actor method 'startReminder' which will register a reminder"); - proxy.invokeMethod("startReminder", "myReminder").block(); + proxy.invokeMethod("setReminderData", this.reminderDataParam).block(); + + proxy.invokeMethod("startReminder", this.reminderName).block(); logger.debug("Pausing 7 seconds to allow reminder to fire"); Thread.sleep(7000); @@ -100,6 +150,7 @@ public void reminderRecoveryTest() throws Exception { logs.clear(); logs.addAll(fetchMethodCallLogs(proxy)); validateMethodCalls(logs, METHOD_NAME, 3); + validateMessageContent(logs, METHOD_NAME, this.expectedReminderStateText); }, 5000); // Restarts runtime only. @@ -121,6 +172,7 @@ public void reminderRecoveryTest() throws Exception { logger.info("Fetching logs for " + METHOD_NAME); List newLogs = fetchMethodCallLogs(proxy); validateMethodCalls(newLogs, METHOD_NAME, 1); + validateMessageContent(newLogs, METHOD_NAME, this.expectedReminderStateText); logger.info("Pausing 10 seconds to allow reminder to fire a few times"); try { diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java index 193f771f87..ef27564735 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java @@ -33,6 +33,7 @@ import static io.dapr.it.Retry.callWithRetry; import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs; import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls; +import static io.dapr.it.actors.MyActorTestUtils.validateMessageContent; import static org.junit.Assert.assertNotEquals; public class ActorTimerRecoveryIT extends BaseIT { @@ -76,6 +77,7 @@ public void timerRecoveryTest() throws Exception { logs.clear(); logs.addAll(fetchMethodCallLogs(proxy)); validateMethodCalls(logs, METHOD_NAME, 3); + validateMessageContent(logs, METHOD_NAME, "ping!"); }, 5000); // Restarts app only. diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/MethodEntryTracker.java b/sdk-tests/src/test/java/io/dapr/it/actors/MethodEntryTracker.java index 542e3d6351..6395e5cdca 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/MethodEntryTracker.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/MethodEntryTracker.java @@ -18,11 +18,17 @@ public class MethodEntryTracker { private boolean isEnter; private String methodName; + private String message; private Date date; public MethodEntryTracker(boolean isEnter, String methodName, Date date) { + this(isEnter, methodName, null, date); + } + + public MethodEntryTracker(boolean isEnter, String methodName, String message, Date date) { this.isEnter = isEnter; this.methodName = methodName; + this.message = message; this.date = date; } @@ -34,12 +40,16 @@ public String getMethodName() { return this.methodName; } + public String getMessage() { + return this.message; + } + public Date getDate() { return this.date; } @Override public String toString() { - return this.date + " " + this.isEnter + " " + this.methodName; + return this.date + " " + this.isEnter + " " + (this.message != null? this.message + " ":"") + this.methodName; } } diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java b/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java index 7d01c14662..140d7ebe35 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.stream.Collectors; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** * Utility class for tests that use MyActor class. @@ -39,12 +39,26 @@ static int countMethodCalls(List logs, String methodName) { // Counts number of times reminder is invoked. // Events for each actor method call include "enter" and "exit" calls, so they are divided by 2. List calls = - logs.stream().filter(x -> x.getMethodName().equals(methodName)).collect(Collectors.toList()); + logs.stream().filter(x -> x.getMethodName().equals(methodName)).collect(Collectors.toList()); System.out.printf( - "Size of %s count list is %d, which means it's been invoked half that many times.\n", methodName, calls.size()); + "Size of %s count list is %d, which means it's been invoked half that many times.\n", methodName, calls.size()); return calls.size() / 2; } + /** + * Checks if all entries for a method call contain the same message. + * @param logs logs with info about method entries and exits returned from the app + * @param methodName name of the method to be validated + * @param message expected message + */ + static void validateMessageContent(List logs, String methodName, String message) { + List calls = + logs.stream().filter(x -> x.getMethodName().equals(methodName)).collect(Collectors.toList()); + for (MethodEntryTracker m : calls) { + assertEquals(message, m.getMessage()); + } + } + /** * Validate the number of call of a given method. * @param logs logs with info about method entries and exits returned from the app @@ -66,11 +80,22 @@ static List fetchMethodCallLogs(ActorProxy proxy) { ArrayList trackers = new ArrayList(); for(String t : logs) { String[] toks = t.split("\\|"); - MethodEntryTracker m = new MethodEntryTracker( - toks[0].equals("Enter") ? true : false, - toks[1], - new Date(toks[2])); - trackers.add(m); + if (toks.length == 3) { + MethodEntryTracker m = new MethodEntryTracker( + toks[0].equals("Enter") ? true : false, + toks[1], + new Date(toks[2])); + trackers.add(m); + } else if (toks.length == 4) { + MethodEntryTracker m = new MethodEntryTracker( + toks[0].equals("Enter") ? true : false, + toks[1], + toks[2], + new Date(toks[3])); + trackers.add(m); + } else { + fail("Invalid log entry"); + } } return trackers; diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/ActorReminderDataParam.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/ActorReminderDataParam.java new file mode 100644 index 0000000000..7231e59716 --- /dev/null +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/ActorReminderDataParam.java @@ -0,0 +1,77 @@ +/* + * Copyright 2021 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.it.actors.app; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.dapr.utils.TypeRef; + +/** + * This class is for passing string or binary data to the Actor for registering reminder later on during test. + */ +public class ActorReminderDataParam { + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + private String data; + + private byte[] binaryData; + + private String typeHint; + + public ActorReminderDataParam() { + } + + public ActorReminderDataParam(String data, String typeHint) { + this.data = data; + this.typeHint = typeHint; + } + + public ActorReminderDataParam(byte[] data, String typeHint) { + this.binaryData = data; + this.typeHint = typeHint; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public byte[] getBinaryData() { + return binaryData; + } + + public void setBinaryData(byte[] binaryData) { + this.binaryData = binaryData; + } + + public String getTypeHint() { + return typeHint; + } + + public void setTypeHint(String typeHint) { + this.typeHint = typeHint; + } + + public T asObject(TypeRef type) throws Exception { + if (this.data != null) { + return OBJECT_MAPPER.readValue(this.data, OBJECT_MAPPER.constructType(type.getType())); + } else if (this.binaryData != null) { + return OBJECT_MAPPER.readValue(this.binaryData, OBJECT_MAPPER.constructType(type.getType())); + } + return null; + } +} diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActor.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActor.java index dd64d0f68a..4d1d1965de 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActor.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActor.java @@ -23,7 +23,9 @@ public interface MyActor { List retrieveActiveActors(); - void startReminder(String name); + void setReminderData(ActorReminderDataParam param); + + void startReminder(String name) throws Exception; void stopReminder(String name); diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorImpl.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBase.java similarity index 70% rename from sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorImpl.java rename to sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBase.java index e88838923a..46aebbbc70 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorImpl.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBase.java @@ -14,7 +14,6 @@ package io.dapr.it.actors.app; import io.dapr.actors.ActorId; -import io.dapr.actors.ActorType; import io.dapr.actors.runtime.AbstractActor; import io.dapr.actors.runtime.ActorRuntimeContext; import io.dapr.actors.runtime.Remindable; @@ -25,25 +24,28 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.List; -import java.util.TimeZone; - -@ActorType(name = "MyActorTest") -public class MyActorImpl extends AbstractActor implements MyActor, Remindable { +import java.util.*; +import java.util.function.Function; + +public abstract class MyActorBase extends AbstractActor implements MyActor, Remindable { private final String TIMER_CALLBACK_METHOD = "clock"; public static final List ACTIVE_ACTOR = new ArrayList<>(); // this tracks method entries and is used to validate turn-based concurrency. - public ArrayList callLog = new ArrayList(); + public final ArrayList callLog = new ArrayList<>(); + + private ActorReminderDataParam actorReminderDataParam = + new ActorReminderDataParam("36", String.class.getSimpleName()); + + private Function toStringFunc = Objects::toString; + + private final TypeRef reminderStateRef; - public MyActorImpl(ActorRuntimeContext runtimeContext, ActorId id) { + public MyActorBase(ActorRuntimeContext runtimeContext, ActorId id, TypeRef reminderStateRef) { super(runtimeContext, id); - this.callLog = new ArrayList(); + this.reminderStateRef = reminderStateRef; } /** @@ -73,12 +75,39 @@ public List retrieveActiveActors() { } @Override - public void startReminder(String name) throws IllegalArgumentException { + public void setReminderData(ActorReminderDataParam param) { + this.formatAndLog(true, "setReminderData"); + + System.out.println("Setting reminder data with type hint: " + param.getTypeHint()); + this.actorReminderDataParam = param; + this.formatAndLog(false, "setReminderData"); + } + + @Override + public void startReminder(String name) throws Exception { this.formatAndLog(true, "startReminder"); + + Object data = null; + + switch (this.actorReminderDataParam.getTypeHint()) { + case "String": + data = actorReminderDataParam.getData(); + break; + case "Binary": + data = actorReminderDataParam.getBinaryData(); + toStringFunc = t -> Base64.getEncoder().encodeToString((byte[])t); + break; + case "Object": + data = actorReminderDataParam.asObject(TypeRef.get(MyObject.class)); + break; + default: + throw new Exception("Invalid type hint: " + this.actorReminderDataParam.getTypeHint()); + } + try { super.registerReminder( name, - "36", + data, Duration.ofSeconds(1), Duration.ofSeconds(2)).block(); } catch(Exception e) { @@ -103,11 +132,11 @@ public void startTimer(String name) { System.out.println("Enter startTimer with timer name " + name); try { super.registerActorTimer( - name, - TIMER_CALLBACK_METHOD, - "ping!", - Duration.ofSeconds(2), - Duration.ofSeconds(3)).block(); + name, + TIMER_CALLBACK_METHOD, + "ping!", + Duration.ofSeconds(2), + Duration.ofSeconds(3)).block(); } catch (Exception e) { // We don't throw, but the proxy side will know it failed because the test looks for the timer to fire later System.out.println("startTimer caught " + e); @@ -140,30 +169,30 @@ protected Mono onDeactivate() { } @Override - public Mono receiveReminder(String reminderName, String state, Duration dueTime, Duration period) { + public Mono receiveReminder(String reminderName, T state, Duration dueTime, Duration period) { return Mono.fromRunnable(() -> { - this.formatAndLog(true, "receiveReminder"); + this.formatAndLog(true, "receiveReminder", toStringFunc.apply(state)); Calendar utcNow = Calendar.getInstance(TimeZone.getTimeZone("GMT")); String utcNowAsString = DATE_FORMAT.format(utcNow.getTime()); // Handles the request by printing message. System.out.println(String.format( "> Server reminded actor %s of: %s for %s @ %s hosted by instance id %s", - this.getId(), reminderName, state, utcNowAsString, System.getenv("DAPR_HTTP_PORT"))); + this.getId(), reminderName, toStringFunc.apply(state), utcNowAsString, System.getenv("DAPR_HTTP_PORT"))); - this.formatAndLog(false, "receiveReminder"); + this.formatAndLog(false, "receiveReminder", toStringFunc.apply(state)); }); } @Override - public TypeRef getStateType() { - return TypeRef.STRING; + public TypeRef getStateType() { + return reminderStateRef; } @Override public void clock(String message) { - this.formatAndLog(true, TIMER_CALLBACK_METHOD); + this.formatAndLog(true, TIMER_CALLBACK_METHOD, message); Calendar utcNow = Calendar.getInstance(TimeZone.getTimeZone("GMT")); String utcNowAsString = DATE_FORMAT.format(utcNow.getTime()); @@ -173,7 +202,7 @@ public void clock(String message) { super.getId() + ": " + (message == null ? "" : message + " @ " + utcNowAsString)); - this.formatAndLog(false, TIMER_CALLBACK_METHOD); + this.formatAndLog(false, TIMER_CALLBACK_METHOD, message); } @Override @@ -185,6 +214,9 @@ public ArrayList getCallLog() { for (MethodEntryTracker m : this.callLog) { String s = m.getIsEnter() ? "Enter" : "Exit"; s += "|" + m.getMethodName(); + if (m.getMessage() != null) { + s += "|" + m.getMessage(); + } s += "|" + m.getDate().toString(); stringList.add(s); } @@ -218,9 +250,14 @@ public boolean dotNetMethod() { } private void formatAndLog(boolean isEnter, String methodName) { + this.formatAndLog(isEnter, methodName, null); + } + + private void formatAndLog(boolean isEnter, String methodName, String message) { Calendar utcNow = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - MethodEntryTracker entry = new MethodEntryTracker(isEnter, methodName, utcNow.getTime()); + MethodEntryTracker entry = new MethodEntryTracker(isEnter, methodName, message, utcNow.getTime()); this.callLog.add(entry); } + } \ No newline at end of file diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBinaryImpl.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBinaryImpl.java new file mode 100644 index 0000000000..fb2c4620c3 --- /dev/null +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBinaryImpl.java @@ -0,0 +1,29 @@ +/* + * Copyright 2021 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.it.actors.app; + +import io.dapr.actors.ActorId; +import io.dapr.actors.ActorType; +import io.dapr.actors.runtime.ActorRuntimeContext; +import io.dapr.actors.runtime.Remindable; +import io.dapr.utils.TypeRef; + +@ActorType(name = "MyActorBinaryTest") +public class MyActorBinaryImpl extends MyActorBase implements MyActor, Remindable { + + public MyActorBinaryImpl(ActorRuntimeContext runtimeContext, ActorId id) { + super(runtimeContext, id, TypeRef.BYTE_ARRAY); + } + +} \ No newline at end of file diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorObjectImpl.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorObjectImpl.java new file mode 100644 index 0000000000..d9902f1efd --- /dev/null +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorObjectImpl.java @@ -0,0 +1,29 @@ +/* + * Copyright 2021 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.it.actors.app; + +import io.dapr.actors.ActorId; +import io.dapr.actors.ActorType; +import io.dapr.actors.runtime.ActorRuntimeContext; +import io.dapr.actors.runtime.Remindable; +import io.dapr.utils.TypeRef; + +@ActorType(name = "MyActorObjectTest") +public class MyActorObjectImpl extends MyActorBase implements MyActor, Remindable { + + public MyActorObjectImpl(ActorRuntimeContext runtimeContext, ActorId id) { + super(runtimeContext, id, TypeRef.get(MyObject.class)); + } + +} \ No newline at end of file diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorService.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorService.java index b624a353d1..94f9959822 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorService.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorService.java @@ -27,7 +27,9 @@ public static void main(String[] args) throws Exception { System.out.println("Hello from main() MyActorService"); long port = Long.parseLong(args[0]); - ActorRuntime.getInstance().registerActor(MyActorImpl.class); + ActorRuntime.getInstance().registerActor(MyActorStringImpl.class); + ActorRuntime.getInstance().registerActor(MyActorBinaryImpl.class); + ActorRuntime.getInstance().registerActor(MyActorObjectImpl.class); TestApplication.start(port); } diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorStringImpl.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorStringImpl.java new file mode 100644 index 0000000000..962cf678a3 --- /dev/null +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorStringImpl.java @@ -0,0 +1,29 @@ +/* + * Copyright 2021 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.it.actors.app; + +import io.dapr.actors.ActorId; +import io.dapr.actors.ActorType; +import io.dapr.actors.runtime.ActorRuntimeContext; +import io.dapr.actors.runtime.Remindable; +import io.dapr.utils.TypeRef; + +@ActorType(name = "MyActorTest") +public class MyActorStringImpl extends MyActorBase implements MyActor, Remindable { + + public MyActorStringImpl(ActorRuntimeContext runtimeContext, ActorId id) { + super(runtimeContext, id, TypeRef.STRING); + } + +} \ No newline at end of file diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/app/MyObject.java b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyObject.java new file mode 100644 index 0000000000..1b691c5610 --- /dev/null +++ b/sdk-tests/src/test/java/io/dapr/it/actors/app/MyObject.java @@ -0,0 +1,44 @@ +/* + * Copyright 2021 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.it.actors.app; + +/** + * This class is for passing string or binary data to the Actor for registering reminder later on during test. + */ +public class MyObject { + + private String name; + + private int age; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String toString() { + return this.name + "," + this.age; + } +} diff --git a/sdk-tests/src/test/java/io/dapr/it/methodinvoke/grpc/MethodInvokeIT.java b/sdk-tests/src/test/java/io/dapr/it/methodinvoke/grpc/MethodInvokeIT.java index ef1a66c033..b5cea26434 100644 --- a/sdk-tests/src/test/java/io/dapr/it/methodinvoke/grpc/MethodInvokeIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/methodinvoke/grpc/MethodInvokeIT.java @@ -112,9 +112,12 @@ public void testInvokeException() throws Exception { DaprException exception = assertThrows(DaprException.class, () -> client.invokeMethod(daprRun.getAppName(), "sleep", req.toByteArray(), HttpExtension.POST).block()); - assertEquals("INTERNAL", exception.getErrorCode()); - assertEquals("INTERNAL: fail to invoke, id: methodinvokeit-methodinvokeservice, err: message is nil", - exception.getMessage()); + // The error messages should be improved once runtime has standardized error serialization in the API. + // This message is not ideal but last time it was improved, there was side effects reported by users. + // If this test fails, there might be a regression in runtime (like we had in 1.10.0). + // The expectations below are as per 1.9 release and (later on) hotfixed in 1.10. + assertEquals("UNKNOWN", exception.getErrorCode()); + assertEquals("UNKNOWN: ", exception.getMessage()); } } }