Skip to content

Commit c67a1a3

Browse files
author
mrzhao
committed
Add test for ZEPPELIN-5962
1 parent a87ecf6 commit c67a1a3

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.google.gson.Gson;
2121
import com.google.gson.GsonBuilder;
22+
import com.google.gson.JsonObject;
2223
import com.google.gson.annotations.SerializedName;
2324

2425
import org.apache.commons.lang3.StringUtils;
@@ -782,7 +783,8 @@ private static class CreateSessionRequest {
782783
public final Map<String, String> conf;
783784
public final Map<String, String> params;
784785

785-
CreateSessionRequest(String kind, String user, Map<String, String> conf, Map<String, String> params) {
786+
CreateSessionRequest(String kind, String user, Map<String, String> conf,
787+
Map<String, String> params) {
786788
this.kind = kind;
787789
this.user = user;
788790
this.conf = conf;

livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,42 @@ public void run() {
643643
}
644644
}
645645

646+
@Test
647+
public void testLivyParams() throws InterpreterException {
648+
if (!checkPreCondition()) {
649+
return;
650+
}
651+
InterpreterGroup interpreterGroup = new InterpreterGroup("group_1");
652+
interpreterGroup.put("session_1", new ArrayList<Interpreter>());
653+
Properties props = new Properties(properties);
654+
props.setProperty("livy.spark.executor.cores", "4");
655+
props.setProperty("livy.name", "zeppelin-livy");
656+
LivySparkInterpreter sparkInterpreter = new LivySparkInterpreter(props);
657+
sparkInterpreter.setInterpreterGroup(interpreterGroup);
658+
interpreterGroup.get("session_1").add(sparkInterpreter);
659+
AuthenticationInfo authInfo = new AuthenticationInfo("user1");
660+
MyInterpreterOutputListener outputListener = new MyInterpreterOutputListener();
661+
InterpreterOutput output = new InterpreterOutput(outputListener);
662+
InterpreterContext context = InterpreterContext.builder()
663+
.setNoteId("noteId")
664+
.setParagraphId("paragraphId")
665+
.setAuthenticationInfo(authInfo)
666+
.setInterpreterOut(output)
667+
.build();
668+
sparkInterpreter.open();
669+
670+
try {
671+
InterpreterResult result = sparkInterpreter.interpret("sc.version\n" +
672+
"assert(sc.getConf.get(\"spark.executor.cores\") == \"4\" && " +
673+
"sc.getConf.get(\"spark.app.name\") == \"zeppelin-livy\")"
674+
, context);
675+
assertEquals(result.toString(), InterpreterResult.Code.SUCCESS, result.code());
676+
assertEquals(1, result.message().size());
677+
} finally {
678+
sparkInterpreter.close();
679+
}
680+
}
681+
646682
@Test
647683
public void testLivyTutorialNote() throws IOException, InterpreterException {
648684
if (!checkPreCondition()) {

0 commit comments

Comments
 (0)