Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring in sidecar test #2733

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions test/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
knativetest "knative.dev/pkg/test"
)

const (
Expand Down Expand Up @@ -54,6 +55,10 @@ func TestSidecarTaskSupport(t *testing.T) {
}}

clients, namespace := setup(t)
t.Parallel()

knativetest.CleanupOnInterrupt(func() { tearDown(t, clients, namespace) }, t.Logf)
defer tearDown(t, clients, namespace)

for i, test := range tests {
t.Run(test.desc, func(t *testing.T) {
Expand All @@ -63,10 +68,10 @@ func TestSidecarTaskSupport(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: sidecarTaskName, Namespace: namespace},
Spec: v1beta1.TaskSpec{
Steps: []v1beta1.Step{{
Container: corev1.Container{Name: primaryContainerName, Image: "busybox:1.31.0-musl", Command: test.stepCommand},
Container: corev1.Container{Name: primaryContainerName, Image: "busybox", Command: test.stepCommand},
}},
Sidecars: []v1beta1.Sidecar{{
Container: corev1.Container{Name: sidecarContainerName, Image: "busybox:1.31.0-musl", Command: test.sidecarCommand},
Container: corev1.Container{Name: sidecarContainerName, Image: "busybox", Command: test.sidecarCommand},
}},
},
}
Expand Down
9 changes: 7 additions & 2 deletions test/v1alpha1/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
knativetest "knative.dev/pkg/test"
)

const (
Expand Down Expand Up @@ -54,6 +55,10 @@ func TestSidecarTaskSupport(t *testing.T) {
}}

clients, namespace := setup(t)
t.Parallel()

knativetest.CleanupOnInterrupt(func() { tearDown(t, clients, namespace) }, t.Logf)
defer tearDown(t, clients, namespace)

for i, test := range tests {
t.Run(test.desc, func(t *testing.T) {
Expand All @@ -62,13 +67,13 @@ func TestSidecarTaskSupport(t *testing.T) {
task := tb.Task(sidecarTaskName,
tb.TaskSpec(
tb.Step(
"busybox:1.31.0-musl",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Couple questions:

  1. Could you add something to the commit message explaining why this is preferred?
  2. What is this doing now? Pulling in ":latest"? If so, should we simply pin to today's "latest" version / digest so that it remains a constant going forward for our tests? If not, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There is no such difference to prefer, the job required can be done by busybox image and we are using that in many e2e tests, while busybox image based on musl is used only in this test so it will avoid this image pulling. I just used a simple busybox image as for the e2e test, it is just doing echo and doesn't have any scenario to use the alpine based image.

  2. If you see all the e2e tests, in every test except one it is justbusybox so I used it here also the same way.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, thanks for explaining. I didn't know that this was what we use everywhere else so it's good to know.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to get this in the commit message too. Even when something is extremely obvious it really helps to have the context of the change described. Otherwise I need to just "somehow" know.

"busybox",
tb.StepName(primaryContainerName),
tb.StepCommand(test.stepCommand...),
),
tb.Sidecar(
sidecarContainerName,
"busybox:1.31.0-musl",
"busybox",
tb.Command(test.sidecarCommand...),
),
),
Expand Down