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
Jérome Perrin
gitlab-ce
Commits
ba5697fd
Commit
ba5697fd
authored
Nov 08, 2017
by
Zeger-Jan van de Weg
Committed by
Kamil Trzcinski
Dec 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix legacy migration test
parent
1756604f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
14 deletions
+38
-14
app/uploaders/artifact_uploader.rb
app/uploaders/artifact_uploader.rb
+1
-3
db/migrate/20170918072948_create_job_artifacts.rb
db/migrate/20170918072948_create_job_artifacts.rb
+2
-2
spec/migrations/migrate_old_artifacts_spec.rb
spec/migrations/migrate_old_artifacts_spec.rb
+29
-8
spec/support/test_env.rb
spec/support/test_env.rb
+5
-0
spec/uploaders/artifact_uploader_spec.rb
spec/uploaders/artifact_uploader_spec.rb
+1
-1
No files found.
app/uploaders/artifact_uploader.rb
View file @
ba5697fd
...
...
@@ -34,8 +34,6 @@ class ArtifactUploader < GitlabUploader
end
def
default_path
File
.
join
(
job
.
project_id
.
to_s
,
job
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
job
.
id
.
to_s
)
File
.
join
(
job
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
job
.
project_id
.
to_s
,
job
.
id
.
to_s
)
end
end
db/migrate/20170918072948_create_job_artifacts.rb
View file @
ba5697fd
...
...
@@ -14,8 +14,8 @@ class CreateJobArtifacts < ActiveRecord::Migration
t
.
datetime_with_timezone
:updated_at
,
null:
false
t
.
string
:file
end
add_foreign_key
:ci_job_artifacts
,
:ci_builds
,
column: :job_id
,
on_delete: :cascade
t
.
foreign_key
:ci_builds
,
column: :job_id
,
on_delete: :cascade
end
end
end
spec/migrations/migrate_old_artifacts_spec.rb
View file @
ba5697fd
...
...
@@ -16,20 +16,22 @@ describe MigrateOldArtifacts do
end
context
'with migratable data'
do
l
et
(
:project1
)
{
create
(
:project
,
ci_id:
2
)
}
l
et
(
:project2
)
{
create
(
:project
,
ci_id:
3
)
}
l
et
(
:project3
)
{
create
(
:project
)
}
s
et
(
:project1
)
{
create
(
:project
,
ci_id:
2
)
}
s
et
(
:project2
)
{
create
(
:project
,
ci_id:
3
)
}
s
et
(
:project3
)
{
create
(
:project
)
}
l
et
(
:pipeline1
)
{
create
(
:ci_empty_pipeline
,
project:
project1
)
}
l
et
(
:pipeline2
)
{
create
(
:ci_empty_pipeline
,
project:
project2
)
}
l
et
(
:pipeline3
)
{
create
(
:ci_empty_pipeline
,
project:
project3
)
}
s
et
(
:pipeline1
)
{
create
(
:ci_empty_pipeline
,
project:
project1
)
}
s
et
(
:pipeline2
)
{
create
(
:ci_empty_pipeline
,
project:
project2
)
}
s
et
(
:pipeline3
)
{
create
(
:ci_empty_pipeline
,
project:
project3
)
}
let!
(
:build_with_legacy_artifacts
)
{
create
(
:ci_build
,
pipeline:
pipeline1
)
}
let!
(
:build_without_artifacts
)
{
create
(
:ci_build
,
pipeline:
pipeline1
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline2
)
}
let!
(
:build3
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline3
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
pipeline:
pipeline2
)
}
let!
(
:build3
)
{
create
(
:ci_build
,
pipeline:
pipeline3
)
}
before
do
setup_builds
(
build2
,
build3
)
store_artifacts_in_legacy_path
(
build_with_legacy_artifacts
)
end
...
...
@@ -113,5 +115,24 @@ describe MigrateOldArtifacts do
build
.
project
.
ci_id
.
to_s
,
build
.
id
.
to_s
)
end
def
new_legacy_path
(
build
)
File
.
join
(
directory
,
build
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
build
.
project_id
.
to_s
,
build
.
id
.
to_s
)
end
def
setup_builds
(
*
builds
)
builds
.
each
do
|
build
|
FileUtils
.
mkdir_p
(
new_legacy_path
(
build
))
build
.
update_columns
(
artifacts_file:
'ci_build_artifacts.zip'
,
artifacts_metadata:
'ci_build_artifacts_metadata.gz'
)
build
.
reload
end
end
end
end
spec/support/test_env.rb
View file @
ba5697fd
...
...
@@ -120,6 +120,7 @@ module TestEnv
FileUtils
.
mkdir_p
(
repos_path
)
FileUtils
.
mkdir_p
(
backup_path
)
FileUtils
.
mkdir_p
(
pages_path
)
FileUtils
.
mkdir_p
(
artifacts_path
)
end
def
clean_gitlab_test_path
...
...
@@ -233,6 +234,10 @@ module TestEnv
Gitlab
.
config
.
pages
.
path
end
def
artifacts_path
Gitlab
.
config
.
artifacts
.
path
end
# When no cached assets exist, manually hit the root path to create them
#
# Otherwise they'd be created by the first test, often timing out and
...
...
spec/uploaders/artifact_uploader_spec.rb
View file @
ba5697fd
...
...
@@ -26,7 +26,7 @@ describe ArtifactUploader do
subject
{
uploader
.
store_dir
}
it
{
is_expected
.
to
start_with
(
path
)
}
it
{
is_expected
.
to
end_with
(
"
#{
job
.
project_id
}
/
#{
job
.
created_at
.
utc
.
strftime
(
'%Y_%m'
)
}
/
#{
job
.
id
}
"
)
}
it
{
is_expected
.
to
end_with
(
"
#{
job
.
project_id
}
/
#{
job
.
id
}
"
)
}
end
describe
'#cache_dir'
do
...
...
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