HwangDongJun commented on code in PR #58187:
URL: https://github.com/apache/spark/pull/58187#discussion_r4345324065
##########
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/ClientSuite.scala:
##########
@@ -180,28 +210,52 @@ class ClientSuite extends SparkFunSuite with
BeforeAndAfter {
when(podOperations.inNamespace(kconf.namespace)).thenReturn(podsWithNamespace)
when(podsWithNamespace.withName(POD_NAME)).thenReturn(namedPods)
+ events.clear()
createdPodArgumentCaptor = ArgumentCaptor.forClass(classOf[Pod])
createdResourcesArgumentCaptor =
ArgumentCaptor.forClass(classOf[Array[HasMetadata]])
- when(podsWithNamespace.resource(fullExpectedPod())).thenReturn(namedPods)
+ patchContextCaptor = ArgumentCaptor.forClass(classOf[PatchContext])
+ patchBodyCaptor = ArgumentCaptor.forClass(classOf[String])
+
when(podsWithNamespace.resource(createdPodArgumentCaptor.capture())).thenReturn(namedPods)
+
when(podOperations.resource(ArgumentMatchers.any[Pod]())).thenReturn(namedPods)
when(resourceList.forceConflicts()).thenReturn(resourceList)
+ when(resourceList.serverSideApply()).thenAnswer(answer {
+ events += "apply"
+ java.util.Collections.emptyList[HasMetadata]()
+ })
+ when(resourceList.delete()).thenAnswer(answer {
+ events += "delete resources"
+ java.util.Collections.emptyList[StatusDetails]()
+ })
when(namedPods.serverSideApply()).thenReturn(podWithOwnerReference())
- when(namedPods.create()).thenReturn(podWithOwnerReference())
+ when(namedPods.create()).thenAnswer(answer {
+ events += "create pod"
+ podWithOwnerReference()
+ })
+ when(namedPods.patch(patchContextCaptor.capture(),
patchBodyCaptor.capture()))
+ .thenAnswer(answer {
+ events += "remove gate"
+ podWithOwnerReference()
+ })
+ when(namedPods.delete()).thenAnswer(answer {
+ events += "delete pod"
+ java.util.Collections.emptyList[StatusDetails]()
+ })
when(namedPods.watch(loggingPodStatusWatcher)).thenReturn(mock[Watch])
val sId = submissionId(kconf.namespace, POD_NAME)
when(loggingPodStatusWatcher.watchOrStop(sId)).thenReturn(true)
- doReturn(resourceList)
- .when(kubernetesClient)
- .resourceList(createdResourcesArgumentCaptor.capture(): _*)
+ resourceListFor = _ => resourceList
+ doAnswer(new Answer[RESOURCE_LIST] {
Review Comment:
Cleaned up:
- the unused `doReturn` helper and the `keyToPaths` parameter of
`podWithOwnerReference` are removed (`fullExpectedPod` still takes `keyToPaths`
for the `SPARK_CONF_DIR` test);
- the `s` prefix at the patch body is removed;
- the `KubernetesDriverSpec(...)` copies became `specWithPod(pod)`, which is
`BUILT_KUBERNETES_SPEC.copy(pod = SparkPod(pod, BUILT_DRIVER_CONTAINER))`;
- the template gate setup and the failing post-resource setup are shared
through `withGates`, `failingWhen` and `useSpec`;
- the `never()` checks that repeated `events` are removed. One
`verify(namedPods, never()).watch(...)` stays, since `events` does not record
`watch`.
The `preResKconf` in the pre-resources test is gone too: that test uses
`kconf` from `before` and only swaps the driver spec (`useSpec`). The one in
the SPARK-37331 test stays, since it is built from a different `SparkConf` and
was already on `master`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]