Skip to content

Commit

Permalink
Fix tests to properly match event UUID
Browse files Browse the repository at this point in the history
Signed-off-by: Calum Murray <[email protected]>
  • Loading branch information
Cali0707 committed Oct 30, 2023
1 parent ff97c1d commit d02844b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/rekt/features/broker/data_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,20 @@ func brokerAcceptsBinaryContentMode(ctx context.Context, t feature.T) {
}
for _, contenttype := range contenttypes {
source := feature.MakeRandomK8sName("source")
id := uuid.New().String()
eventshub.Install(source,
eventshub.StartSenderToResource(broker.GVR(), brokerName),
eventshub.InputHeader("ce-specversion", "1.0"),
eventshub.InputHeader("ce-type", "sometype"),
eventshub.InputHeader("ce-source", "200.request.sender.test.knative.dev"),
eventshub.InputHeader("ce-id", uuid.New().String()),
eventshub.InputHeader("ce-id", id),
eventshub.InputHeader("content-type", contenttype),
eventshub.InputBody("{}"),
eventshub.InputMethod("POST"),
)(ctx, t)

store := eventshub.StoreFromContext(ctx, source)
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("")))
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher(id)))
for _, e := range events {
if e.Response.StatusCode < 200 || e.Response.StatusCode > 299 {
t.Errorf("Expected statuscode 2XX for sequence %d got %d", e.Response.Sequence, e.Response.StatusCode)
Expand Down Expand Up @@ -245,7 +246,7 @@ func brokerAcceptsStructuredContentMode(ctx context.Context, t feature.T) {
)(ctx, t)

store := eventshub.StoreFromContext(ctx, source)
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("")))
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("2222-4444-6666")))
for _, e := range events {
if e.Response.StatusCode < 200 || e.Response.StatusCode > 299 {
t.Errorf("Expected statuscode 2XX for sequence %d got %d", e.Response.Sequence, e.Response.StatusCode)
Expand Down Expand Up @@ -278,7 +279,7 @@ func brokerRejectsUnknownCEVersion(ctx context.Context, t feature.T) {
// response was what was expected.
// Note: We pass in "" for the match ID because when we construct the headers manually
// above, they do not get stuff into the sent/response SentId fields.
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("")))
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher(id)))
for _, e := range events {
// Make sure HTTP response code is 4XX
if e.Response.StatusCode < 400 || e.Response.StatusCode > 499 {
Expand Down Expand Up @@ -307,7 +308,7 @@ func brokerAcceptResponseSuccess(ctx context.Context, t feature.T) {
)(ctx, t)

store := eventshub.StoreFromContext(ctx, source)
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("")))
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher(id)))
for _, e := range events {
// Make sure HTTP response code is 200
if e.Response.StatusCode < 200 || e.Response.StatusCode > 299 {
Expand Down Expand Up @@ -343,7 +344,7 @@ func brokerRejectsGetRequest(ctx context.Context, t feature.T) {
// response was what was expected.
// Note: We pass in "" for the match ID because when we construct the headers manually
// above, they do not get stuff into the sent/response SentId fields.
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("")))
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher(id)))
for _, e := range events {
// Make sure HTTP response code is 405
if e.Response.StatusCode != 405 {
Expand All @@ -355,11 +356,12 @@ func brokerRejectsGetRequest(ctx context.Context, t feature.T) {

func brokerRejectsMalformedCE(ctx context.Context, t feature.T) {
brokerName := state.GetStringOrFail(ctx, t, "brokerName")
id := uuid.New().String()
headers := map[string]string{
"ce-specversion": "1.0",
"ce-type": "sometype",
"ce-source": "conformancetest.request.sender.test.knative.dev",
"ce-id": uuid.New().String(),
"ce-id": id,
}

for k := range headers {
Expand Down Expand Up @@ -390,7 +392,7 @@ func brokerRejectsMalformedCE(ctx context.Context, t feature.T) {
// response was what was expected.
// Note: We pass in "" for the match ID because when we construct the headers manually
// above, they do not get stuff into the sent/response SentId fields.
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher("")))
events := knconf.Correlate(store.AssertAtLeast(ctx, t, 2, knconf.SentEventMatcher(id)))
for _, e := range events {
// Make sure HTTP response code is 4XX
if e.Response.StatusCode < 400 || e.Response.StatusCode > 499 {
Expand Down

0 comments on commit d02844b

Please sign in to comment.