End-to-end testing framework for Apache Flink stream processing with classloader behavior validation.
npx @tessl/cli install tessl/maven-org-apache-flink--flink-end-to-end-tests-2-11@1.4.0The Flink End-to-End Tests module provides specialized testing utilities for validating Apache Flink's classloader behavior and resolution order settings. This package is designed for end-to-end integration testing scenarios, specifically focusing on verifying that Flink's classloader isolation and resolution mechanisms work correctly across different deployment environments.
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-end-to-end-tests_2.11</artifactId>
<version>1.4.2</version>
</dependency>// Main test classes
import org.apache.flink.streaming.tests.ClassLoaderTestProgram;
import org.apache.flink.runtime.taskmanager.TaskManager;
// Required Flink API imports for streaming execution
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.core.fs.FileSystem;
// Standard Java imports for resource handling
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;// Run as a command-line application with required parameters
java -cp ClassLoaderTestProgram.jar org.apache.flink.streaming.tests.ClassLoaderTestProgram \
--resolve-order parent-first \
--output /path/to/output/file
// Or programmatically execute the main method
String[] args = {"--resolve-order", "child-first", "--output", "/tmp/test-results.txt"};
ClassLoaderTestProgram.main(args);The testing framework is built around a clever classloader validation mechanism:
.version.properties filesThe test works by attempting to call a method (getMessage()) that exists only in the fake TaskManager class. With parent-first classloading, Flink's real TaskManager is loaded (which lacks this method, causing NoSuchMethodError). With child-first classloading, the fake TaskManager is loaded (allowing the method call to succeed).
Main test program that validates Flink's classloader resolution order settings through a streaming job execution.
public class ClassLoaderTestProgram {
/**
* Entry point for the classloader test program.
* Creates and executes a Flink streaming job that validates classloader behavior.
*
* @param args String array of command line arguments containing:
* --resolve-order: "parent-first" or "child-first" (required)
* --output: Output file path for test results (required)
*
* @throws Exception If execution fails, invalid parameters provided, or streaming job execution fails
* @throws RuntimeException If resolve-order is invalid or unexpected classloader behavior occurs
*/
public static void main(String[] args) throws Exception;
}Usage Example:
// Test parent-first classloader behavior
String[] parentFirstArgs = {
"--resolve-order", "parent-first",
"--output", "/tmp/parent-first-results.txt"
};
ClassLoaderTestProgram.main(parentFirstArgs);
// Test child-first classloader behavior
String[] childFirstArgs = {
"--resolve-order", "child-first",
"--output", "/tmp/child-first-results.txt"
};
ClassLoaderTestProgram.main(childFirstArgs);Fake TaskManager class used for classloader behavior validation, providing a method that doesn't exist in Flink's real TaskManager.
public class TaskManager {
/**
* Test method used to validate child-first classloader behavior.
* This method only exists in the test TaskManager, not in Flink's real TaskManager.
*
* @return String Always returns "Hello, World!" when child-first classloading is active
* @throws NoSuchMethodError When parent-first classloading is active (expected behavior)
*/
public static String getMessage();
}Usage Example:
// This will work only with child-first classloading
try {
String message = TaskManager.getMessage();
System.out.println("Child-first loading successful: " + message);
} catch (NoSuchMethodError e) {
System.out.println("Parent-first loading detected");
}.version.properties from classpathTaskManager.getMessage() methodThe test program handles several error conditions:
--resolve-order or --output parameters are missingRuntimeException for resolve-order values other than "parent-first" or "child-first"RuntimeException if parent-first loading doesn't produce expected NoSuchMethodErrorRuntimeException if child-first loading returns incorrect message from fake TaskManagerTest execution produces structured output in the format:
[BEHAVIOR_INDICATOR]:[GIT_URL]:[ORDERED_PROPERTIES]Where:
BEHAVIOR_INDICATOR: Either "NoSuchMethodError" (parent-first) or "Hello, World!" (child-first)GIT_URL: Git repository URL from .version.propertiesORDERED_PROPERTIES: Concatenated git URLs from all classpath .version.properties resourcesThe package provides specialized Maven configuration for creating executable JARs:
.version.properties resource fileThis module is essential for maintaining the reliability and consistency of Flink applications across different deployment environments and ensuring proper isolation of user code from Flink's internal dependencies.