You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tz...@apache.org on 2021/08/11 11:59:05 UTC
[flink-statefun] 02/02: [hotfix] [e2e] Simplify target function id
creation in Java smoke E2E
This is an automated email from the ASF dual-hosted git repository.
tzulitai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git
commit 8c31f5dec5d11b383f1289767a737774f33d9fb8
Author: Tzu-Li (Gordon) Tai <tz...@apache.org>
AuthorDate: Wed Aug 11 18:19:52 2021 +0800
[hotfix] [e2e] Simplify target function id creation in Java smoke E2E
---
.../e2e/smoke/java/CommandInterpreter.java | 10 ++----
.../smoke/java/CommandInterpreterAppServer.java | 3 +-
.../apache/flink/statefun/e2e/smoke/java/Ids.java | 38 ----------------------
.../e2e/smoke/java/SmokeVerificationJavaE2E.java | 7 ++--
.../src/test/resources/Dockerfile.remote-function | 4 +--
5 files changed, 8 insertions(+), 54 deletions(-)
diff --git a/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreter.java b/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreter.java
index 7963416..0b1a415 100644
--- a/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreter.java
+++ b/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreter.java
@@ -21,7 +21,6 @@ package org.apache.flink.statefun.e2e.smoke.java;
import static org.apache.flink.statefun.e2e.smoke.java.Constants.*;
import java.time.Duration;
-import java.util.Objects;
import org.apache.flink.statefun.e2e.smoke.generated.Command;
import org.apache.flink.statefun.e2e.smoke.generated.Commands;
import org.apache.flink.statefun.e2e.smoke.generated.VerificationResult;
@@ -32,13 +31,8 @@ import org.apache.flink.statefun.sdk.java.message.Message;
import org.apache.flink.statefun.sdk.java.message.MessageBuilder;
public final class CommandInterpreter {
- private final Ids ids;
private static final Duration sendAfterDelay = Duration.ofMillis(1);
- public CommandInterpreter(Ids ids) {
- this.ids = Objects.requireNonNull(ids);
- }
-
public void interpret(ValueSpec<Long> state, Context context, Message message) {
if (message.is(SOURCE_COMMAND_TYPE)) {
interpret(state, context, message.as(SOURCE_COMMAND_TYPE).getCommands());
@@ -95,7 +89,7 @@ public final class CommandInterpreter {
private void sendAfter(
@SuppressWarnings("unused") ValueSpec<Long> state, Context context, Command.SendAfter send) {
- String id = ids.idOf(send.getTarget());
+ String id = Integer.toString(send.getTarget());
Address targetAddress = new Address(CMD_INTERPRETER_FN, id);
Message message =
MessageBuilder.forAddress(targetAddress)
@@ -106,7 +100,7 @@ public final class CommandInterpreter {
private void send(
@SuppressWarnings("unused") ValueSpec<Long> state, Context context, Command.Send send) {
- String id = ids.idOf(send.getTarget());
+ String id = Integer.toString(send.getTarget());
Address targetAddress = new Address(CMD_INTERPRETER_FN, id);
Message message =
MessageBuilder.forAddress(targetAddress)
diff --git a/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreterAppServer.java b/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreterAppServer.java
index c43dc01..6e512f5 100644
--- a/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreterAppServer.java
+++ b/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/CommandInterpreterAppServer.java
@@ -29,8 +29,7 @@ public class CommandInterpreterAppServer {
public static final int PORT = 8000;
public static void main(String[] args) {
- final int numInstances = Integer.parseInt(args[0]);
- final CommandInterpreter interpreter = new CommandInterpreter(new Ids(numInstances));
+ final CommandInterpreter interpreter = new CommandInterpreter();
final StatefulFunctionSpec FN_SPEC =
StatefulFunctionSpec.builder(CMD_INTERPRETER_FN)
.withSupplier(() -> new CommandInterpreterFn(interpreter))
diff --git a/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/Ids.java b/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/Ids.java
deleted file mode 100644
index 7f0937e..0000000
--- a/statefun-e2e-tests/statefun-smoke-e2e-java/src/main/java/org/apache/flink/statefun/e2e/smoke/java/Ids.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.flink.statefun.e2e.smoke.java;
-
-final class Ids {
- private final String[] cache;
-
- public Ids(int maxIds) {
- this.cache = createIds(maxIds);
- }
-
- public String idOf(int address) {
- return cache[address];
- }
-
- private static String[] createIds(int maxIds) {
- String[] ids = new String[maxIds];
- for (int i = 0; i < maxIds; i++) {
- ids[i] = Integer.toString(i);
- }
- return ids;
- }
-}
diff --git a/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/java/org/apache/flink/statefun/e2e/smoke/java/SmokeVerificationJavaE2E.java b/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/java/org/apache/flink/statefun/e2e/smoke/java/SmokeVerificationJavaE2E.java
index 3e2fb1d..3d34da5 100644
--- a/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/java/org/apache/flink/statefun/e2e/smoke/java/SmokeVerificationJavaE2E.java
+++ b/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/java/org/apache/flink/statefun/e2e/smoke/java/SmokeVerificationJavaE2E.java
@@ -42,7 +42,7 @@ public class SmokeVerificationJavaE2E {
parameters.setMessageCount(100_000);
parameters.setMaxFailures(1);
- GenericContainer<?> remoteFunction = configureRemoteFunction(parameters);
+ GenericContainer<?> remoteFunction = configureRemoteFunction();
StatefulFunctionsAppContainers.Builder builder =
StatefulFunctionsAppContainers.builder("flink-statefun-cluster", NUM_WORKERS)
@@ -52,7 +52,7 @@ public class SmokeVerificationJavaE2E {
SmokeRunner.run(parameters, builder);
}
- private GenericContainer<?> configureRemoteFunction(SmokeRunnerParameters parameters) {
+ private GenericContainer<?> configureRemoteFunction() {
Path targetDirPath = Paths.get(System.getProperty("user.dir") + "/target/");
ImageFromDockerfile remoteFunctionImage =
new ImageFromDockerfile("remote-function-image")
@@ -61,7 +61,6 @@ public class SmokeVerificationJavaE2E {
return new GenericContainer<>(remoteFunctionImage)
.withNetworkAliases("remote-function-host")
- .withLogConsumer(new Slf4jLogConsumer(LOG))
- .withEnv("NUM_FN_INSTANCES", Integer.toString(parameters.getNumberOfFunctionInstances()));
+ .withLogConsumer(new Slf4jLogConsumer(LOG));
}
}
diff --git a/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/resources/Dockerfile.remote-function b/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/resources/Dockerfile.remote-function
index 90302cf..1738665 100644
--- a/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/resources/Dockerfile.remote-function
+++ b/statefun-e2e-tests/statefun-smoke-e2e-java/src/test/resources/Dockerfile.remote-function
@@ -18,7 +18,7 @@ FROM openjdk:8
RUN mkdir -p /app
WORKDIR /app
-COPY statefun-smoke-e2e-*-jar-with-dependencies.jar /app/
+COPY statefun-smoke-e2e-java-*-jar-with-dependencies.jar /app/
EXPOSE 8000
-CMD java -jar /app/statefun-smoke-e2e-*-jar-with-dependencies.jar "${NUM_FN_INSTANCES}"
+CMD java -jar /app/statefun-smoke-e2e-*-jar-with-dependencies.jar