Skip to content

[JENKINS-41516] Add script console listener#7056

Merged
NotMyFault merged 47 commits intojenkinsci:masterfrom
daniel-beck:meiswjn-feature-add-script-console-listener
Oct 5, 2023
Merged

[JENKINS-41516] Add script console listener#7056
NotMyFault merged 47 commits intojenkinsci:masterfrom
daniel-beck:meiswjn-feature-add-script-console-listener

Conversation

@daniel-beck
Copy link
Copy Markdown
Member

@daniel-beck daniel-beck commented Sep 2, 2022

Alternative to #6539 (but might still get reintegrated there) by @meiswjn, for now just to get a PR build/incremental deployment.

See JENKINS-41516.

Minor secondary TODOs:

  • Add implementation of extension point outside core (IMO kinda optional since DefaultScriptListener exists)

Proposed changelog entries

  • Developer: Add extension point to notify about in-process scripting events.

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change) and are in the imperative mood. Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadoc, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO") if applicable.
  • New or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content-Security-Policy directives (see documentation on jenkins.io).
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

meiswjn and others added 30 commits April 26, 2022 14:52
Co-authored-by: Wadeck Follonier <Wadeck@users.noreply.github.com>
@daniel-beck daniel-beck added the needs-more-reviews Complex change, which would benefit from more eyes label Aug 29, 2023
Copy link
Copy Markdown
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

nice

@timja timja requested a review from a team September 4, 2023 14:25
@meiswjn
Copy link
Copy Markdown
Contributor

meiswjn commented Oct 2, 2023

One more reviewer! :)

Copy link
Copy Markdown
Member

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

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

Tagging the reviewers that approved the previous PR #6539: NotMyFault @res0nance timja StefanSpieker

My humble apology, I must have missed this PR :(

@meiswjn
Copy link
Copy Markdown
Contributor

meiswjn commented Oct 2, 2023

No worries, thanks for the approval! Looking forward to the release 🚀

@NotMyFault NotMyFault added developer Changes which impact plugin developers and removed needs-more-reviews Complex change, which would benefit from more eyes labels Oct 2, 2023
@timja
Copy link
Copy Markdown
Member

timja commented Oct 2, 2023

/label ready-for-merge


This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Oct 2, 2023
@NotMyFault NotMyFault merged commit 270062a into jenkinsci:master Oct 5, 2023
@NotMyFault
Copy link
Copy Markdown
Member

NotMyFault commented Oct 6, 2023

The tests added in this PR cause failures in the default branch for Windows agents: https://ci.jenkins.io/job/Core/job/jenkins/job/master/5460/testReport/jenkins.model/

Would you mind taking a look and think you can submit a fixup before next Tuesday? Otherwise, I'd revert the merge to restore the test functionality and not break the weekly release.

@NotMyFault NotMyFault changed the title [JENKINS-41516] Add script console listener (alternative/extended proposal) [JENKINS-41516] Add script console listener Oct 6, 2023
@daniel-beck
Copy link
Copy Markdown
Member Author

@NotMyFault Any idea why CI passed for this PR?

@daniel-beck
Copy link
Copy Markdown
Member Author

daniel-beck commented Oct 6, 2023

def target = platform == 'windows' ? '30%' : '100%'

So we're running every test on Linux 3 times (11, 17, and 19), but less than a third of tests on Windows?

@daniel-beck
Copy link
Copy Markdown
Member Author

How do I even confirm a fix PR will work, if this just skips execution of the test I'm fixing?

(Also, seems like a clear bug to not execute new tests.)

@NotMyFault
Copy link
Copy Markdown
Member

def target = platform == 'windows' ? '30%' : '100%'

So we're running every test on Linux 3 times (11, 17, and 19), but less than a third of tests on Windows?

But that's only used for the launchable part, isn't it

jenkins/Jenkinsfile

Lines 113 to 116 in 778b8b6

sh "launchable verify && launchable subset --session ${session} --target ${target} --get-tests-from-previous-sessions --output-exclusion-rules maven >${excludesFile}"
} else {
excludesFile = "${tmpDir}\\excludes.txt"
bat "launchable verify && launchable subset --session ${session} --target ${target}% --get-tests-from-previous-sessions --output-exclusion-rules maven >${excludesFile}"
?

@NotMyFault Any idea why CI passed for this PR?

To be fair, it passed at the end of July, I could've updated this PR before integrating it into master.

@daniel-beck
Copy link
Copy Markdown
Member Author

daniel-beck commented Oct 6, 2023

But that's only used for the launchable part, isn't it

Unsure what you mean. https://ci.jenkins.io/job/Core/job/jenkins/job/PR-7056/12/consoleFull did not run the new test on Windows, just three times on Linux. See https://ci.jenkins.io/job/Core/job/jenkins/job/PR-7056/12/execution/node/273/log/?consoleFull for the Windows output specifically.

@timja
Copy link
Copy Markdown
Member

timja commented Oct 6, 2023

How do I even confirm a fix PR will work, if this just skips execution of the test I'm fixing?

(Also, seems like a clear bug to not execute new tests.)

cc @basil if you have any input on the above ^^

@daniel-beck
Copy link
Copy Markdown
Member Author

How do I even confirm a fix PR will work, if this just skips execution of the test I'm fixing?

Given that it's being executed in an unrelated PR now, this comment is probably obsolete.

@MarkEWaite
Copy link
Copy Markdown
Contributor

Thanks for reporting the issue.

Launchable was enabled months ago to reduce the cost of pull request evaluation. Launchable uses results from previous tests to define a subset of Windows tests that will execute in roughly the same amount of time as the Linux builds require. The full set of Windows tests are run on the master branch after the pull request is merged.

This is the first time since Launchable was enabled that we've had a test failure "escape" from a pull request merge and reach the master branch. I think that the cost savings from limiting Windows tests to approximately one hour (instead of the four hours required on the main branch) are worth this type of rare event.

I agree that the test selection algorithm used by Launchable should add all new tests to the list of tests that it runs. We'll need to report that to them, since others will likely want the same thing. When there is no test result data for a test, add it to the executed set of tests.

@MarkEWaite
Copy link
Copy Markdown
Contributor

I agree that the test selection algorithm used by Launchable should add all new tests to the list of tests that it runs. We'll need to report that to them, since others will likely want the same thing. When there is no test result data for a test, add it to the executed set of tests.

I've reported the issue to Launchable support and copied Kohsuke on the report so that he's aware. Thanks again for detecting the issue!

* {@link java.io.Writer} that calls {@link #fireScriptOutput(String, Object, Object, String, hudson.model.User)} with the
* output it writes to the wrapped {@link java.io.Writer}, and otherwise just forwards {@link #flush()} and {@link #close()}.
*/
class ListenerWriter extends Writer {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is implicitly public. If you did you not mean for this to be part of the API, use @Restricted(NoExternalUse.class). Ditto other members of the interface.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Could go either way. Realistically there are few (possibly none) possible callers of #fire… methods outside core (that possibly could want this), so it might be better to start off @Restricted and open up if necessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

/**
* Basic default implementation of {@link jenkins.util.ScriptListener} that just logs.
*
* @since TODO
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be omitted because it is not part of the API anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I like it to quickly see when a feature was added. While I could get there via git blame, given the negligible cost, this is reasonable to have IMO.

@basil
Copy link
Copy Markdown
Member

basil commented Oct 18, 2023

Causes JENKINS-72181.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

developer Changes which impact plugin developers ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback squash-merge-me Unclean or useless commit history, should be merged only with squash-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants