Skip to content

Commit 1741985

Browse files
TQJADEdongjoon-hyun
authored andcommitted
[SPARK-49468] Add Hot Properties Reload Test
### What changes were proposed in this pull request? Add one more e2e test to validate the hot properties reload. ### Why are the changes needed? 1. It will verify Spark Operator reload the properties from dynamic config map 2. It will verify the watched namespace worked as expected ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Test from personal GitHub workflow Actions ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#112, apache#114 Closes apache#115 from TQJADE/hot-properties-test. Authored-by: Qi Tan <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 87920b5 commit 1741985

File tree

9 files changed

+228
-4
lines changed

9 files changed

+228
-4
lines changed

.github/workflows/build_and_test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ jobs:
7373
- spark-versions
7474
- python
7575
- state-transition
76+
dynamic_config_test_group:
77+
- watched-namespaces
7678
steps:
7779
- name: Checkout repository
7880
uses: actions/checkout@v4
@@ -98,7 +100,7 @@ jobs:
98100
run: |
99101
kubectl get pods -A
100102
kubectl describe node
101-
- name: Run Spark K8s Operator on K8S
103+
- name: Run Spark K8s Operator on K8S with Dynamic Configuration Disabled
102104
run: |
103105
kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts || true
104106
eval $(minikube docker-env)
@@ -108,9 +110,22 @@ jobs:
108110
helm test spark-kubernetes-operator
109111
# Use remote host' s docker image
110112
minikube docker-env --unset
111-
- name: Run E2E Test
113+
- name: Run E2E Test with Dynamic Configuration Disabled
112114
run: |
113115
chainsaw test --test-dir ./tests/e2e/${{ matrix.test_group }} --parallel 2
116+
- name: Run Spark K8s Operator on K8S with Dynamic Configuration Enabled
117+
run: |
118+
helm uninstall spark-kubernetes-operator
119+
eval $(minikube docker-env)
120+
helm install spark-kubernetes-operator --create-namespace -f \
121+
build-tools/helm/spark-kubernetes-operator/values.yaml -f \
122+
tests/e2e/helm/dynamic-config-values.yaml \
123+
build-tools/helm/spark-kubernetes-operator/
124+
minikube docker-env --unset
125+
- name: Run E2E Test with Dynamic Configuration Enabled
126+
run: |
127+
chainsaw test --test-dir ./tests/e2e/${{ matrix.dynamic_config_test_group }} --parallel 2
128+
114129
lint:
115130
name: "Linter and documentation"
116131
runs-on: ubuntu-latest

build-tools/helm/spark-kubernetes-operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ operatorConfiguration:
188188
"helm.sh/resource-policy": keep
189189
data:
190190
# Spark Operator Config Runtime Properties Overrides. e.g.
191-
spark.kubernetes.operator.reconciler.intervalSeconds: 60
191+
spark.kubernetes.operator.reconciler.intervalSeconds: "60"

tests/e2e/assertions/spark-application/spark-state-transition.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ apiVersion: spark.apache.org/v1alpha1
1919
kind: SparkApplication
2020
metadata:
2121
name: spark-job-succeeded-test
22-
namespace: default
22+
namespace: ($SPARK_APP_NAMESPACE)
2323
status:
2424
stateTransitionHistory:
2525
(*.currentStateSummary):
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
appResources:
17+
namespaces:
18+
overrideWatchedNamespaces: false
19+
data:
20+
- "spark-1"
21+
- "spark-2"
22+
role:
23+
create: true
24+
roleBinding:
25+
create: true
26+
27+
operatorConfiguration:
28+
dynamicConfig:
29+
enable: true
30+
create: true
31+
data:
32+
spark.kubernetes.operator.watchedNamespaces: "default"

tests/e2e/state-transition/chainsaw-test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ spec:
3636
value: ($FILE_NAME)
3737
content: kubectl apply -f $FILE_NAME
3838
- assert:
39+
bindings:
40+
- name: SPARK_APP_NAMESPACE
41+
value: default
3942
timeout: 60s
4043
file: "../assertions/spark-application/spark-state-transition.yaml"
4144
catch:
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
apiVersion: chainsaw.kyverno.io/v1alpha1
19+
kind: Test
20+
metadata:
21+
name: spark-operator-dynamic-configuration-validation
22+
spec:
23+
steps:
24+
- try:
25+
- apply:
26+
file: spark-operator-dynamic-config-1.yaml
27+
- sleep:
28+
duration: 30s
29+
- script:
30+
content:
31+
kubectl logs -n default $(kubectl get pods -o=name -l app.kubernetes.io/component=operator-deployment,app.kubernetes.io/name=spark-kubernetes-operator)
32+
check:
33+
(contains($stdout, 'Updating operator namespaces to [default, spark-1]')): true
34+
- apply:
35+
bindings:
36+
- name: SPARK_APP_NAMESPACE
37+
value: spark-1
38+
file: spark-example.yaml
39+
- assert:
40+
bindings:
41+
- name: SPARK_APP_NAMESPACE
42+
value: spark-1
43+
timeout: 60s
44+
file: "../assertions/spark-application/spark-state-transition.yaml"
45+
- apply:
46+
bindings:
47+
- name: SPARK_APP_NAMESPACE
48+
value: spark-2
49+
file: spark-example.yaml
50+
- sleep:
51+
duration: 60s
52+
- script:
53+
content:
54+
kubectl get sparkapplication spark-job-succeeded-test -n spark-2 -o json | jq ".status"
55+
check:
56+
(contains($stdout, 'null')): true
57+
catch:
58+
- podLogs:
59+
namespace: default
60+
selector: app.kubernetes.io/component=operator-deployment,app.kubernetes.io/name=spark-kubernetes-operator
61+
- describe:
62+
apiVersion: spark.apache.org/v1alpha1
63+
kind: SparkApplication
64+
namespace: spark-1
65+
- describe:
66+
apiVersion: spark.apache.org/v1alpha1
67+
kind: SparkApplication
68+
namespace: spark-2
69+
finally:
70+
- script:
71+
content: |
72+
kubectl delete sparkapplication spark-job-succeeded-test -n spark-1 --ignore-not-found=true
73+
kubectl delete sparkapplication spark-job-succeeded-test -n spark-2 --ignore-not-found=true
74+
kubectl replace -f spark-operator-dynamic-config-2.yaml
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
apiVersion: spark.apache.org/v1alpha1
19+
kind: SparkApplication
20+
metadata:
21+
name: spark-job-succeeded-test
22+
namespace: ($SPARK_APP_NAMESPACE)
23+
spec:
24+
mainClass: "org.apache.spark.examples.SparkPi"
25+
jars: "local:///opt/spark/examples/jars/spark-examples_2.13-4.0.0-preview1.jar"
26+
sparkConf:
27+
spark.executor.instances: "1"
28+
spark.kubernetes.container.image: "spark:4.0.0-preview1-scala2.13-java17-ubuntu"
29+
spark.kubernetes.authenticate.driver.serviceAccountName: "spark"
30+
runtimeVersions:
31+
sparkVersion: 4.0.0-preview1
32+
scalaVersion: "2.13"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
apiVersion: v1
19+
data:
20+
spark.kubernetes.operator.watchedNamespaces: default, spark-1
21+
kind: ConfigMap
22+
metadata:
23+
annotations:
24+
helm.sh/resource-policy: keep
25+
meta.helm.sh/release-name: spark-kubernetes-operator
26+
meta.helm.sh/release-namespace: default
27+
labels:
28+
app.kubernetes.io/component: operator-dynamic-config-overrides
29+
app.kubernetes.io/managed-by: Helm
30+
app.kubernetes.io/name: spark-kubernetes-operator
31+
app.kubernetes.io/version: 0.1.0-SNAPSHOT
32+
helm.sh/chart: spark-kubernetes-operator-0.1.0-SNAPSHOT
33+
name: spark-kubernetes-operator-dynamic-configuration
34+
namespace: default
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
apiVersion: v1
19+
data:
20+
spark.kubernetes.operator.watchedNamespaces: default
21+
kind: ConfigMap
22+
metadata:
23+
annotations:
24+
helm.sh/resource-policy: keep
25+
meta.helm.sh/release-name: spark-kubernetes-operator
26+
meta.helm.sh/release-namespace: default
27+
labels:
28+
app.kubernetes.io/component: operator-dynamic-config-overrides
29+
app.kubernetes.io/managed-by: Helm
30+
app.kubernetes.io/name: spark-kubernetes-operator
31+
app.kubernetes.io/version: 0.1.0-SNAPSHOT
32+
helm.sh/chart: spark-kubernetes-operator-0.1.0-SNAPSHOT
33+
name: spark-kubernetes-operator-dynamic-configuration
34+
namespace: default

0 commit comments

Comments
 (0)