Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Chen <github@chenyicn.net>
  • Loading branch information
ChenYi015 committed Sep 10, 2024
1 parent 976471c commit ed1d525
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions test/e2e/sparkapplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/yaml"

"github.com/kubeflow/spark-operator/api/v1beta2"
"github.com/kubeflow/spark-operator/pkg/common"
"github.com/kubeflow/spark-operator/pkg/util"
)

Expand Down Expand Up @@ -130,13 +132,41 @@ var _ = Describe("Example SparkApplication", func() {
}
})

It("Should complete successfully", func() {
It("Should complete successfully with configmap mounted", func() {
By("Waiting for SparkApplication to complete")
key := types.NamespacedName{Namespace: app.Namespace, Name: app.Name}
Expect(waitForSparkApplicationCompleted(ctx, key)).NotTo(HaveOccurred())

By("Checking out driver logs")
By("Checking out whether volumes are mounted to driver pod")
driverPodName := util.GetDriverPodName(app)
driverPodKey := types.NamespacedName{Namespace: app.Namespace, Name: driverPodName}
driverPod := &corev1.Pod{}
Expect(k8sClient.Get(ctx, driverPodKey, driverPod)).NotTo(HaveOccurred())
hasVolumes := false
hasVolumeMounts := false
for _, volume := range app.Spec.Volumes {
for _, podVolume := range driverPod.Spec.Volumes {
if equality.Semantic.DeepEqual(volume, podVolume) {
hasVolumes = true
}
}
}
for _, volumeMount := range app.Spec.Driver.VolumeMounts {
for _, container := range driverPod.Spec.Containers {
if container.Name != common.SparkDriverContainerName {
continue
}
for _, podVolumeMount := range container.VolumeMounts {
if equality.Semantic.DeepEqual(volumeMount, podVolumeMount) {
hasVolumeMounts = true
}
}
}
}
Expect(hasVolumes).To(BeTrue())
Expect(hasVolumeMounts).To(BeTrue())

By("Checking out driver logs")
bytes, err := clientset.CoreV1().Pods(app.Namespace).GetLogs(driverPodName, &corev1.PodLogOptions{}).Do(ctx).Raw()
Expect(err).NotTo(HaveOccurred())
Expect(bytes).NotTo(BeEmpty())
Expand Down Expand Up @@ -176,8 +206,22 @@ var _ = Describe("Example SparkApplication", func() {
key := types.NamespacedName{Namespace: app.Namespace, Name: app.Name}
Expect(waitForSparkApplicationCompleted(ctx, key)).NotTo(HaveOccurred())

By("Checking out driver logs")
By("Checking out whether resource requests and limits of driver pod are set")
driverPodName := util.GetDriverPodName(app)
driverPodKey := types.NamespacedName{Namespace: app.Namespace, Name: driverPodName}
driverPod := &corev1.Pod{}
Expect(k8sClient.Get(ctx, driverPodKey, driverPod)).NotTo(HaveOccurred())
for _, container := range driverPod.Spec.Containers {
if container.Name != common.SparkDriverContainerName {
continue
}
Expect(container.Resources.Requests.Cpu).NotTo(BeNil())
Expect(container.Resources.Requests.Memory).NotTo(BeNil())
Expect(container.Resources.Limits.Cpu).NotTo(BeNil())
Expect(container.Resources.Limits.Memory).NotTo(BeNil())
}

By("Checking out driver logs")
bytes, err := clientset.CoreV1().Pods(app.Namespace).GetLogs(driverPodName, &corev1.PodLogOptions{}).Do(ctx).Raw()
Expect(err).NotTo(HaveOccurred())
Expect(bytes).NotTo(BeEmpty())
Expand Down

0 comments on commit ed1d525

Please sign in to comment.