Skip to content

Commit 394bdb9

Browse files
committed
Add unit test
1 parent 3741f96 commit 394bdb9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/SparkAppSubmissionWorkerTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,20 @@ void generatedSparkAppIdShouldComplyLengthLimit() {
219219
String appId = SparkAppSubmissionWorker.generateSparkAppId(mockApp);
220220
assertTrue(appId.length() <= DEFAULT_ID_LENGTH_LIMIT);
221221
}
222+
223+
@Test
224+
void checkAppIdWhenUserSpecifiedInSparkConf() {
225+
SparkApplication mockApp = mock(SparkApplication.class);
226+
ApplicationSpec mockSpec = mock(ApplicationSpec.class);
227+
Map<String, String> appProps = new HashMap<>();
228+
appProps.put("spark.app.id", "foo");
229+
ObjectMeta appMeta = new ObjectMetaBuilder().withName("app1").withNamespace("ns1").build();
230+
when(mockSpec.getSparkConf()).thenReturn(appProps);
231+
when(mockApp.getSpec()).thenReturn(mockSpec);
232+
when(mockApp.getMetadata()).thenReturn(appMeta);
233+
234+
SparkAppSubmissionWorker submissionWorker = new SparkAppSubmissionWorker();
235+
SparkAppDriverConf conf = submissionWorker.buildDriverConf(mockApp, Collections.emptyMap());
236+
assertEquals(conf.appId(), "foo");
237+
}
222238
}

0 commit comments

Comments
 (0)