aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-05-30 15:33:50 +0800
committerGitHub <noreply@github.com>2024-05-30 07:33:50 +0000
commitfb7b743bd0f305a6462896398bcba2a74c6e391e (patch)
treeab821590da64878c10c369fea6c6ca9221d04085 /tests
parent015efcd8bfd451ef593192eb43cfcfb7001f7861 (diff)
downloadgitea-fb7b743bd0f305a6462896398bcba2a74c6e391e.tar.gz
gitea-fb7b743bd0f305a6462896398bcba2a74c6e391e.zip
Azure blob storage support (#30995)
This PR implemented object storages(LFS/Packages/Attachments and etc.) for Azure Blob Storage. It depends on azure official golang SDK and can support both the azure blob storage cloud service and azurite mock server. Replace #25458 Fix #22527 - [x] CI Tests - [x] integration test, MSSQL integration tests will now based on azureblob - [x] unit test - [x] CLI Migrate Storage - [x] Documentation for configuration added ------ TODO (other PRs): - [ ] Improve performance of `blob download`. --------- Co-authored-by: yp05327 <576951401@qq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_packages_generic_test.go31
-rw-r--r--tests/mssql.ini.tmpl12
-rw-r--r--tests/pgsql.ini.tmpl3
3 files changed, 28 insertions, 18 deletions
diff --git a/tests/integration/api_packages_generic_test.go b/tests/integration/api_packages_generic_test.go
index 1cbae599af..baa8dd66c8 100644
--- a/tests/integration/api_packages_generic_test.go
+++ b/tests/integration/api_packages_generic_test.go
@@ -144,18 +144,29 @@ func TestPackageGeneric(t *testing.T) {
t.Run("ServeDirect", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
- if setting.Packages.Storage.Type != setting.MinioStorageType {
- t.Skip("Test skipped for non-Minio-storage.")
+ if setting.Packages.Storage.Type != setting.MinioStorageType && setting.Packages.Storage.Type != setting.AzureBlobStorageType {
+ t.Skip("Test skipped for non-Minio-storage and non-AzureBlob-storage.")
return
}
- if !setting.Packages.Storage.MinioConfig.ServeDirect {
- old := setting.Packages.Storage.MinioConfig.ServeDirect
- defer func() {
- setting.Packages.Storage.MinioConfig.ServeDirect = old
- }()
-
- setting.Packages.Storage.MinioConfig.ServeDirect = true
+ if setting.Packages.Storage.Type == setting.MinioStorageType {
+ if !setting.Packages.Storage.MinioConfig.ServeDirect {
+ old := setting.Packages.Storage.MinioConfig.ServeDirect
+ defer func() {
+ setting.Packages.Storage.MinioConfig.ServeDirect = old
+ }()
+
+ setting.Packages.Storage.MinioConfig.ServeDirect = true
+ }
+ } else if setting.Packages.Storage.Type == setting.AzureBlobStorageType {
+ if !setting.Packages.Storage.AzureBlobConfig.ServeDirect {
+ old := setting.Packages.Storage.AzureBlobConfig.ServeDirect
+ defer func() {
+ setting.Packages.Storage.AzureBlobConfig.ServeDirect = old
+ }()
+
+ setting.Packages.Storage.AzureBlobConfig.ServeDirect = true
+ }
}
req := NewRequest(t, "GET", url+"/"+filename)
@@ -168,7 +179,7 @@ func TestPackageGeneric(t *testing.T) {
resp2, err := (&http.Client{}).Get(location)
assert.NoError(t, err)
- assert.Equal(t, http.StatusOK, resp2.StatusCode)
+ assert.Equal(t, http.StatusOK, resp2.StatusCode, location)
body, err := io.ReadAll(resp2.Body)
assert.NoError(t, err)
diff --git a/tests/mssql.ini.tmpl b/tests/mssql.ini.tmpl
index 07997f62ed..77c969e813 100644
--- a/tests/mssql.ini.tmpl
+++ b/tests/mssql.ini.tmpl
@@ -53,9 +53,6 @@ APP_DATA_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data
BUILTIN_SSH_SERVER_USER = git
SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXWo7GMxTchtzmJHYzfN6sZ9FAPFR4ijMLfGki+olvOMO5Fql1/yGnGfbELQa1S6y4shSvj/5K+zUFScmEXYf3Gcr87RqilLkyk16RS+cHNB1u87xTHbETaa3nyCJeGQRpd4IQ4NKob745mwDZ7jQBH8AZEng50Oh8y8fi8skBBBzaYp1ilgvzG740L7uex6fHV62myq0SXeCa+oJUjq326FU8y+Vsa32H8A3e7tOgXZPdt2TVNltx2S9H2WO8RMi7LfaSwARNfy1zu+bfR50r6ef8Yx5YKCMz4wWb1SHU1GS800mjOjlInLQORYRNMlSwR1+vLlVDciOqFapDSbj+YOVOawR0R1aqlSKpZkt33DuOBPx9qe6CVnIi7Z+Px/KqM+OLCzlLY/RS+LbxQpDWcfTVRiP+S5qRTcE3M3UioN/e0BE/1+MpX90IGpvVkA63ILYbKEa4bM3ASL7ChTCr6xN5XT+GpVJveFKK1cfNx9ExHI4rzYE=
-[attachment]
-PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/attachments
-
[mailer]
ENABLED = true
PROTOCOL = dummy
@@ -102,8 +99,13 @@ SECRET_KEY = 9pCviYTWSb
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
DISABLE_QUERY_AUTH_TOKEN = true
-[lfs]
-PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/lfs
+[storage]
+STORAGE_TYPE = azureblob
+AZURE_BLOB_ENDPOINT = http://devstoreaccount1.azurite.local:10000
+AZURE_BLOB_ACCOUNT_NAME = devstoreaccount1
+AZURE_BLOB_ACCOUNT_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
+AZURE_BLOB_CONTAINER = gitea
+SERVE_DIRECT = false
[packages]
ENABLED = true
diff --git a/tests/pgsql.ini.tmpl b/tests/pgsql.ini.tmpl
index 486cfc945c..6b54f790c5 100644
--- a/tests/pgsql.ini.tmpl
+++ b/tests/pgsql.ini.tmpl
@@ -54,9 +54,6 @@ APP_DATA_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-pgsql/data
BUILTIN_SSH_SERVER_USER = git
SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXWo7GMxTchtzmJHYzfN6sZ9FAPFR4ijMLfGki+olvOMO5Fql1/yGnGfbELQa1S6y4shSvj/5K+zUFScmEXYf3Gcr87RqilLkyk16RS+cHNB1u87xTHbETaa3nyCJeGQRpd4IQ4NKob745mwDZ7jQBH8AZEng50Oh8y8fi8skBBBzaYp1ilgvzG740L7uex6fHV62myq0SXeCa+oJUjq326FU8y+Vsa32H8A3e7tOgXZPdt2TVNltx2S9H2WO8RMi7LfaSwARNfy1zu+bfR50r6ef8Yx5YKCMz4wWb1SHU1GS800mjOjlInLQORYRNMlSwR1+vLlVDciOqFapDSbj+YOVOawR0R1aqlSKpZkt33DuOBPx9qe6CVnIi7Z+Px/KqM+OLCzlLY/RS+LbxQpDWcfTVRiP+S5qRTcE3M3UioN/e0BE/1+MpX90IGpvVkA63ILYbKEa4bM3ASL7ChTCr6xN5XT+GpVJveFKK1cfNx9ExHI4rzYE=
-[attachment]
-PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-pgsql/data/attachments
-
[mailer]
ENABLED = true
PROTOCOL = dummy