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

Random unit test failure in TestRepository_GetAnnotatedTag #18444

Closed
zeripath opened this issue Jan 29, 2022 · 6 comments · Fixed by #18447
Closed

Random unit test failure in TestRepository_GetAnnotatedTag #18444

zeripath opened this issue Jan 29, 2022 · 6 comments · Fixed by #18447

Comments

@zeripath
Copy link
Contributor

Gitea Version

1.15.x/1.16.x/main

Git Version

On CI

Operating System

Linux

How are you running Gitea?

In the CI

Database

SQLite

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

TestRepository_GetAnnotatedTag (0.24s)
    repo_tag_test.go:90: 
        	Error Trace:	repo_tag_test.go:90
        	Error:      	Received unexpected error:
        	            	exit status 128 - fatal: destination path 'tests/repos/repo1_TestRepository_GetTag' already exists and is not an empty directory.

This test and the rest of the tests in this file should be changed to clone into random temporary directories:

func TestRepository_GetAnnotatedTag(t *testing.T) {
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
clonedPath, err := cloneRepo(bareRepo1Path, testReposDir, "repo1_TestRepository_GetTag")
assert.NoError(t, err)
defer util.RemoveAll(clonedPath)

Screenshots

No response

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jan 29, 2022

Some more related issues (maybe not related, just FYI):

Some comments before:

  • wxiaoguang: I guess the problem is possibly caused by concurrent running tests, or async queue tasks, some of them may conflict.
  • singuliere: After adding -cpu=1 to unit-test-coverage I did not exprience any random failure when running drone exec --pipeline testing-amd64 .drone.yml locally on my laptop.

@zeripath
Copy link
Contributor Author

Thanks for the link to the summary issue.

Whilst the summary issues can be helpful - the solutions and causes for them are going to be disparate and so unless some work is done to investigate each cause in turn it's not going to be solved.

I've opened this issue as I've just done that work for this particular failure.

In this case although I'm not completely aware of why the "temp" path being already extant causes the problem or how it could already be extant - it's clear that the solution would be to use a real individual temporary path for each one in turn.

A pr doing that would be simple and if no one does it before me I will put one in later today.

zeripath added a commit to zeripath/gitea that referenced this issue Jan 29, 2022
There are a few places where tests appear to reuse testing repos which
causes random CI failures.

This PR simply changes these tests to ensure that cloning always happens
into new temporary directories.

Fix go-gitea#18444

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

zeripath commented Jan 29, 2022

Case 6 in #17719 should be fixed by the attached PR.

@zeripath
Copy link
Contributor Author

Case 3 in #17719 is slightly related to this PR - however, I think it's particularly interesting as it implies that the testcase repositories aren't available. This is weird and probably indicates some error higher up whereby the test repos haven't been cloned properly or a testcase is actually deleting them.

It may be that this PR fixes this case too.

@wxiaoguang
Copy link
Contributor

Cool, then we can close #17719 (it's a little old) by the new PR, then if we meet new errors, we record them in a new issue.

@zeripath
Copy link
Contributor Author

Dunno maybe we should keep it open - there are more than a few cases in there that haven't been properly addressed, but we may want to open individual issues for each as we investigate them.

zeripath added a commit that referenced this issue Jan 29, 2022
* Ensure git tag tests and other create test repos in tmpdir

There are a few places where tests appear to reuse testing repos which
causes random CI failures.

This PR simply changes these tests to ensure that cloning always happens
into new temporary directories.

Fix #18444

* Change log root for integration tests to use the REPO_TEST_DIR

There is a potential race in the drone integration tests whereby test-mysql etc
will start writing to log files causing make test-check fail.

Fix #18077

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Feb 14, 2022
…#18447)

Backport go-gitea#18447

* Ensure git tag tests and other create test repos in tmpdir

There are a few places where tests appear to reuse testing repos which
causes random CI failures.

This PR simply changes these tests to ensure that cloning always happens
into new temporary directories.

Fix go-gitea#18444

* Change log root for integration tests to use the REPO_TEST_DIR

There is a potential race in the drone integration tests whereby test-mysql etc
will start writing to log files causing make test-check fail.

Fix go-gitea#18077

Signed-off-by: Andrew Thornton <art27@cantab.net>
lunny pushed a commit that referenced this issue Feb 15, 2022
…18767)

Backport #18447

* Ensure git tag tests and other create test repos in tmpdir

There are a few places where tests appear to reuse testing repos which
causes random CI failures.

This PR simply changes these tests to ensure that cloning always happens
into new temporary directories.

Fix #18444

* Change log root for integration tests to use the REPO_TEST_DIR

There is a potential race in the drone integration tests whereby test-mysql etc
will start writing to log files causing make test-check fail.

Fix #18077

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
…#18447)

* Ensure git tag tests and other create test repos in tmpdir

There are a few places where tests appear to reuse testing repos which
causes random CI failures.

This PR simply changes these tests to ensure that cloning always happens
into new temporary directories.

Fix go-gitea#18444

* Change log root for integration tests to use the REPO_TEST_DIR

There is a potential race in the drone integration tests whereby test-mysql etc
will start writing to log files causing make test-check fail.

Fix go-gitea#18077

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants