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

E2E test for Channel Tracing #1858

Merged
merged 35 commits into from
Sep 20, 2019
Merged

Conversation

Harwayne
Copy link
Contributor

@Harwayne Harwayne commented Sep 10, 2019

Helps with #1765.

Proposed Changes

  • Add an E2E test for tracing through Channels.

Release Note

NONE

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 10, 2019
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/test-and-release Test infrastructure, tests or release labels Sep 10, 2019
@Harwayne Harwayne changed the title E2E tracing [WIP] E2E test for Channel Tracing Sep 10, 2019
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 10, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Harwayne

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2019
expectedNumSpans := 3
if tc.incomingTraceId {
expectedNumSpans = 4
}
Copy link
Member

@daisy-ycguo daisy-ycguo Sep 12, 2019

Choose a reason for hiding this comment

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

Could you explain why the number of spans is different when the incoming message includes trace Id ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment to the code, does it make sense?

@@ -32,7 +35,10 @@ func handler(event cloudevents.Event) {
}

func main() {
c, err := cloudevents.NewDefaultClient()
if err := tracing.SetupStaticPublishing(zap.NewNop().Sugar(), "", tracing.AlwaysSample); err != nil {
Copy link
Member

@daisy-ycguo daisy-ycguo Sep 12, 2019

Choose a reason for hiding this comment

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

Why both logevents and sendevents need to call tracing.SetupStaticPublishing? Will it bring a duplicate tracing setup ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each Pod must setup tracing independently. The only way I am aware of doing it without our container doing the work is with a sidecar like Istio. As this test does not require Istio, we need to setup the tracing ourselves.

In general, we want to test that a trace that started before the request to the Channel is continued through the Channel to the Channel's subscribers. To do that, we need to ensure there is a trace going into the Channel, hence we instrument the sending pod, as well as ensure the same trace is going to the Channel's subscribers, hence we instrument the logging pod.

@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 12, 2019
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 16, 2019
@Harwayne
Copy link
Contributor Author

/test pull-knative-eventing-integration-tests

@chizhg
Copy link
Member

chizhg commented Sep 17, 2019

/retest

test/conformance/channel_tracing_test.go Outdated Show resolved Hide resolved
test/e2e-common.sh Outdated Show resolved Hide resolved
t.Fatalf("Error getting logs: %v", err)
}
// This is the format that the eventdetails image prints headers.
re := regexp.MustCompile("\nGot Header X-B3-Traceid: ([a-zA-Z0-9]{32})\n")
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit hacky...
We should find a better way to get the header, but can be in a different PR..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree, what do you recommend?

Copy link
Member

Choose a reason for hiding this comment

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

We can define a library to add and parse headers to/from the logs, each header will be quoted with something like <header>...</header>. We can also use the similar way to log and parse the body of cloud event, if we need more accurate check on it.

This requires bigger changes, so it can be in a different PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#1945 to track.

test/e2e-common.sh Outdated Show resolved Hide resolved
test/e2e-common.sh Show resolved Hide resolved
test/conformance/channel_tracing_test.go Outdated Show resolved Hide resolved
@Harwayne Harwayne mentioned this pull request Sep 18, 2019
@Harwayne Harwayne changed the title [WIP] E2E test for Channel Tracing E2E test for Channel Tracing Sep 18, 2019
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 18, 2019
@Harwayne
Copy link
Contributor Author

This is ready for review.

incomingTraceId bool
istio bool
}{
//"no incoming trace id": {},
Copy link
Member

Choose a reason for hiding this comment

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

Ah, so this one is still not working? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works consistently on my Linux desktop, is flaky on my Mac laptop. For now, I'll leave it commented out (or I could remove the line if you prefer), so that the rest of the test can get in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it for now, rather than just commenting it out.

for n, tc := range testCases {
loggerPodName := "logger"
t.Run(n, func(t *testing.T) {
channelTestRunner.RunTests(t, common.FeatureBasic, func(st *testing.T, channel string) {
Copy link
Member

Choose a reason for hiding this comment

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

This function needs to be defined as a helper function, if you want it to be ported to eventing-contrib to test other channel implementations, example https://github.com/knative/eventing/blob/master/test/conformance/helpers/channel_header_single_event_helper.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

I didn't know, thanks for pointing it out.

@chizhg
Copy link
Member

chizhg commented Sep 20, 2019

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants