This commit is contained in:
Lee moon soo 2016-03-23 11:40:37 -07:00
parent aa35a83a8a
commit dcfee3210c
2 changed files with 31 additions and 1 deletions

View file

@ -60,6 +60,7 @@ public abstract class AbstractTestRestApi {
static final String url = getUrlToTest();
protected static final boolean wasRunning = checkIfServerIsRunning();
static boolean pySpark = false;
static boolean sparkR = false;
private String getUrl(String path) {
String url;
@ -132,7 +133,7 @@ public abstract class AbstractTestRestApi {
// set spark home for pyspark
sparkIntpSetting.getProperties().setProperty("spark.home", getSparkHome());
pySpark = true;
sparkR = true;
ZeppelinServer.notebook.getInterpreterFactory().restart(sparkIntpSetting.id());
} else {
// assume first one is spark
@ -148,6 +149,7 @@ public abstract class AbstractTestRestApi {
// set spark home for pyspark
sparkIntpSetting.getProperties().setProperty("spark.home", sparkHome);
pySpark = true;
sparkR = true;
}
ZeppelinServer.notebook.getInterpreterFactory().restart(sparkIntpSetting.id());
@ -174,6 +176,10 @@ public abstract class AbstractTestRestApi {
return pySpark;
}
boolean isSparkR() {
return sparkR;
}
private static String getSparkHomeRecursively(File dir) {
if (dir == null) return null;
File files [] = dir.listFiles();

View file

@ -83,6 +83,30 @@ public class ZeppelinSparkClusterTest extends AbstractTestRestApi {
ZeppelinServer.notebook.removeNote(note.id());
}
@Test
public void sparkRTest() throws IOException {
// create new note
Note note = ZeppelinServer.notebook.createNote();
int sparkVersion = getSparkVersionNumber(note);
if (isPyspark() && sparkVersion >= 14) { // sparkr supported from 1.4.0
// run markdown paragraph, again
Paragraph p = note.addParagraph();
Map config = p.getConfig();
config.put("enabled", true);
p.setConfig(config);
p.setText("%r localDF <- data.frame(name=c(\"a\", \"b\", \"c\"), age=c(19, 23, 18))\n" +
"df <- createDataFrame(sqlContext, localDF)\n" +
"count(df)"
);
note.run(p.getId());
waitForFinish(p);
assertEquals(Status.FINISHED, p.getStatus());
assertEquals("[1] 3\n", p.getResult().message());
}
ZeppelinServer.notebook.removeNote(note.id());
}
@Test
public void pySparkTest() throws IOException {
// create new note