Skip to content

Commit

Permalink
Add test for ZEPPELIN-5962
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzhao committed Sep 15, 2023
1 parent a87ecf6 commit c67a1a3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;

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

CreateSessionRequest(String kind, String user, Map<String, String> conf, Map<String, String> params) {
CreateSessionRequest(String kind, String user, Map<String, String> conf,
Map<String, String> params) {
this.kind = kind;
this.user = user;
this.conf = conf;
Expand Down
36 changes: 36 additions & 0 deletions livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,42 @@ public void run() {
}
}

@Test
public void testLivyParams() throws InterpreterException {
if (!checkPreCondition()) {
return;
}
InterpreterGroup interpreterGroup = new InterpreterGroup("group_1");
interpreterGroup.put("session_1", new ArrayList<Interpreter>());
Properties props = new Properties(properties);
props.setProperty("livy.spark.executor.cores", "4");
props.setProperty("livy.name", "zeppelin-livy");
LivySparkInterpreter sparkInterpreter = new LivySparkInterpreter(props);
sparkInterpreter.setInterpreterGroup(interpreterGroup);
interpreterGroup.get("session_1").add(sparkInterpreter);
AuthenticationInfo authInfo = new AuthenticationInfo("user1");
MyInterpreterOutputListener outputListener = new MyInterpreterOutputListener();
InterpreterOutput output = new InterpreterOutput(outputListener);
InterpreterContext context = InterpreterContext.builder()
.setNoteId("noteId")
.setParagraphId("paragraphId")
.setAuthenticationInfo(authInfo)
.setInterpreterOut(output)
.build();
sparkInterpreter.open();

try {
InterpreterResult result = sparkInterpreter.interpret("sc.version\n" +
"assert(sc.getConf.get(\"spark.executor.cores\") == \"4\" && " +
"sc.getConf.get(\"spark.app.name\") == \"zeppelin-livy\")"
, context);
assertEquals(result.toString(), InterpreterResult.Code.SUCCESS, result.code());
assertEquals(1, result.message().size());
} finally {
sparkInterpreter.close();
}
}

@Test
public void testLivyTutorialNote() throws IOException, InterpreterException {
if (!checkPreCondition()) {
Expand Down

0 comments on commit c67a1a3

Please sign in to comment.