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

org.eclipse.ui.tests.dialogs.UIEditWorkingSetWizardAuto.testEditPage fails on windows in the I-build intermittently #275

Closed
ktatavarthi opened this issue Aug 18, 2022 · 13 comments · Fixed by #1893

Comments

@ktatavarthi
Copy link
Member

The test org.eclipse.ui.tests.dialogs.UIEditWorkingSetWizardAuto.testEditPage failed in the IBuild I20220817-1800 on Windows with the below error

Problems encountered while deleting resources.

junit.framework.AssertionFailedError: Problems encountered while deleting resources.
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:223)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.deleteResources(UIWorkingSetWizardsAuto.java:102)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.doTearDown(UIWorkingSetWizardsAuto.java:169)
at org.eclipse.ui.tests.harness.util.UITestCase.tearDown(UITestCase.java:214) 
@ktatavarthi
Copy link
Member Author

The test org.eclipse.ui.tests.dialogs.UIEditWorkingSetWizardAuto.testEditPage failed in the IBuild I20220824-1800 on Windows with the below error

Problems encountered while deleting resources.

junit.framework.AssertionFailedError: Problems encountered while deleting resources.
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:223)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.deleteResources(UIWorkingSetWizardsAuto.java:102)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.doTearDown(UIWorkingSetWizardsAuto.java:169)
at org.eclipse.ui.tests.harness.util.UITestCase.tearDown(UITestCase.java:214) 

@fedejeanne
Copy link
Contributor

It failed also during this PR-Build on May 2023.

fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 1, 2023
fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 1, 2023
fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 1, 2023
fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 2, 2023
…ipse-platform#275

Find the most severe status in the caught exception and use its stack
trace in order to be able to see where the error originated.
fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 2, 2023
…ipse-platform#275

Find the most severe status in the caught exception and use its stack
trace in order to be able to see where the error originated.
fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 2, 2023
…ipse-platform#275

Find the most severe status in the caught exception and use its stack
trace in order to be able to see where the error originated.
@fedejeanne
Copy link
Contributor

fedejeanne commented Jun 5, 2023

#790 should help identify the problem

akurtakov pushed a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 10, 2023
…ipse-platform#275

Find the most severe status in the caught exception and use its stack
trace in order to be able to see where the error originated.
fedejeanne added a commit to fedejeanne/eclipse.platform.ui that referenced this issue Jun 21, 2023
…ipse-platform#275

Find the most severe status in the caught exception and use its stack
trace in order to be able to see where the error originated.
HeikoKlare pushed a commit that referenced this issue Jun 21, 2023
Find the most severe status in the caught exception and use its stack
trace in order to be able to see where the error originated.
@jukzi
Copy link
Contributor

jukzi commented Jul 14, 2023

@HeikoKlare happended today again:
https://download.eclipse.org/eclipse/downloads/drops4/I20230713-1800/testresults/html/org.eclipse.ui.tests_ep429I-unit-win32-java17_win32.win32.x86_64_17.html

java.lang.AssertionError: Problems encountered while deleting resources.
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.createAssertionError(UIWorkingSetWizardsAuto.java:115)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.deleteResources(UIWorkingSetWizardsAuto.java:103)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.doTearDown(UIWorkingSetWizardsAuto.java:199)
at org.eclipse.ui.tests.harness.util.UITestCase.tearDown(UITestCase.java:214)

@fedejeanne
Copy link
Contributor

I just noticed I hadn't properly tagged this issue in #560.
fyi my PR aims to help identify the underlying error with a more meaningful stack trace.

@HeikoKlare
Copy link
Contributor

HeikoKlare commented Jul 17, 2023

A proper stack trace is already provided in the logs. For example, a recent failing IBuild shows:

!MESSAGE Could not delete 'C:\Users\genie.releng\workspace\AutomatedTests\ep429I-unit-win32-java17\workarea\I20230713-1800\eclipse-testing\test-eclipse\eclipse\ui_sniff_folder\TP2\.project'.
!STACK 1
org.eclipse.core.runtime.CoreException: Problems encountered while deleting files.
	at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:163)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFile(ResourceTree.java:316)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteProject(ResourceTree.java:437)
	at org.eclipse.core.internal.resources.ResourceTree.standardDeleteProject(ResourceTree.java:856)
	at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1843)
	at org.eclipse.core.internal.resources.Resource.delete(Resource.java:808)
	at org.eclipse.core.internal.resources.Project.delete(Project.java:365)
	at org.eclipse.ui.tests.harness.util.FileUtil.deleteProject(FileUtil.java:61)
	at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.deleteResources(UIWorkingSetWizardsAuto.java:98)
	at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.doTearDown(UIWorkingSetWizardsAuto.java:199)
	at org.eclipse.ui.tests.harness.util.UITestCase.tearDown(UITestCase.java:214)

and

Contains: Could not delete: C:\Users\genie.releng\workspace\AutomatedTests\ep429I-unit-win32-java17\workarea\I20230713-1800\eclipse-testing\test-eclipse\eclipse\ui_sniff_folder\TP2\.project.
java.nio.file.FileSystemException: C:\Users\genie.releng\workspace\AutomatedTests\ep429I-unit-win32-java17\workarea\I20230713-1800\eclipse-testing\test-eclipse\eclipse\ui_sniff_folder\TP2\.project: The process cannot access the file because it is being used by another process
	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:275)
	at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:110)
	at java.base/java.nio.file.Files.deleteIfExists(Files.java:1191)
	at org.eclipse.core.internal.filesystem.local.LocalFile.internalDelete(LocalFile.java:244)

So for some reason the .project file is locked while the test tries to delete the project during cleanup.

HeikoKlare added a commit to HeikoKlare/eclipse.platform.ui that referenced this issue Jul 17, 2023
The UIEditWorkingSetWizardAuto#testEditPage randomly fails because the
project deletion during test cleanup fails. The project file of the
second project to be deleted is already locked.

To avoid that the deletion of the first project triggers some
asynchronous tasks that interfere with the deletion of the second
project, this change combines both deletions into an atomic workspace
operation. In addition, the change separates the exception handling for
both projects to see from the stack trace which of the deletions caused
the exception.

Contributes to
eclipse-platform#275
@HeikoKlare
Copy link
Contributor

You can provoke the error by manually locking the .project file by, e.g., executing FileChannel.open(pathToProjectFile, StandardOpenOption.APPEND).lock(); somewhere before resource deletion.

I could not figure out yet who concurrently accesses the file. I expect it to be some asynchronous task executed within the workspace (but thats rather a gut feeling than an analysis result).
Some slightly more analytic result: The logs show that the exception occurs during deletion of the second project. Since a project.delete triggers some actions (such as an auto build), I can image that the (asynchronously executed) effects of project.delete for the first project interfere with the deletion of the second project.
If that was really the case, it would point to some other issue, since there should, in my opinion, never be an access exception when trying to delete a project just because there is some asynchronous task running in the workspace.

I propose to simply put the two project deletions into a single workspace operation to avoid this potential kind of interference. That won't break anything and we can have a look at subsequent build results to figure out if that "solves" the issue. I have proposed an according PR in #941.

@jukzi
Copy link
Contributor

jukzi commented Jul 17, 2023

On windows it may just be that the filehandle was opened and not closed. You could debug where it is opened and verify if it's closed.

@HeikoKlare
Copy link
Contributor

Yes, it could be the case that the file handle was not closed somewhere. Then this would (probably) be a symptom of some bug in the workspace code, as the test itself does not access the .project file.

In terms of debugging, I tried to do something similar, but during local execution I was not able to provoke any concurrent access to the file. I locked the file handle at the beginning of the test and waited for a significant amount of time before teardown to give workers (auto build, refresh etc.) the chance to perform their work, but the test only fails during teardown (when trying to delete the resource). So either no other asynchronous operations tried to lock the file in between or these other operations silently accept that the file is already locked.

Your proposal sound like "watching" the .project file handle after it has been created. Do you know some "easy" way to do that? From my understanding, this would require debugging at the Windows file system abstraction layer in Java. Since that may require quite some effort, I would defer that step and first see whether #941 gives some further insights.

HeikoKlare added a commit that referenced this issue Jul 18, 2023
The UIEditWorkingSetWizardAuto#testEditPage randomly fails because the
project deletion during test cleanup fails. The project file of the
second project to be deleted is already locked.

To avoid that the deletion of the first project triggers some
asynchronous tasks that interfere with the deletion of the second
project, this change combines both deletions into an atomic workspace
operation. In addition, the change separates the exception handling for
both projects to see from the stack trace which of the deletions caused
the exception.

Contributes to
#275
@HeikoKlare
Copy link
Contributor

HeikoKlare added a commit to HeikoKlare/eclipse.platform.ui that referenced this issue Jul 21, 2023
…m#275

The tests for working set wizards change the workspace's working sets
without resetting them afterwards. Instead, they cleanup working sets
during test setup. In addition, workspace resources are cleaned up
selectively after test execution instead of cleaning up the workspace
resources into total.

This change addresses this a follows:
- Cleans up working set changes after test execution
- Improves resource cleanup by deleting all workspace resources
- Refactors test implementations by improving encapsulation in test
classes to avoid unwanted/undetected side effects that may be related to
random failures of UIEditWorkingSetWizardAuto.testEditPage
praveen-skp pushed a commit to praveen-skp/eclipse.platform.ui that referenced this issue Aug 8, 2023
The UIEditWorkingSetWizardAuto#testEditPage randomly fails because the
project deletion during test cleanup fails. The project file of the
second project to be deleted is already locked.

To avoid that the deletion of the first project triggers some
asynchronous tasks that interfere with the deletion of the second
project, this change combines both deletions into an atomic workspace
operation. In addition, the change separates the exception handling for
both projects to see from the stack trace which of the deletions caused
the exception.

Contributes to
eclipse-platform#275
praveen-skp pushed a commit to praveen-skp/eclipse.platform.ui that referenced this issue Aug 8, 2023
…m#275

The tests for working set wizards change the workspace's working sets
without resetting them afterwards. Instead, they cleanup working sets
during test setup. In addition, workspace resources are cleaned up
selectively after test execution instead of cleaning up the workspace
resources into total.

This change addresses this a follows:
- Cleans up working set changes after test execution
- Improves resource cleanup by deleting all workspace resources
- Refactors test implementations by improving encapsulation in test
classes to avoid unwanted/undetected side effects that may be related to
random failures of UIEditWorkingSetWizardAuto.testEditPage

Contributes to eclipse-platform#275
@Shee43
Copy link
Contributor

Shee43 commented Sep 29, 2023

The test org.eclipse.ui.tests.dialogs.UIEditWorkingSetWizardAuto.testEditPage failed in the IBuild I20230927-1800 on Windows with the below error

Problems encountered while deleting resources.

java.lang.AssertionError: Problems encountered while deleting resources.
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.createAssertionError(UIWorkingSetWizardsAuto.java:156)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.cleanupWorkspace(UIWorkingSetWizardsAuto.java:141)
at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.doTearDown(UIWorkingSetWizardsAuto.java:123)
at org.eclipse.ui.tests.harness.util.UITestCase.tearDown(UITestCase.java:214)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

@Wittmaxi
Copy link
Contributor

Wittmaxi commented Apr 9, 2024

@HeikoKlare printing out the stacktrace when the test fails yields this:
grafik
(Error in English: "The process cannot access the file because it is being used by another process")

it looks like a file-lock is not yet reclaimed at the time we are trying to delete the file

I reproduced the error by running the test 100 times at once using this code (https://stackoverflow.com/questions/1492856/easy-way-of-running-the-same-junit-test-over-and-over):

/**
 * Tests the WorkingSetEditWizard Tests input validation, presence of correct
 * edit page and wizard page texts.
 */
@RunWith(Parameterized.class)
public class UIEditWorkingSetWizardAuto extends UIWorkingSetWizardsAuto<WorkingSetEditWizard> {

	public UIEditWorkingSetWizardAuto() {
		super(UIEditWorkingSetWizardAuto.class.getSimpleName());
	}

	@Parameterized.Parameters
	public static Object[][] data() {
		return new Object[100][0];
	}

From my few experiments, I estimate it to occur roughly 3% of the runs

Wittmaxi added a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 9, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes and editors before deleting the
files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
Wittmaxi added a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 10, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
Wittmaxi added a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 11, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
Wittmaxi added a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 12, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
Wittmaxi added a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 12, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
HeikoKlare pushed a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 16, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
Wittmaxi added a commit to Wittmaxi/eclipse.platform.ui that referenced this issue Apr 16, 2024
…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
HeikoKlare pushed a commit that referenced this issue Apr 17, 2024
In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

#275
@HeikoKlare
Copy link
Contributor

Failure still occurs after fix attempt in #1803.
See for example this build: https://github.com/eclipse-platform/eclipse.platform.ui/pull/1823/checks?check_run_id=23971305789

Problems encountered while deleting resources.
java.lang.AssertionError: Problems encountered while deleting resources.
	at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.createAssertionError(UIWorkingSetWizardsAuto.java:156)
	at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.cleanupWorkspace(UIWorkingSetWizardsAuto.java:141)
	at org.eclipse.ui.tests.dialogs.UIWorkingSetWizardsAuto.doTearDown(UIWorkingSetWizardsAuto.java:123)
	at org.eclipse.ui.tests.dialogs.UIEditWorkingSetWizardAuto.doTearDown(UIEditWorkingSetWizardAuto.java:158)
	at org.eclipse.ui.tests.harness.util.UITestCase.tearDown(UITestCase.java:214)

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 a pull request may close this issue.

6 participants