Skip to content

Commit

Permalink
Refine the integration tests for the immutable PyTorchJob queueName (k…
Browse files Browse the repository at this point in the history
…ubeflow#2130)

Signed-off-by: Yuki Iwai <[email protected]>
  • Loading branch information
tenzen-y authored May 30, 2024
1 parent 00f4d52 commit c07000f
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pkg/controller.v1/pytorch/pytorchjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,21 @@ var _ = Describe("PyTorchJob controller", func() {
Expect(testK8sClient.Create(ctx, job)).Should(Succeed())

By("Attempting to update the PyTorchJob with a different queue value")
updatedJob := &kubeflowv1.PyTorchJob{}
Eventually(func() bool {
err := testK8sClient.Get(ctx, jobKey, updatedJob)
return err == nil
}, testutil.Timeout, testutil.Interval).Should(BeTrue(), "Failed to get PyTorchJob")

Eventually(func() bool {
Eventually(func(g Gomega) {
updatedJob := &kubeflowv1.PyTorchJob{}
g.Expect(testK8sClient.Get(ctx, jobKey, updatedJob)).Should(Succeed(), "Failed to get PyTorchJob")
updatedJob.Spec.RunPolicy.SchedulingPolicy.Queue = "test"
err := testK8sClient.Update(ctx, updatedJob)
g.Expect(err).To(HaveOccurred(), "Expected an error when updating the queue, but update succeeded")
By("Checking that the queue update fails")
Expect(err).To(HaveOccurred(), "Expected an error when updating the queue, but update succeeded")
Expect(err).To(MatchError(ContainSubstring("spec.runPolicy.schedulingPolicy.queue is immutable"), "The error message did not contain the expected message"))
return err != nil
}, testutil.Timeout, testutil.Interval).Should(BeTrue())

}, testutil.Timeout, testutil.Interval).Should(Succeed())

By("Validating the queue was not updated")
freshJob := &kubeflowv1.PyTorchJob{}
Expect(testK8sClient.Get(ctx, client.ObjectKeyFromObject(job), freshJob)).Should(Succeed(), "Failed to get PyTorchJob after update attempt")
Expect(freshJob.Spec.RunPolicy.SchedulingPolicy.Queue).To(Equal("initial-queue"), "The queue should remain as the initial value since it should be immutable")

})

It("Shouldn't create resources if PyTorchJob is suspended", func() {
Expand Down

0 comments on commit c07000f

Please sign in to comment.