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

Add event message verification to cronjob e2e test #698

Closed
wants to merge 1 commit into from

Conversation

daisy-ycguo
Copy link
Member

Fixes #566

Proposed Changes

  • Add event message verification to cronjob e2e test

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 2, 2020
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 2, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: daisy-ycguo
To complete the pull request process, please assign maximilien
You can assign the PR to them by writing /assign @maximilien in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@daisy-ycguo daisy-ycguo changed the title Add cronjob event message verification to e2e test Add event message verification to cronjob e2e test Mar 2, 2020
@daisy-ycguo daisy-ycguo force-pushed the crone2e branch 6 times, most recently from 2455583 to c88470b Compare March 2, 2020 15:58
Copy link
Contributor

@maximilien maximilien left a 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.

assert.NilError(t, err)
}

func (test *e2eTest) verifyDeventDisplayLogs(t *testing.T, svcname string, message string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/verifyDeventDisplayLogs/verifyEventDisplayLogs/

Copy link
Member Author

Choose a reason for hiding this comment

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

done

out string
)

selectorstr := fmt.Sprintf("serving.knative.dev/service=%s", svcname)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/selectorstr/selectorStr/

Copy link
Member Author

Choose a reason for hiding this comment

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

done


selectorstr := fmt.Sprintf("serving.knative.dev/service=%s", svcname)
for retries < 5 {
out, err = kubectl{}.Run("logs", "-l", selectorstr, "-c", "user-container")
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Member Author

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.

@daisy-ycguo daisy-ycguo force-pushed the crone2e branch 8 times, most recently from d1c0838 to 1275696 Compare March 3, 2020 07:32
@knative-prow-robot
Copy link
Contributor

@daisy-ycguo: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-knative-client-integration-tests f564a3c link /test pull-knative-client-integration-tests
pull-knative-client-integration-tests-latest-release f564a3c link /test pull-knative-client-integration-tests-latest-release

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.

@daisy-ycguo
Copy link
Member Author

daisy-ycguo commented Mar 3, 2020

@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:

{"level":"error","ts":1583223540.0185604,"logger":"fallback","caller":"cronjobevents/adapter.go:120","msg":"failed to send cloudevent{error 25 0  Post http://displaysvc.kne2etests1.svc.cluster.local: dial tcp: lookup displaysvc.kne2etests1.svc.cluster.local on 10.11.240.10:53: no such host}","stacktrace":"knative.dev/eventing/pkg/adapter/cronjobevents.(*cronJobAdapter).cronTick\n\tknative.dev/eventing/pkg/adapter/cronjobevents/adapter.go:120\nknative.dev/eventing/vendor/github.com/robfig/cron.FuncJob.Run\n\tknative.dev/eventing/vendor/github.com/robfig/cron/cron.go:131\nknative.dev/eventing/vendor/github.com/robfig/cron.(*Cron).startJob.func1\n\tknative.dev/eventing/vendor/github.com/robfig/cron/cron.go:307"}

cronjob is trying to send the event messages to displaysvc.kne2etests1.svc.cluster.local but the host name could not be resolved. I think maybe we need to update istio install to use cluster local gateway in the test environment to solve the issue. Refer to this issue report in Knative eventing.

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove

Copy link
Member Author

@daisy-ycguo daisy-ycguo Mar 4, 2020

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove

Copy link
Member Author

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)
Copy link
Contributor

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.

Copy link
Member Author

@daisy-ycguo daisy-ycguo Mar 4, 2020

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)
Copy link
Contributor

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) {
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

what if err ?

Copy link
Member Author

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

what if err ?

Copy link
Member Author

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

why log ?

Copy link
Member Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

else not needed

@rhuss
Copy link
Contributor

rhuss commented Mar 4, 2020

@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.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2020
@knative-prow-robot
Copy link
Contributor

@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.

@rhuss
Copy link
Contributor

rhuss commented Mar 5, 2020

/hold

Sorry, but as we are moving to ping source as a replacement for a cronjob source we need to do it completely different.

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 5, 2020
@maximilien
Copy link
Contributor

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.

@rhuss
Copy link
Contributor

rhuss commented Mar 7, 2020

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!

@daisy-ycguo
Copy link
Member Author

@rhuss I will close it and raise a new one for the PingSource.

@daisy-ycguo daisy-ycguo closed this Mar 9, 2020
dsimansk pushed a commit to dsimansk/client that referenced this pull request May 12, 2021
Co-authored-by: pratham-m <prathamm@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indicates the PR's author has signed the CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add E2E tests for CronJob source
5 participants