-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix bugs when concurrent pushing packages #30335
Draft
lunny
wants to merge
9
commits into
go-gitea:main
Choose a base branch
from
lunny:lunny/maven_deploy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7b860dd
Add integration test for concurrent maven deploy
lunny ba342cb
Fix the test
lunny 142fe05
Use insert on duplicate to try insert package
lunny 649128f
Fix lint and update format of SQL
lunny 842d734
Merge branch 'main' into lunny/maven_deploy
lunny dd0ff15
Fix bug
lunny e05ec3a
Fix bug
lunny 83bc1e6
Merge branch 'main' into lunny/maven_deploy
lunny 165d1ae
Fix bug
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"net/http" | ||
"strconv" | ||
"strings" | ||
"sync" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
|
@@ -242,3 +243,35 @@ func TestPackageMaven(t *testing.T) { | |
putFile(t, fmt.Sprintf("/%s/maven-metadata.xml", snapshotVersion), "test-overwrite", http.StatusCreated) | ||
}) | ||
} | ||
|
||
func TestPackageMavenConcurrent(t *testing.T) { | ||
defer tests.PrepareTestEnv(t)() | ||
|
||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) | ||
|
||
groupID := "com.gitea" | ||
artifactID := "test-project" | ||
packageVersion := "1.0.1" | ||
|
||
root := fmt.Sprintf("/api/packages/%s/maven/%s/%s", user.Name, strings.ReplaceAll(groupID, ".", "/"), artifactID) | ||
|
||
putFile := func(t *testing.T, path, content string, expectedStatus int) { | ||
req := NewRequestWithBody(t, "PUT", root+path, strings.NewReader(content)). | ||
AddBasicAuth(user.Name) | ||
MakeRequest(t, req, expectedStatus) | ||
} | ||
|
||
t.Run("Concurrent Upload", func(t *testing.T) { | ||
defer tests.PrintCurrentTest(t)() | ||
|
||
var wg sync.WaitGroup | ||
for i := 0; i < 10; i++ { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this test is not correct - it should look like:
` |
||
wg.Add(1) | ||
go func() { | ||
putFile(t, fmt.Sprintf("/%s/%s.jar", packageVersion, strconv.Itoa(i)), "test", http.StatusCreated) | ||
wg.Done() | ||
}() | ||
} | ||
wg.Wait() | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line should look like:
"INSERT INTO package (owner_id,
type,lower_name,name,semver_compatible) VALUES (?,?,?,?,?) ON CONFLICT (owner_id,
type,lower_name) DO UPDATE SET lower_name=EXCLUDED.lower_name"