Skip to content

Commit 2fa153b

Browse files
author
Zach Swanson
committed
test case for rollout with workload ref
1 parent 6c52847 commit 2fa153b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

components/migrations_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,62 @@ var _ = Describe("Migrations component", func() {
306306
helper.TestClient.GetName("testing-migrations", job)
307307
Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("myapp:v1"))
308308
})
309+
310+
It("follows owner references for an argoproj.io rollout with workloadref to deployment", func() {
311+
truep := true
312+
rollout := &argoproj.Rollout{
313+
ObjectMeta: metav1.ObjectMeta{Name: "testing"},
314+
Spec: argoproj.RolloutSpec{
315+
WorkloadRef: &argoproj.ObjectRef{
316+
Name: "testing",
317+
APIVersion: "apps/v1",
318+
Kind: "Deployment",
319+
},
320+
},
321+
}
322+
helper.TestClient.Create(rollout)
323+
deployment := &appsv1.Deployment{
324+
ObjectMeta: metav1.ObjectMeta{Name: "testing"},
325+
Spec: appsv1.DeploymentSpec{
326+
Template: corev1.PodTemplateSpec{
327+
Spec: corev1.PodSpec{
328+
Containers: []corev1.Container{
329+
{
330+
Name: "main",
331+
Image: "myapp:v1",
332+
},
333+
},
334+
},
335+
},
336+
},
337+
}
338+
helper.TestClient.Create(deployment)
339+
rs := &appsv1.ReplicaSet{
340+
ObjectMeta: metav1.ObjectMeta{
341+
Name: "testing-1234",
342+
OwnerReferences: []metav1.OwnerReference{
343+
{
344+
APIVersion: "argoproj.io/v1alpha1",
345+
Kind: "Rollout",
346+
Name: "testing",
347+
Controller: &truep,
348+
},
349+
},
350+
},
351+
}
352+
helper.TestClient.Create(rs)
353+
pod.OwnerReferences = []metav1.OwnerReference{
354+
{
355+
APIVersion: "apps/v1",
356+
Kind: "ReplicaSet",
357+
Name: "testing-1234",
358+
Controller: &truep,
359+
},
360+
}
361+
helper.TestClient.Create(pod)
362+
363+
helper.MustReconcile()
364+
helper.TestClient.GetName("testing-migrations", job)
365+
Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("myapp:v1"))
366+
})
309367
})

0 commit comments

Comments
 (0)