This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 07ff073  [SPARK-49625] Add `SparkCluster` state transition test
07ff073 is described below

commit 07ff073b358e4f3b70c66c629f17d79625e534d3
Author: Qi Tan <[email protected]>
AuthorDate: Thu Sep 12 20:42:23 2024 -0700

    [SPARK-49625] Add `SparkCluster` state transition test
    
    ### What changes were proposed in this pull request?
    Add e2e for Spark Cluster Happy State Transition Test
    
    ### Why are the changes needed?
    To simulate real user experiences
    
    ### Does this PR introduce _any_ user-facing change?
    no
    
    ### How was this patch tested?
    test locally
    
    ### Was this patch authored or co-authored using generative AI tooling?
    no
    
    Closes #122 from TQJADE/spark-cluster-state-transtition.
    
    Authored-by: Qi Tan <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../spark-cluster-state-transition.yaml            | 27 ++++++++++++++++
 tests/e2e/state-transition/chainsaw-test.yaml      | 37 +++++++++++++++++++---
 .../spark-cluster-example-succeeded.yaml           | 33 +++++++++++++++++++
 3 files changed, 93 insertions(+), 4 deletions(-)

diff --git 
a/tests/e2e/assertions/spark-cluster/spark-cluster-state-transition.yaml 
b/tests/e2e/assertions/spark-cluster/spark-cluster-state-transition.yaml
new file mode 100644
index 0000000..4194583
--- /dev/null
+++ b/tests/e2e/assertions/spark-cluster/spark-cluster-state-transition.yaml
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+apiVersion: spark.apache.org/v1alpha1
+kind: SparkCluster
+metadata:
+  name: spark-cluster-succeeded-test
+  namespace: ($SPARK_APP_NAMESPACE)
+status:
+  stateTransitionHistory:
+    (*.currentStateSummary):
+      - "Submitted"
+      - "RunningHealthy"
diff --git a/tests/e2e/state-transition/chainsaw-test.yaml 
b/tests/e2e/state-transition/chainsaw-test.yaml
index 46f5c1f..6e95b69 100644
--- a/tests/e2e/state-transition/chainsaw-test.yaml
+++ b/tests/e2e/state-transition/chainsaw-test.yaml
@@ -18,22 +18,26 @@
 apiVersion: chainsaw.kyverno.io/v1alpha1
 kind: Test
 metadata:
-  name: spark-operator-spark-application-state-transition-validation
+  name: spark-operator-state-transition-validation
 spec:
   scenarios:
   - bindings:
       - name: TEST_NAME
         value: succeeded
-      - name: FILE_NAME
+      - name: APPLICATION_FILE_NAME
         value: spark-example-succeeded.yaml
+      - name: CLUSTER_FILE_NAME
+        value: spark-cluster-example-succeeded.yaml
       - name: SPARK_APPLICATION_NAME
         value: spark-job-succeeded-test
+      - name: SPARK_CLUSTER_NAME
+        value: spark-cluster-succeeded-test
   steps:
   - try:
     - script:
         env:
           - name: FILE_NAME
-            value: ($FILE_NAME)
+            value: ($APPLICATION_FILE_NAME)
         content: kubectl apply -f $FILE_NAME
     - assert:
         bindings:
@@ -53,4 +57,29 @@ spec:
             value: ($SPARK_APPLICATION_NAME)
         timeout: 30s
         content: |
-          kubectl delete sparkapplication $SPARK_APPLICATION_NAME
\ No newline at end of file
+          kubectl delete sparkapplication $SPARK_APPLICATION_NAME
+  - try:
+    - script:
+        env:
+          - name: FILE_NAME
+            value: ($CLUSTER_FILE_NAME)
+        content: kubectl apply -f $FILE_NAME
+    - assert:
+        bindings:
+          - name: SPARK_APP_NAMESPACE
+            value: default
+        timeout: 60s
+        file: "../assertions/spark-cluster/spark-cluster-state-transition.yaml"
+    catch:
+    - describe:
+        apiVersion: spark.apache.org/v1alpha1
+        kind: SparkCluster
+        namespace: default
+    finally:
+      - script:
+          env:
+            - name: SPARK_CLUSTER_NAME
+              value: ($SPARK_CLUSTER_NAME)
+          timeout: 30s
+          content: |
+            kubectl delete sparkcluster $SPARK_CLUSTER_NAME
diff --git a/tests/e2e/state-transition/spark-cluster-example-succeeded.yaml 
b/tests/e2e/state-transition/spark-cluster-example-succeeded.yaml
new file mode 100644
index 0000000..f36b286
--- /dev/null
+++ b/tests/e2e/state-transition/spark-cluster-example-succeeded.yaml
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: spark.apache.org/v1alpha1
+kind: SparkCluster
+metadata:
+  name: spark-cluster-succeeded-test
+  namespace: default
+spec:
+  runtimeVersions:
+    sparkVersion: "4.0.0-preview1"
+  clusterTolerations:
+    instanceConfig:
+      initWorkers: 1
+      minWorkers: 1
+      maxWorkers: 1
+  sparkConf:
+    spark.kubernetes.container.image: "spark:4.0.0-preview1"
+    spark.master.ui.title: "Spark Cluster E2E Test"
+    spark.master.rest.enabled: "true"
+    spark.master.rest.host: "0.0.0.0"
+    spark.ui.reverseProxy: "true"
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to