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

JobSink: Test OIDC support #8000

Merged
merged 4 commits into from
Jun 20, 2024
Merged

Conversation

pierDipi
Copy link
Member

Fixes #

Proposed Changes

  • Test JobSink's OIDC support (success and failure case)
  • Validate returned status codes for various cases (202, 401)

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note


Docs

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@knative-prow knative-prow bot added area/test-and-release Test infrastructure, tests or release size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 13, 2024
@pierDipi
Copy link
Member Author

/cc @creydr

@knative-prow knative-prow bot requested a review from creydr June 13, 2024 08:03
Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 2.85714% with 34 lines in your changes missing coverage. Please review.

Project coverage is 67.72%. Comparing base (8da4543) to head (48caf48).
Report is 6 commits behind head on main.

Files Patch % Lines
cmd/jobsink/main.go 0.00% 34 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8000      +/-   ##
==========================================
+ Coverage   67.65%   67.72%   +0.06%     
==========================================
  Files         361      362       +1     
  Lines       16638    16720      +82     
==========================================
+ Hits        11256    11323      +67     
- Misses       4690     4701      +11     
- Partials      692      696       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@creydr
Copy link
Member

creydr commented Jun 13, 2024

=== RUN   TestJobSinkSuccess/Success/Assert/Source_sent_the_event
=== PAUSE TestJobSinkSuccess/Success/Assert/Source_sent_the_event
=== CONT  TestJobSinkSuccess/Success/Assert/Source_sent_the_event
    event_info_store.go:171: Timeout waiting for at least 1 matches.
        Error: FAIL MATCHING: saw 0/1 matching events.
        - Store-
        Pod 'source-ndxbvwbi' in namespace 'test-bylujand'
        - Recent events -
        2 events seen, last 2 events (total events seen 2099, events ignored 2097):
        -- EventInfo --
        --- Kind: Sent ---
        --- Event ---
        Context Attributes,
          specversion: 1.0
          type: com.example.FullEvent
          source: http://example.com/source
          subject: topic
          id: f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6
          time: 2020-03-21T12:34:56.78Z
          dataschema: http://example.com/schema
          datacontenttype: text/json
        Extensions,
          exbinary: AAECAw==
          exbool: true
          exint: 42
          exstring: exstring
          extime: 2020-03-21T12:34:56.78Z
          exurl: http://example.com/source
        Data,
          "hello"
        
        --- HTTP headers ---
          Ce-Exbool: true
          Ce-Exstring: exstring
          Ce-Exurl: http://example.com/source
          Ce-Subject: topic
          Ce-Type: com.example.FullEvent
          Ce-Exbinary: AAECAw==
          Ce-Source: http://example.com/source
          Ce-Exint: 42
          Ce-Extime: 2020-03-21T12:34:56.78Z
          Ce-Specversion: 1.0
          Content-Type: text/json
          Ce-Dataschema: http://example.com/schema
          Ce-Id: f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6
          Ce-Time: 2020-03-21T12:34:56.78Z
        
        --- Origin: 'source-ndxbvwbi' ---
        --- Observer: 'source-ndxbvwbi' ---
        --- Time: 2024-06-13 08:37:35.624394693 +0000 UTC ---
        --- Sequence: 1 ---
        --- Sent Id:  'f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6 ---
        --------------------
        
        -- EventInfo --
        --- Kind: Response ---
        --- HTTP headers ---
          Content-Length: 0
          Date: Thu, 13 Jun 2024 08:37:35 GMT
          Location: /namespaces/test-bylujand/name/jobsink-owsdtozs/sources/http://example.com/source/ids/f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6
        
        --- Status Code: 202 ---
        --- Origin: 'http://job-sink.knative-eventing.svc.cluster.local/test-bylujand/jobsink-owsdtozs' ---
        --- Observer: 'source-ndxbvwbi' ---
        --- Time: 2024-06-13 08:37:35.632626806 +0000 UTC ---
        --- Sequence: 1 ---
        --- Sent Id:  'f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6 ---
        --------------------
        
        
        - Match errors -
        0 - event status code don't match. Expected: '202', Actual: '0'
        1 - event kind don't match. Expected: 'Sent', Actual: 'Response'
        
        Collected events: -- EventInfo --
        --- Kind: Sent ---
        --- Event ---
        Context Attributes,
          specversion: 1.0
          type: com.example.FullEvent
          source: http://example.com/source
          subject: topic
          id: f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6
          time: 2020-03-21T12:34:56.78Z
          dataschema: http://example.com/schema
          datacontenttype: text/json
        Extensions,
          exbinary: AAECAw==
          exbool: true
          exint: 42
          exstring: exstring
          extime: 2020-03-21T12:34:56.78Z
          exurl: http://example.com/source
        Data,
          "hello"
        
        --- HTTP headers ---
          Ce-Exbinary: AAECAw==
          Ce-Source: http://example.com/source
          Ce-Specversion: 1.0
          Content-Type: text/json
          Ce-Exint: 42
          Ce-Extime: 2020-03-21T12:34:56.78Z
          Ce-Time: 2020-03-21T12:34:56.78Z
          Ce-Dataschema: http://example.com/schema
          Ce-Id: f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6
          Ce-Exurl: http://example.com/source
          Ce-Subject: topic
          Ce-Type: com.example.FullEvent
          Ce-Exbool: true
          Ce-Exstring: exstring
        
        --- Origin: 'source-ndxbvwbi' ---
        --- Observer: 'source-ndxbvwbi' ---
        --- Time: 2024-06-13 08:37:35.624394693 +0000 UTC ---
        --- Sequence: 1 ---
        --- Sent Id:  'f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6 ---
        --------------------
        
        -- EventInfo --
        --- Kind: Response ---
        --- HTTP headers ---
          Content-Length: 0
          Date: Thu, 13 Jun 2024 08:37:35 GMT
          Location: /namespaces/test-bylujand/name/jobsink-owsdtozs/sources/http://example.com/source/ids/f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6
        
        --- Status Code: 202 ---
        --- Origin: 'http://job-sink.knative-eventing.svc.cluster.local/test-bylujand/jobsink-owsdtozs' ---
        --- Observer: 'source-ndxbvwbi' ---
        --- Time: 2024-06-13 08:37:35.632626806 +0000 UTC ---
        --- Sequence: 1 ---
        --- Sent Id:  'f615e8b7-bb4a-4aa9-bfa4-933fa6b301b6 ---
        --------------------
        
        
        knative.dev/reconciler-test/pkg/eventshub.(*Store).AssertAtLeast
        	/home/prow/go/src/knative.dev/eventing/vendor/knative.dev/reconciler-test/pkg/eventshub/event_info_store.go:171
        knative.dev/eventing/test/rekt/features/jobsink.Success.MatchAssertionBuilder.AtLeast.func8
        	/home/prow/go/src/knative.dev/eventing/vendor/knative.dev/reconciler-test/pkg/eventshub/assert/step.go:94
        knative.dev/reconciler-test/pkg/environment.(*MagicEnvironment).executeStep.func1
        	/home/prow/go/src/knative.dev/eventing/vendor/knative.dev/reconciler-test/pkg/environment/execution.go:67
        testing.tRunner
        	/root/.gvm/gos/go1.22.4/src/testing/testing.go:1689
        runtime.goexit
        	/root/.gvm/gos/go1.22.4/src/runtime/asm_amd64.s:1695
--- FAIL: TestJobSinkSuccess/Success/Assert/Source_sent_the_event (120.03s)
FAIL test/rekt.TestJobSinkSuccess/Success/Assert/Source_sent_the_event (120.03s)

@pierDipi is this a (known) flake?

/test reconciler-tests

EDIT:
I oversaw this change in the diff. So probably related to this change

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi
Copy link
Member Author

I don't get why this

        -- EventInfo --
        --- Kind: Response ---
        --- HTTP headers ---
          Content-Length: 0
          Date: Fri, 14 Jun 2024 13:51:14 GMT
          Location: /namespaces/test-weytqyqd/name/jobsink-tshnfxrp/sources/http://example.com/source/ids/7e9c3535-0c0d-4558-b16a-09f6c279161e
        
        --- Status Code: 202 ---
        --- Origin: 'http://job-sink.knative-eventing.svc.cluster.local/test-weytqyqd/jobsink-tshnfxrp' ---
        --- Observer: 'source-gsisqqgr' ---
        --- Time: 2024-06-14 13:51:14.602621825 +0000 UTC ---
        --- Sequence: 1 ---
        --- Sent Id:  '7e9c3535-0c0d-4558-b16a-09f6c279161e ---
        --------------------

is not matched with:

	f.Assert("Source sent the event", assert.OnStore(source).
		MatchResponseEvent().
		Match(assert.MatchStatusCode(202)).
		AtLeast(1),
	)

@pierDipi
Copy link
Member Author

This is why

// Convert a matcher that checks valid messages to a function
// that checks EventInfo structures, returning an error for any that don't
// contain valid events.
func MatchEvent(evf ...cetest.EventMatcher) eventshub.EventInfoMatcher {
	return func(ei eventshub.EventInfo) error {
		if ei.Event == nil {
			return fmt.Errorf("Saw nil event")
		} else {
			return cetest.AllOf(evf...)(*ei.Event)
		}
	}
}

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 20, 2024
Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

finally 🎉

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 20, 2024
@knative-prow knative-prow bot merged commit 18dfe3c into knative:main Jun 20, 2024
35 of 36 checks passed
Copy link

knative-prow bot commented Jun 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: creydr, pierDipi

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

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

None yet

2 participants