aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_repo_file_create_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-04-16 20:30:16 +0200
committerGitHub <noreply@github.com>2021-04-16 20:30:16 +0200
commita67861b4dc7809e025240f18a5d60b10c6dcd6b5 (patch)
tree691dbe44218d10b930b978e40745b872d8fe59a6 /integrations/api_repo_file_create_test.go
parentc29e85228ff3b524cbe0cd4c8893109c4facc022 (diff)
downloadgitea-a67861b4dc7809e025240f18a5d60b10c6dcd6b5.tar.gz
gitea-a67861b4dc7809e025240f18a5d60b10c6dcd6b5.zip
Fix Benchmark tests, remove a broken one & add two new (#15250)
* Benchmark Integration TESTS * CI: add benching-arm64 pipeline * BenchmarkRepo: name test case tests * Fix BenchmarkRepoBranchCommit beside Create new Branch * CI: benching use amd64 * rm total broken "BenchmarkRepo" * dont run benchmark in CI
Diffstat (limited to 'integrations/api_repo_file_create_test.go')
-rw-r--r--integrations/api_repo_file_create_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/integrations/api_repo_file_create_test.go b/integrations/api_repo_file_create_test.go
index 853224f091..17ed6cb7cf 100644
--- a/integrations/api_repo_file_create_test.go
+++ b/integrations/api_repo_file_create_test.go
@@ -105,6 +105,36 @@ func getExpectedFileResponseForCreate(commitID, treePath string) *api.FileRespon
}
}
+func BenchmarkAPICreateFileSmall(b *testing.B) {
+ onGiteaRunTB(b, func(t testing.TB, u *url.URL) {
+ b := t.(*testing.B)
+ user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo1 & repo16
+ repo1 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) // public repo
+
+ for n := 0; n < b.N; n++ {
+ treePath := fmt.Sprintf("update/file%d.txt", n)
+ createFileInBranch(user2, repo1, treePath, repo1.DefaultBranch, treePath)
+ }
+ })
+}
+
+func BenchmarkAPICreateFileMedium(b *testing.B) {
+ data := make([]byte, 10*1024*1024)
+
+ onGiteaRunTB(b, func(t testing.TB, u *url.URL) {
+ b := t.(*testing.B)
+ user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo1 & repo16
+ repo1 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) // public repo
+
+ b.ResetTimer()
+ for n := 0; n < b.N; n++ {
+ treePath := fmt.Sprintf("update/file%d.txt", n)
+ copy(data, treePath)
+ createFileInBranch(user2, repo1, treePath, repo1.DefaultBranch, treePath)
+ }
+ })
+}
+
func TestAPICreateFile(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo1 & repo16