Commit 78ec6f7
committed
[SPARK-55173][K8S][TESTS] Improve K8s IT to use
### What changes were proposed in this pull request?
This PR aims to improve K8s integration tests by refactoring
- To re-use `TestConstants` consistently, e.g., `"minikube"` -> `BACKEND_MINIKUBE` and `"docker-desktop"` -> `BACKEND_DOCKER_DESKTOP`.
- To use `match` syntax (instead of `if` statement) for extensibility.
```scala
- val storageClassName = if (testBackend == MinikubeTestBackend) "standard" else "hostpath"
- val hostname = if (testBackend == MinikubeTestBackend) "minikube" else "docker-desktop"
+ val (storageClassName, hostname) = testBackend match {
+ case MinikubeTestBackend => ("standard", BACKEND_MINIKUBE)
+ case DockerForDesktopBackend => ("hostpath", BACKEND_DOCKER_DESKTOP)
+ case _ => ("hostpath", BACKEND_DOCKER_DESKTOP)
+ }
```
### Why are the changes needed?
This helps us maintain the test backend consistently and add a new backend easily.
### Does this PR introduce _any_ user-facing change?
No, this is a test-only change.
### How was this patch tested?
Pass the CIs with the existing test cases.
Manually check the previous code patterns like the following.
**BEFORE**
```
$ git grep 'testBackend ==' | wc -l
4
```
```
$ git grep "docker-desktop" | grep scala
resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/PVTestsSuite.scala: val hostname = if (testBackend == MinikubeTestBackend) "minikube" else "docker-desktop"
resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/TestConstants.scala: val BACKEND_DOCKER_DESKTOP = "docker-desktop"
```
**AFTER**
```
$ git grep 'testBackend ==' | wc -l
0
```
```
$ git grep "docker-desktop" | grep scala
resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/TestConstants.scala: val BACKEND_DOCKER_DESKTOP = "docker-desktop"
```
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #53956 from dongjoon-hyun/SPARK-55173.
Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>TestConstants consistently and match syntax for extensibility1 parent 03dedbb commit 78ec6f7
File tree
3 files changed
+17
-5
lines changed- resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest
- backend/minikube
3 files changed
+17
-5
lines changedLines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
33 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
151 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
0 commit comments