-
Notifications
You must be signed in to change notification settings - Fork 261
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
Add event message verification to cronjob e2e test #698
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: daisy-ycguo The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
2455583
to
c88470b
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.
Left some feedback. Also, tests are failing.
test/e2e/cronjob_test.go
Outdated
assert.NilError(t, err) | ||
} | ||
|
||
func (test *e2eTest) verifyDeventDisplayLogs(t *testing.T, svcname string, message string) 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.
s/verifyDeventDisplayLogs/verifyEventDisplayLogs/
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.
done
test/e2e/cronjob_test.go
Outdated
out string | ||
) | ||
|
||
selectorstr := fmt.Sprintf("serving.knative.dev/service=%s", svcname) |
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.
s/selectorstr/selectorStr/
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.
done
test/e2e/cronjob_test.go
Outdated
|
||
selectorstr := fmt.Sprintf("serving.knative.dev/service=%s", svcname) | ||
for retries < 5 { | ||
out, err = kubectl{}.Run("logs", "-l", selectorstr, "-c", "user-container") |
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'd separate the retry logic and code into it's on private function.
Would also simplify this function.
} | ||
} | ||
|
||
func (test *e2eTest) serviceCreateEventDisplay(t *testing.T, r *KnRunResultCollector, serviceName 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.
Why is this not a public Test...
function?
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's same as serviceCreate
function defined in service_test.go
func (test *e2eTest) serviceCreateDuplicate(t *testing.T, r *KnRunResultCollector, serviceName string)
Although it's not public, but you can use this function under any e2e tests.
d1c0838
to
1275696
Compare
@daisy-ycguo: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@rhuss @navidshaikh @maximilien I met with problem in this test case. I have set up cronjob and event-display in the test environment. Yet there are error messages in cronjob adapter:
cronjob is trying to send the event messages to Please let me know your thoughts to the current situation. Thank you. |
@@ -185,6 +185,7 @@ func RunKubectl(namespace string, args ...string) (string, error) { | |||
args = append(args, "--namespace", namespace) | |||
} | |||
stdout, stderr, err := runCli("kubectl", args) | |||
//out := fmt.Sprintf("$kubectl %s \n %s", args, stdout) |
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.
please remove
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.
for debug purpose. will remove in the latest version.
@@ -56,7 +59,57 @@ func TestSourceCronJob(t *testing.T) { | |||
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}" | |||
out, err := test.getResourceFieldsWithJSONPath("cronjobsource", "testcronjobsource2", jpSinkRefNameInSpec) | |||
assert.NilError(t, err) | |||
assert.Equal(t, out, "testsvc1") | |||
//assert.Equal(t, out, "testsvc1") |
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.
please remove
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.
@daisy-ycguo with the latest commits, there is a conflict.
wrt/ the issue: I will open an issue on test-infrastructure so that the istio local gateway gets enabled for the tests.
Until test-infrastructure gets update, this PR will not pass the integration test.
results := test.kn.Run("source", "cronjob", "describe", "testcronjobsource3") | ||
r.AssertNoError(results) | ||
out, err = kubectl{test.kn.namespace}.Run("get", "pod", "-l", "sources.eventing.knative.dev/cronJobSource=testcronjobsource3", "-o", "yaml") | ||
t.Log(out) |
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.
Is this necessary ? Maybe better assert on out
.
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.
for debug purpose. will remove in the latest version.
for retries < 5 { | ||
out, err = kubectl{test.kn.namespace}.Run("logs", "-l", selectorStr, "-c", "user-container") | ||
if err != nil { | ||
t.Logf("error happens at kubectl logs -l %s -c -n %s: %v", selectorStr, test.kn.namespace, err) |
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.
you should return here with the error.
out, err = kubectl{test.kn.namespace}.Run("logs", "-l", selectorStr, "-c", "user-container") | ||
if err != nil { | ||
t.Logf("error happens at kubectl logs -l %s -c -n %s: %v", selectorStr, test.kn.namespace, err) | ||
} else if err == nil && strings.Contains(out, message) { |
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.
err is nil for sure when you reach this (see condition before)
break | ||
} else { | ||
t.Logf("return from kubectl logs -l %s -n %s: %s", selectorStr, test.kn.namespace, out) | ||
out, err = kubectl{test.kn.namespace}.Run("get", "pods") |
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.
what if err ?
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.
for debug purpose. will remove in the latest version.
t.Logf("return from kubectl logs -l %s -n %s: %s", selectorStr, test.kn.namespace, out) | ||
out, err = kubectl{test.kn.namespace}.Run("get", "pods") | ||
t.Log(out) | ||
out, err = kubectl{test.kn.namespace}.Run("logs", "-l", "sources.eventing.knative.dev/cronJobSource=testcronjobsource3") |
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.
what if err ?
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.
for debug purpose. will remove in the latest version.
} else { | ||
t.Logf("return from kubectl logs -l %s -n %s: %s", selectorStr, test.kn.namespace, out) | ||
out, err = kubectl{test.kn.namespace}.Run("get", "pods") | ||
t.Log(out) |
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.
why log here ?
out, err = kubectl{test.kn.namespace}.Run("get", "pods") | ||
t.Log(out) | ||
out, err = kubectl{test.kn.namespace}.Run("logs", "-l", "sources.eventing.knative.dev/cronJobSource=testcronjobsource3") | ||
t.Log(out) |
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.
why log ?
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.
for debug purpose. will remove in the latest version.
|
||
if retries == 5 { | ||
return fmt.Errorf("Expected log incorrect after retry 5 times. Expecting to include:\n%s\n Instead found:\n%s\n", message, out) | ||
} else { |
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.
else not needed
@daisy-ycguo with the latest commits, there is a conflict. wrt/ the issue: I will open an issue on test-infrastructure so that the istio local gateway gets enabled for the tests. |
@daisy-ycguo: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/hold Sorry, but as we are moving to ping source as a replacement for a cronjob source we need to do it completely different. |
Hi, @daisy-ycguo, please mark comments that have been resolved by clicking "Resolve" this should make it easier to do subsequent reviews on previous one. Thanks. |
As mentioned we moved now to a PingSource. Could you please either update that PR, or, maybe simpler, create a new one for the PingSource ? Thanks! |
@rhuss I will close it and raise a new one for the PingSource. |
Co-authored-by: pratham-m <prathamm@us.ibm.com>
Fixes #566
Proposed Changes