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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
04625437
Commit
04625437
authored
Feb 21, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests
parent
c00a4cb6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
ee/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb
...ared_examples/uploaders/object_storage_shared_examples.rb
+34
-0
spec/uploaders/job_artifact_uploader_spec.rb
spec/uploaders/job_artifact_uploader_spec.rb
+10
-0
No files found.
ee/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb
View file @
04625437
...
...
@@ -38,6 +38,40 @@ shared_examples "migrates" do |to_store:, from_store: nil|
expect
(
File
.
exist?
(
original_file
)).
to
be_falsey
end
it
'can access to the original file during migration'
do
original_file
=
subject
.
file
.
path
allow
(
subject
).
to
receive
(
:delete_migrated_file
)
{
}
expect
{
migrate
(
to
)
}.
not_to
change
{
File
.
exist?
(
original_file
)
}
end
context
'when migrate! is not oqqupied by another process'
do
it
'executes migrate!'
do
expect
(
subject
).
to
receive
(
:object_store
=
)
migrate
(
to
)
end
end
context
'when migrate! is oqqupied by another process'
do
let
(
:exclusive_lease_key
)
{
"object_storage_migrate:
#{
subject
.
store_path
}
"
}
before
do
@uuid
=
Gitlab
::
ExclusiveLease
.
new
(
exclusive_lease_key
,
timeout:
1
.
hour
.
to_i
).
try_obtain
end
it
'does not execute migrate!'
do
expect
(
subject
).
not_to
receive
(
:object_store
=
)
migrate
(
to
)
end
after
do
Gitlab
::
ExclusiveLease
.
cancel
(
exclusive_lease_key
,
@uuid
)
end
end
context
'migration is unsuccessful'
do
shared_examples
"handles gracefully"
do
|
error
:|
it
'does not update the object_store'
do
...
...
spec/uploaders/job_artifact_uploader_spec.rb
View file @
04625437
...
...
@@ -67,4 +67,14 @@ describe JobArtifactUploader do
it
{
is_expected
.
to
include
(
"/
#{
job_artifact
.
job_id
}
/
#{
job_artifact
.
id
}
/"
)
}
it
{
is_expected
.
to
end_with
(
"ci_build_artifacts.zip"
)
}
end
describe
"#migrate!"
do
before
do
uploader
.
store!
(
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/trace/sample_trace'
)))
stub_artifacts_object_storage
end
it_behaves_like
"migrates"
,
to_store:
described_class
::
Store
::
REMOTE
it_behaves_like
"migrates"
,
from_store:
described_class
::
Store
::
REMOTE
,
to_store:
described_class
::
Store
::
LOCAL
end
end
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