Skip to content

Commit

Permalink
even more spacing cleanup/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gabbifish committed May 26, 2020
1 parent 338c6e5 commit db469c6
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,22 @@ var _ = Describe("Run CronJob Controller", func() {
Now that we've created a CronJob in our test cluster, the next step is to write a test that actually tests our CronJob controller’s behavior.
Let’s test the CronJob controller’s logic responsible for updating CronJob.Status.Active with actively running jobs.
We’ll verify that when a CronJob has a single active downstream Job, its CronJob.Status.Active field contains a reference to this Job.
First, we should get the test CronJob we created earlier, and verify that it currently does not have any active jobs.
Note that, because the k8s apiserver may not have finished creating a CronJob after our `Create()` call from earlier, we will use Gomega’s Eventually() testing function instead of Expect() to give the apiserver an opportunity to finish creating our CronJob.
`Eventually()` will repeatedly run the function provided as an argument every interval seconds until
(a) the function’s output matches what’s expected in the subsequent `Should()` call, or
(b) the number of attempts * timeout period exceed the provided interval value.
In the examples below, let `FAILURE bool = false` and `SUCCESS bool = true`.
timeout and interval are Go Duration values of your choosing.
*/
Context("Can perform status updates", func() {
It("CronJob Status.Active count should increase as Jobs are added", func() {
By("CronJob status should initially have no active Jobs")
ctx := context.Background()
/*
First, we should get the test CronJob we created earlier, and verify that it currently does not have any active jobs.
Note that, because the k8s apiserver may not have finished creating a CronJob after our `Create()` call from earlier, we will use Gomega’s Eventually() testing function instead of Expect() to give the apiserver an opportunity to finish creating our CronJob.
`Eventually()` will repeatedly run the function provided as an argument every interval seconds until
(a) the function’s output matches what’s expected in the subsequent `Should()` call, or
(b) the number of attempts * timeout period exceed the provided interval value.

In the examples below, let `FAILURE bool = false` and `SUCCESS bool = true`.
timeout and interval are Go Duration values of your choosing.
*/
By("CronJob status should initially have no active Jobs")
cronjobLookupKey := types.NamespacedName{Name: CronjobName, Namespace: CronjobNamespace}
createdCronjob := &cronjobv1.CronJob{}

Expand All @@ -151,6 +151,10 @@ var _ = Describe("Run CronJob Controller", func() {
/*
Next, we actually create a stubbed Job that will belong to our CronJob, as well as its downstream template specs.
We set the Job's status's "Active" count to 2 to simulate the Job running two pods, which means the Job is actively running.
We then take the stubbed Job and set its owner reference to point to our test CronJob.
This ensures that the test Job belongs to, and is tracked by, our test CronJob.
Once that’s done, we create our new Job instance.
*/
By("Create active Job underneath CronJob")
testJob := &batchv1.Job{
Expand All @@ -176,11 +180,7 @@ var _ = Describe("Run CronJob Controller", func() {
Active: 2,
},
}
/*
We take the stubbed Job and set its owner reference to point to our test CronJob.
This ensures that the test Job belongs to, and is tracked by, our test CronJob.
Once that’s done, we create our new Job instance.
*/

// Note that your CronJob’s GroupVersionKind is required to set up this owner reference.
controllerRef := metav1.NewControllerRef(createdCronjob, GVK)
testJob.SetOwnerReferences([]metav1.OwnerReference{*controllerRef})
Expand Down

0 comments on commit db469c6

Please sign in to comment.