-
Notifications
You must be signed in to change notification settings - Fork 600
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 Broker Tracing #1995
Conversation
[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 |
channelTypeMeta := common.GetChannelTypeMeta(channel) | ||
client.CreateBrokerOrFail(brokerName, channelTypeMeta) | ||
|
||
// DO NOT SUBMIT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111!!!!!!!!!!!!!!!!!! |
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.
Found "DO NOT SUBMIT".
return it[key] < jt[key] | ||
} | ||
} | ||
panic(fmt.Errorf("can't tell the difference between %v, %v", ic, jc)) |
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.
Don't panic.
/retest |
/test pull-knative-eventing-integration-tests |
1 similar comment
/test pull-knative-eventing-integration-tests |
/test pull-knative-eventing-integration-tests |
@chizhg This is ready for review. |
@@ -252,10 +253,9 @@ func (r *Handler) sendEvent(ctx context.Context, tctx cloudevents.HTTPTransportC | |||
} | |||
|
|||
sendingCTX := utils.ContextFrom(tctx, subscriberURI) |
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.
Ctx
instead of CTX
?
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.
From what I understand, Go prefers non-word segments to share capitalization. https://talks.golang.org/2014/names.slide#5 refers to acronyms, "Acronyms should be all capitals, as in ServeHTTP and IDProcessor." CTX isn't an acronym, but it does feel like a similar, non-word segment. So I chose to keep it at the same level of capitalization.
@@ -91,6 +89,10 @@ func (h *Handler) serveHTTP(ctx context.Context, event cloudevents.Event, resp * | |||
|
|||
start := time.Now() | |||
sendingCTX := utils.ContextFrom(tctx, h.ChannelURI) |
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.
Ditto.
test/common/tracker.go
Outdated
@@ -144,7 +145,7 @@ func (t *Tracker) WaitForKResourcesReady() error { | |||
t.logf("Waiting for all KResources to become ready") | |||
for _, metaResource := range t.resourcesToCheckStatus { | |||
if err := base.WaitForResourceReady(t.dynamicClient, &metaResource); err != nil { | |||
return err | |||
return fmt.Errorf("waiting for %+v to become ready: %v", metaResource, 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.
return fmt.Errorf("waiting for %+v to become ready: %v", metaResource, err) | |
return fmt.Errorf("failed waiting for %+v to become ready: %v", metaResource, 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.
Done.
|
||
// Create a Trigger that receives events (type=bar) and sends them to the logger Pod. | ||
loggerTrigger := client.CreateTriggerOrFail( | ||
"logger", |
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.
Define it as a constant?
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 could, but why? This is the only place the value is used. Everywhere else it is needed, we use loggerTrigger.Name
.
Tags: map[string]string{ | ||
"http.method": "POST", | ||
"http.status_code": "202", | ||
"http.url": fmt.Sprintf("http://%s/", loggerSVCHost), |
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.
Can we remove the trailing /
?
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.
No. This is doing an exact match against the values recorded in the trace. The trace records the trailing /
, so the test needs it too.
Kind model.Kind | ||
LocalEndpointServiceName string | ||
Tags map[string]string | ||
Note string `json:"aaNote,omitempty"` |
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.
Are these a
and aa
prefixes added for sorting? If yes can we have some comments for them?
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.
Added a comment, does it make sense?
} | ||
|
||
func (t TestSpanTree) String() string { | ||
b, _ := json.Marshal(t) | ||
return string(b) | ||
} | ||
|
||
func (t *TestSpanTree) SortChildren() { |
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.
Can we have some comments for what this sort function does?
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.
if g, w := actual.ToTestSpanTree().SpanCount(), t.SpanCount(); g != w { | ||
return fmt.Errorf("unexpected number of spans. got %d want %d", g, w) | ||
} | ||
t.SortChildren() | ||
err := traceTreeMatches(".", t, actual) |
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.
Inline the error check?
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.
|
||
// Due to https://github.com/knative/eventing/issues/1998, wait for the Broker to become ready | ||
// before creating the Triggers. | ||
err := client.WaitForResourceReady(brokerName, &metav1.TypeMeta{ |
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.
We can use common.BrokerTypeMeta
here.
Also sounds like this is a bug we'll fix anyway, can we change the comment to a TODO
? Since we also have the similar logic in e2e 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.
Done.
I think the other e2e tests use the default Broker, which is likely created via the injection annotation and happens to be ready in 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.
There are also two test cases that create brokers:
client.CreateBrokerOrFail(brokerName, channelTypeMeta) |
client.CreateBrokerOrFail(brokerName, channelTypeMeta) |
// +build e2e | ||
|
||
/* | ||
Copyright 2019 The Knative Authors |
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.
Copyright 2019 The Knative Authors | |
Copyright 2019 The Knative Authors | |
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.
Copyright 2019 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at |
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.
Also missed linefeed here, and in the header of other new files.
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.
@@ -0,0 +1,48 @@ | |||
/* |
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.
Since you define them as functions here, do you think uri.go
will be a better file name?
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.
// 1. Shorter children first. | ||
// 2. Span kind. | ||
// 3. "http.url", "http.host", "http.path" tag presence and values. | ||
// If all of those are equal, then arbitrarily chose the earlier index. |
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.
// If all of those are equal, then arbitrarily chose the earlier index. | |
// If all of those are equal, then arbitrarily choose the earlier index. |
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.
// manually. | ||
// | ||
// The order it uses: | ||
// 1. Shorter children first. |
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.
Lower children first?
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.
Shorter. Where height is defined as the maximal number of descendants before hitting a leaf node. For example:
A
/ \
B C
|
D
'A' has a height of 2. 'B' has a height of 1. 'C' and 'D' have heights of 0.
The following is the coverage report on the affected files.
|
It looks really hard to get this test working, I can imagine how much effort you put on it 👍 |
Helps with #1766
Proposed Changes
The initial work for this PR was done by @daisy-ycguo in #1878.
Release Note