Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Newton <[email protected]>
  • Loading branch information
Tom-Newton committed Oct 13, 2024
1 parent 696a689 commit bc13f30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions test/e2e/sparkapplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ var _ = Describe("Example SparkApplication", func() {
})

It("Fails submission and retries until retries are exhausted", func() {
By("Waiting for SparkApplication to complete")
By("Waiting for SparkApplication to terminate")
key := types.NamespacedName{Namespace: app.Namespace, Name: app.Name}
apps, polling_err := collectStatusesUntilSparkApplicationTerminates(ctx, key)
apps, polling_err := collectSparkApplicationsUntilTermination(ctx, key)
Expect(polling_err).To(HaveOccurred())

By("Should eventually fail")
Expand Down Expand Up @@ -320,9 +320,9 @@ var _ = Describe("Example SparkApplication", func() {
})

It("Application fails and retries until retries are exhausted", func() {
By("Waiting for SparkApplication to complete")
By("Waiting for SparkApplication to terminate")
key := types.NamespacedName{Namespace: app.Namespace, Name: app.Name}
apps, polling_err := collectStatusesUntilSparkApplicationTerminates(ctx, key)
apps, polling_err := collectSparkApplicationsUntilTermination(ctx, key)
Expect(polling_err).To(HaveOccurred())

By("Should eventually fail")
Expand Down
10 changes: 4 additions & 6 deletions test/e2e/suit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ func waitForSparkApplicationCompleted(ctx context.Context, key types.NamespacedN
return false, err
}
switch app.Status.AppState.State {
case v1beta2.ApplicationStateFailed:
// TODO: Try combining this case with the one below.
return true, errors.New(app.Status.AppState.ErrorMessage)
case v1beta2.ApplicationStateFailedSubmission, v1beta2.ApplicationStateFailed:
return false, errors.New(app.Status.AppState.ErrorMessage)
case v1beta2.ApplicationStateCompleted:
return true, nil
}
Expand All @@ -273,13 +272,12 @@ func waitForSparkApplicationCompleted(ctx context.Context, key types.NamespacedN
return err
}


func collectStatusesUntilSparkApplicationTerminates(ctx context.Context, key types.NamespacedName) ([]v1beta2.SparkApplication, error) {
func collectSparkApplicationsUntilTermination(ctx context.Context, key types.NamespacedName) ([]v1beta2.SparkApplication, error) {
cancelCtx, cancelFunc := context.WithTimeout(ctx, WaitTimeout)
defer cancelFunc()

apps := []v1beta2.SparkApplication{}

err := wait.PollUntilContextCancel(cancelCtx, PollInterval, true, func(ctx context.Context) (bool, error) {
app := v1beta2.SparkApplication{}
if err := k8sClient.Get(ctx, key, &app); err != nil {
Expand Down

0 comments on commit bc13f30

Please sign in to comment.