Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
293c51e3
Commit
293c51e3
authored
Feb 15, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove more BG migration spec dependencies
For the `PrepareUntrackedUploads` spec.
parent
348c60d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
17 deletions
+26
-17
spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
...b/background_migration/populate_untracked_uploads_spec.rb
+2
-2
spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
...ab/background_migration/prepare_untracked_uploads_spec.rb
+15
-11
spec/support/track_untracked_uploads_helpers.rb
spec/support/track_untracked_uploads_helpers.rb
+9
-4
No files found.
spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
View file @
293c51e3
...
...
@@ -38,8 +38,8 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra
untracked_files_for_uploads
.
create!
(
path:
get_uploads
(
user2
,
'User'
).
first
.
path
)
untracked_files_for_uploads
.
create!
(
path:
get_uploads
(
project1
,
'Project'
).
first
.
path
)
untracked_files_for_uploads
.
create!
(
path:
get_uploads
(
project2
,
'Project'
).
first
.
path
)
untracked_files_for_uploads
.
create!
(
path:
"
#{
project_uploads_dir
(
project1
).
sub
(
"
#{
TrackUntrackedUploadsHelpers
::
PUBLIC_DIR
}
/"
,
''
)
}
/
#{
get_uploads
(
project1
,
'Project'
).
last
.
path
}
"
)
untracked_files_for_uploads
.
create!
(
path:
"
#{
project_uploads_dir
(
project2
).
sub
(
"
#{
TrackUntrackedUploadsHelpers
::
PUBLIC_DIR
}
/"
,
''
)
}
/
#{
get_uploads
(
project2
,
'Project'
).
last
.
path
}
"
)
untracked_files_for_uploads
.
create!
(
path:
"
#{
legacy_
project_uploads_dir
(
project1
).
sub
(
"
#{
TrackUntrackedUploadsHelpers
::
PUBLIC_DIR
}
/"
,
''
)
}
/
#{
get_uploads
(
project1
,
'Project'
).
last
.
path
}
"
)
untracked_files_for_uploads
.
create!
(
path:
"
#{
legacy_
project_uploads_dir
(
project2
).
sub
(
"
#{
TrackUntrackedUploadsHelpers
::
PUBLIC_DIR
}
/"
,
''
)
}
/
#{
get_uploads
(
project2
,
'Project'
).
last
.
path
}
"
)
# Untrack 4 files
get_uploads
(
user2
,
'User'
).
delete_all
...
...
spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
View file @
293c51e3
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
PrepareUntrackedUploads
,
:sidekiq
,
:migration
,
schema:
20180129193323
do
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe
Gitlab
::
BackgroundMigration
::
PrepareUntrackedUploads
,
:sidekiq
,
:migration
,
schema:
20180208183958
do
include
TrackUntrackedUploadsHelpers
include
MigrationsHelpers
let!
(
:untracked_files_for_uploads
)
{
described_class
::
UntrackedFile
}
let!
(
:appearances
)
{
table
(
:appearances
)
}
let!
(
:namespaces
)
{
table
(
:namespaces
)
}
let!
(
:projects
)
{
table
(
:projects
)
}
let!
(
:routes
)
{
table
(
:routes
)
}
let!
(
:uploads
)
{
table
(
:uploads
)
}
let!
(
:users
)
{
table
(
:users
)
}
around
do
|
example
|
# Especially important so the follow-up migration does not get run
...
...
@@ -15,19 +21,17 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
shared_examples
'prepares the untracked_files_for_uploads table'
do
context
'when files were uploaded before and after hashed storage was enabled'
do
let!
(
:appearance
)
{
create_or_update_appearance
(
logo:
uploaded_file
,
header_logo:
uploaded_fil
e
)
}
let!
(
:user
)
{
create
(
:user
,
:with_avatar
)
}
let!
(
:project1
)
{
create
(
:project
,
:with_avatar
,
:legacy_storag
e
)
}
let
(
:project2
)
{
create
(
:project
)
}
# instantiate after enabling hashed_storage
let!
(
:appearance
)
{
create_or_update_appearance
(
logo:
true
,
header_logo:
tru
e
)
}
let!
(
:user
)
{
create
_user
(
avatar:
true
)
}
let!
(
:project1
)
{
create
_project
(
avatar:
tru
e
)
}
let
(
:project2
)
{
create
_project
}
# instantiate after enabling hashed_storage
before
do
# Markdown upload before enabling hashed_storage
UploadService
.
new
(
project1
,
uploaded_file
,
FileUploader
).
execute
stub_application_setting
(
hashed_storage_enabled:
true
)
add_markdown_attachment
(
project1
)
# Markdown upload after enabling hashed_storage
UploadService
.
new
(
project2
,
uploaded_file
,
FileUploader
).
execute
add_markdown_attachment
(
project2
,
hashed_storage:
true
)
end
it
'has a path field long enough for really long paths'
do
...
...
@@ -61,7 +65,7 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
it
'does not add hashed files to the untracked_files_for_uploads table'
do
described_class
.
new
.
perform
hashed_file_path
=
project2
.
uploads
.
where
(
uploader:
'FileUploader'
).
first
.
path
hashed_file_path
=
get_uploads
(
project2
,
'Project'
)
.
where
(
uploader:
'FileUploader'
).
first
.
path
expect
(
untracked_files_for_uploads
.
where
(
"path like '%
#{
hashed_file_path
}
%'"
).
exists?
).
to
be_falsey
end
...
...
spec/support/track_untracked_uploads_helpers.rb
View file @
293c51e3
...
...
@@ -71,8 +71,8 @@ module TrackUntrackedUploadsHelpers
)
end
def
add_markdown_attachment
(
project
)
project_dir
=
project_uploads_dir
(
project
)
def
add_markdown_attachment
(
project
,
hashed_storage:
false
)
project_dir
=
hashed_storage
?
hashed_project_uploads_dir
(
project
)
:
legacy_
project_uploads_dir
(
project
)
attachment_dir
=
File
.
join
(
project_dir
,
SecureRandom
.
hex
)
attachment_file_path
=
File
.
join
(
attachment_dir
,
UPLOAD_FILENAME
)
project_attachment_path_relative_to_project
=
attachment_file_path
.
sub
(
"
#{
project_dir
}
/"
,
''
)
...
...
@@ -88,8 +88,13 @@ module TrackUntrackedUploadsHelpers
)
end
def
project_uploads_dir
(
project
)
File
.
join
(
UPLOADS_DIR
,
project
.
full_path
)
def
legacy_project_uploads_dir
(
project
)
namespace
=
namespaces
.
find_by
(
id:
project
.
namespace_id
)
File
.
join
(
UPLOADS_DIR
,
namespace
.
path
,
project
.
path
)
end
def
hashed_project_uploads_dir
(
project
)
File
.
join
(
UPLOADS_DIR
,
'@hashed'
,
'aa'
,
'aaaaaaaaaaaa'
)
end
def
upload_file_path
(
model
,
model_type
,
attachment_type
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment