public class PackagedProgramEndToEndITCase {
@Test
public void testEverything() {
NepheleMiniCluster cluster = new NepheleMiniCluster();
File points = null;
File clusters = null;
File outFile = null;
try {
// set up the files
points = File.createTempFile("kmeans_points", ".in");
clusters = File.createTempFile("kmeans_clusters", ".in");
outFile = File.createTempFile("kmeans_result", ".out");
outFile.delete();
FileWriter fwPoints = new FileWriter(points);
fwPoints.write(KMeansData.DATAPOINTS);
fwPoints.close();
FileWriter fwClusters = new FileWriter(clusters);
fwClusters.write(KMeansData.INITIAL_CENTERS);
fwClusters.close();
String jarPath = "target/maven-test-jar.jar";
// run KMeans
cluster.setNumTaskManager(2);
cluster.setTaskManagerNumSlots(2);
cluster.start();
RemoteExecutor ex = new RemoteExecutor("localhost", cluster.getJobManagerRpcPort());
ex.executeJar(jarPath,
"org.apache.flink.test.util.testjar.KMeansForTest",
new String[] {
points.toURI().toString(),
clusters.toURI().toString(),
outFile.toURI().toString(),
"25"});
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
finally {
if (points != null) {
points.delete();
}
if (cluster != null) {
clusters.delete();
}
if (outFile != null) {
outFile.delete();
}
try {
cluster.stop();
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}