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

I209: Display team stderr to judges #907

Merged
merged 5 commits into from
Jan 27, 2024

Conversation

SamanwaySadhu
Copy link
Collaborator

@SamanwaySadhu SamanwaySadhu commented Dec 30, 2023

Description of what the PR does

  • Updated Executable class to now save Team stderr for each test case in a file and return the list of files
  • Updated SelectJudgmentPaneNew to receive list of team stderr files from executable and forward it to TestResultsPane
  • Updated TestResultsFrame to forward list of team stderr files to TestResultsPane
  • Updated TestResultsPane to add a new column for team stderr and show the stderr upon button click
  • Updated TestCaseResultsTableModel to handle new column for team stderr
  • Updated TestResultsRowData to handle new column for team stder

Issue which the PR addresses

Fixes #209

Environment in which the PR was developed (OS, IDE, Java version, etc.)

Windows 10, Eclipse 2021-12 R, JDK 8u381 (1.8), C++ 13.2.0

Precise steps for testing the PR (i.e., how to demonstrate that it works correctly)

  • Run the Ant script build.xml in the pc2v9 project.
  • Start a PC2 server, loading a sample contest such as "SumitHello".
  • Start a PC2 Admin.
  • In Problems pane make sure one of the problems have judging type set to Manual, if not edit and set to Manual.
  • In Auto Judge pane make sure one of the judges have Problems (none selected), if not edit and set.
  • Start the contest.
  • Start a PC2 team.
  • Make a submission for a problem which had manual judging type set.
  • It is usually hard to get to receive execution time STDERR. I set C++ and simulated using cerr. Need to be tested for other languages.
  • Starte a PC2 judge. Make sure to use the one which no problems set for auto-judge.
  • Select the submission from New Runs pane and request run.
  • In Select Judgement for Run {:id} window click on Execute Run.
  • In Test Results for Run {:id} you should see a new column name Team StdErr. Click on View to view the StdErr.
    image

Additional Context

  • CI: In All Runs pane if we try to Rejudge, then View Outputs and Data and then try to view any Team Output/Stderr, etc. it throws NullPointerException error. This is because in TestResultsPane lines 2199 and 2209 it checks for the condition currentTeamOutputFileNames != null || currentTeamOutputFileNames.length >= row and because the condition has OR it checks for the length even if the variable is null.
    Resolution: Changed the condition to AND i.e. &&.
  • CI: The above issue occurs because the list variable is null which should not happen technically. This is because all the output/stderr, etc. files are created in a temporary folder executesiteNjudgeM and the contents are deleted each time SelectJudgementFrame is called. Currently a testcase output and stderr is being stored in a SerializedFile in ExecutionData object of Executable class and it gets overwritten for each test case (can be resolved by making it a list of SerilizedFiles). However the Executable/ExecutionData object is not saved anywhere in PC2 database. The TestResultsPane table is being populated using objects of Run, RunFiles, RunTestCase (it stores only the verdict) but they do not store the actual output/stderr.
    Resolution: Need to be researched more. It is a potential roadblock to solving issues Provide a way for a judge to re-execute/judge a single test case #35, On Judge UI add feature to execute all test cases if stop-on-first-failed-test-case is true #39, etc.

@SamanwaySadhu SamanwaySadhu marked this pull request as ready for review December 30, 2023 10:10
@johnbrvc johnbrvc added this to the 9.10.0 milestone Jan 4, 2024
@clevengr clevengr requested review from clevengr and johnbrvc January 4, 2024 03:40
Copy link
Collaborator

@johnbrvc johnbrvc left a comment

Choose a reason for hiding this comment

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

Code looks good, and the PR works as described.

Further testing (than mentioned in the PR) was performed and a couple of issues were found (not related directly to the fixes made by this PR, but it makes sense to include these fixes in the PR as CI):

  1. Judge the run as "Yes" (Accepted).
  2. Select the accepted run from the "All Runs" tab.
  3. Select "Rejudge".
  4. Select "View Outputs & Data"

One would expect you could select "View" under "Team Output" or "Team StdErr" and see the corresponding outputs. In reality what happens is a NPE exception is generated in TestResultsPane.getFileForTableCell() because "currentTeamOutputFileNames" is null. The tests are wrong on lines 2199:

if (currentTeamOutputFileNames != null || currentTeamOutputFileNames.length >= row) {
and 2209:

if (currentTeamStderrFileNames != null || currentTeamStderrFileNames.length >= row) {
the || should be an &&. If the member is null, it will try to get "null.length" which is an NPE. This code was always there for the currentTeamOutputFileNames case. Both of these cases should be fixed as a CI.
But, the real problem is WHY are those null in the first place (they shouldn't be). The reason appears to be another problem that has always been there. Executable goes out of its way to create the stdout and stderr file lists, but it never saves them in the ExecutionData for the judgement. See class RunResultsFile. The methods setExeuteStdoutFile() and setExecuteStderrFile() are never called to actually set the information to be saved in executionData. This is a legacy bug apparently. This can be fixed as well under a CI with this PR IMHO.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at edu.csus.ecs.pc2.ui.TestResultsPane.getFileForTableCell(TestResultsPane.java:2209) at edu.csus.ecs.pc2.ui.TestResultsPane.viewFile(TestResultsPane.java:2065) at edu.csus.ecs.pc2.ui.TestResultsPane$19.mouseClicked(TestResultsPane.java:1748) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270) at java.awt.Component.processMouseEvent(Component.java:6542) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6304) at java.awt.Container.processEvent(Container.java:2239) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2297) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4544) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476) at java.awt.Container.dispatchEventImpl(Container.java:2283) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84) at java.awt.EventQueue$4.run(EventQueue.java:733) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:730) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@johnbrvc johnbrvc requested a review from troy2914 January 11, 2024 21:43
@clevengr
Copy link
Contributor

Code looks good, and the PR works as described.

Further testing (than mentioned in the PR) was performed and a couple of issues were found (not related directly to the fixes made by this PR, but it makes sense to include these fixes in the PR as CI):

  1. Judge the run as "Yes" (Accepted).
  2. Select the accepted run from the "All Runs" tab.
  3. Select "Rejudge".
  4. Select "View Outputs & Data"

One would expect you could select "View" under "Team Output" or "Team StdErr" and see the corresponding outputs. In reality what happens is a NPE exception is generated in TestResultsPane.getFileForTableCell() because "currentTeamOutputFileNames" is null. The tests are wrong on lines 2199:

if (currentTeamOutputFileNames != null || currentTeamOutputFileNames.length >= row) { and 2209:

if (currentTeamStderrFileNames != null || currentTeamStderrFileNames.length >= row) { the || should be an &&. If the member is null, it will try to get "null.length" which is an NPE. This code was always there for the currentTeamOutputFileNames case. Both of these cases should be fixed as a CI. But, the real problem is WHY are those null in the first place (they shouldn't be). The reason appears to be another problem that has always been there. Executable goes out of its way to create the stdout and stderr file lists, but it never saves them in the ExecutionData for the judgement. See class RunResultsFile. The methods setExeuteStdoutFile() and setExecuteStderrFile() are never called to actually set the information to be saved in executionData. This is a legacy bug apparently. This can be fixed as well under a CI with this PR IMHO.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at edu.csus.ecs.pc2.ui.TestResultsPane.getFileForTableCell(TestResultsPane.java:2209) at edu.csus.ecs.pc2.ui.TestResultsPane.viewFile(TestResultsPane.java:2065) at edu.csus.ecs.pc2.ui.TestResultsPane$19.mouseClicked(TestResultsPane.java:1748) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270) at java.awt.Component.processMouseEvent(Component.java:6542) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6304) at java.awt.Container.processEvent(Container.java:2239) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2297) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4544) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476) at java.awt.Container.dispatchEventImpl(Container.java:2283) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84) at java.awt.EventQueue$4.run(EventQueue.java:733) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:730) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Great catch, John. I completely agree these issues can and should be fixed as part of this PR, under the banner of "Continuous Improvement".

Copy link
Collaborator

@johnbrvc johnbrvc left a comment

Choose a reason for hiding this comment

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

Discussed with @SamanwaySadhu the one CI that I asked about, namely, just setting the output/stderr files so they are preserved. That will not work, it is more involved than that, and out of scope of this PR. As such, as separate issue was be created (#916).

@johnbrvc johnbrvc merged commit be8ca61 into pc2ccs:develop Jan 27, 2024
3 checks passed
@SamanwaySadhu SamanwaySadhu deleted the I209_display_team_stderr branch January 28, 2024 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Judge should be able to view Team StdErr output
3 participants