-
Notifications
You must be signed in to change notification settings - Fork 29
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
Start buildrun follow logs test #39
Start buildrun follow logs test #39
Conversation
I was able to test successfully manuall as well
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good, just a couple of minor comments.
@@ -141,6 +146,9 @@ func (r *RunCommand) stop() { | |||
|
|||
// Run creates a BuildRun resource based on Build's name informed on arguments. | |||
func (r *RunCommand) Run(params *params.Params, ioStreams *genericclioptions.IOStreams) error { | |||
// ran into some data race conditions during unit test with this starting up, but pod events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍🏼 Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
pkg/shp/cmd/build/run_test.go
Outdated
}, | ||
} | ||
shpclientset := shpfake.NewSimpleClientset() | ||
createReactorFunc := func(action fakekubetesting.Action) (handled bool, ret runtime.Object, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be worth to explain why we need this reactor in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point / part of next push
pkg/shp/cmd/build/run_test.go
Outdated
pod.Status.Phase = corev1.PodSucceeded | ||
cmd.onEvent(pod) | ||
if !strings.Contains(out.String(), "Pod 'testpod' has succeeded!") { | ||
t.Fatalf("unexpected output: %s", out.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alternatively we could use gomega
assertion library, as we do in the other unit-tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I've see that and am not the biggest fan ... was hoping for some developer choice here :-)
but let me ponder and then "officially" respond
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see gomega kept out of unit tests, especially just for an assertion.
pkg/shp/cmd/build/run_test.go
Outdated
) | ||
|
||
func TestStartBuildRunFollowLog(t *testing.T) { | ||
// "build.shipwright.io/name=%s,buildrun.shipwright.io/name=%s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be a left over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is thanks
pkg/shp/cmd/build/run_test.go
Outdated
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" | ||
shpfake "github.com/shipwright-io/build/pkg/client/clientset/versioned/fake" | ||
"github.com/shipwright-io/cli/pkg/shp/flags" | ||
"github.com/shipwright-io/cli/pkg/shp/params" | ||
"github.com/spf13/cobra" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
"k8s.io/client-go/kubernetes/fake" | ||
fakekubetesting "k8s.io/client-go/testing" | ||
"strings" | ||
"testing" | ||
"time" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: imports should be sorted into blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep saw that and have that part of the next push as well
also @otaviof @coreydaley I may have figured out a better approach than the sleep on line 84 of run_test.go ... trying it out now |
Yes!!! ... |
e549214
to
39826af
Compare
OK @otaviof @coreydaley I've pushed updates stemming from the comments (with still withholding on the go omega usage) Also, I
PTAL / thanks |
39826af
to
001a564
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! It looks good to me!
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gabemontero The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
add unit test for previously provided live log follow / tail of invoking build run from referenced build via cli
unit tests uncovered some race conditions previously unseen with manual testing
/kind cleanup
/assign @otaviof
/assign @coreydaley
/assign @HeavyWombat
after a bunch of back and forth with myself today (preceded by a conversation with @otaviof )
I gave up trying to get k8s fake clients to work with watches, etc. and am just testing the function in this package
we have tests in pod_watcher and tail for those functions
in looking at the panic we saw in @HeavyWombat 's #35 I do believe line 64 in run.go is in the Run() method, so in theory this test calling that method would have caught that error.
But as @otaviof mentioned to me today, and I agree, e2e tests that run against an api server are also needed for this component long term
Submitter Checklist
See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.
Release Notes