tzulitai commented on a change in pull request #108:
URL: https://github.com/apache/flink-statefun/pull/108#discussion_r425509272



##########
File path: 
statefun-e2e-tests/statefun-e2e-tests-common/src/main/java/org/apache/flink/statefun/e2e/common/StatefulFunctionsAppContainers.java
##########
@@ -186,124 +148,220 @@ protected void before() throws Throwable {
   protected void after() {
     master.stop();
     workers.forEach(GenericContainer::stop);
-  }
 
-  private static ImageFromDockerfile appImage(
-      String appName,
-      Configuration dynamicProperties,
-      List<ClasspathBuildContextFile> classpathBuildContextFiles) {
-    final Path targetDirPath = Paths.get(System.getProperty("user.dir") + 
"/target/");
-    LOG.info("Building app image with built artifacts located at: {}", 
targetDirPath);
-
-    final ImageFromDockerfile appImage =
-        new ImageFromDockerfile(appName)
-            .withFileFromClasspath("Dockerfile", "Dockerfile")
-            .withFileFromPath(".", targetDirPath);
-
-    Configuration flinkConf = resolveFlinkConf(dynamicProperties);
-    String flinkConfString = flinkConfigAsString(flinkConf);
-    LOG.info(
-        "Resolved Flink configuration after merging dynamic properties with 
base flink-conf.yaml:\n\n{}",
-        flinkConf);
-    appImage.withFileFromString("flink-conf.yaml", flinkConfString);
-
-    for (ClasspathBuildContextFile classpathBuildContextFile : 
classpathBuildContextFiles) {
-      appImage.withFileFromClasspath(
-          classpathBuildContextFile.buildContextPath, 
classpathBuildContextFile.fromResourcePath);
-    }
+    FileUtils.deleteDirectoryQuietly(checkpointDir);
+  }
 
-    return appImage;
+  /** @return the exposed port on master for calling REST APIs. */
+  public int getMasterRestPort() {
+    return master.getMappedPort(8081);
   }
 
   /**
-   * Merges set dynamic properties with configuration in the base 
flink-conf.yaml located in
-   * resources.
+   * Restarts a single worker of this Stateful Functions application.
+   *
+   * @param workerIndex the index of the worker to restart.
    */
-  private static Configuration resolveFlinkConf(Configuration 
dynamicProperties) {
-    final InputStream baseFlinkConfResourceInputStream =
-        
StatefulFunctionsAppContainers.class.getResourceAsStream("/flink-conf.yaml");
-    if (baseFlinkConfResourceInputStream == null) {
-      throw new RuntimeException("Base flink-conf.yaml cannot be found.");
+  public void restartWorker(int workerIndex) {
+    if (workerIndex >= workers.size()) {
+      throw new IndexOutOfBoundsException(
+          "Invalid worker index; valid values are 0 to " + (workers.size() - 
1));
     }
 
-    final File tempBaseFlinkConfFile = 
copyToTempFlinkConfFile(baseFlinkConfResourceInputStream);
-    return GlobalConfiguration.loadConfiguration(
-        tempBaseFlinkConfFile.getParentFile().getAbsolutePath(), 
dynamicProperties);
+    final GenericContainer<?> worker = workers.get(workerIndex);
+    worker.stop();
+    worker.start();
+  }
+
+  private static File temporaryCheckpointDir() throws IOException {

Review comment:
       I thought about that, but testcontainers does not support named volumes, 
only bind mounts. I guess it's because the docker-java API itself doesn't 
support named volumes, and therefore also not supported in Testcontainers which 
is built on top of that.
   
   However, even with named volumes, ideally we still would want to treat them 
as temporary resources that should be deleted after every test run - we don't 
want to be persisting anything beyond the test lifecycle.
   
   So, in that sense, technically there doesn't seem to be a difference in 
using named volumes v.s. bind mounting temp host directories for what we need 
to do here?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to