Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4a132952
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4a132952
编写于
12月 18, 2018
作者:
D
Douglas Barbosa Alexandre
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract a shared example for legacy and hashed storage migrations tests
上级
754f6611
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
78 deletion
+46
-78
spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb
...nd_migration/backfill_hashed_project_repositories_spec.rb
+1
-39
spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb
...nd_migration/backfill_legacy_project_repositories_spec.rb
+1
-39
spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb
...round_migration/backfill_project_repositories_examples.rb
+44
-0
未找到文件。
spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb
浏览文件 @
4a132952
...
...
@@ -3,43 +3,5 @@
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
BackfillHashedProjectRepositories
,
:migration
,
schema:
20181130102132
do
describe
'#perform'
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:project_repositories
)
{
table
(
:project_repositories
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:shards
)
{
table
(
:shards
)
}
let
(
:group
)
{
namespaces
.
create!
(
name:
'foo'
,
path:
'foo'
)
}
let
(
:shard
)
{
shards
.
create!
(
name:
'default'
)
}
it
'creates a project_repository row for projects on hashed storage that need one'
do
projects
.
create!
(
id:
1
,
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
1
)
projects
.
create!
(
id:
2
,
name:
'bar'
,
path:
'bar'
,
namespace_id:
group
.
id
,
storage_version:
2
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
to
change
(
project_repositories
,
:count
).
by
(
2
)
end
it
'does nothing for projects on hashed storage that have already a project_repository row'
do
projects
.
create!
(
id:
1
,
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
1
)
project_repositories
.
create!
(
project_id:
1
,
disk_path:
'@phony/foo/bar'
,
shard_id:
shard
.
id
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
change
(
project_repositories
,
:count
)
end
it
'does nothing for projects on legacy storage'
do
projects
.
create!
(
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
0
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
change
(
project_repositories
,
:count
)
end
it
'inserts rows in a single query'
do
projects
.
create!
(
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
1
,
repository_storage:
shard
.
name
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}
projects
.
create!
(
name:
'bar'
,
path:
'bar'
,
namespace_id:
group
.
id
,
storage_version:
1
,
repository_storage:
shard
.
name
)
projects
.
create!
(
name:
'zoo'
,
path:
'zoo'
,
namespace_id:
group
.
id
,
storage_version:
1
,
repository_storage:
shard
.
name
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
exceed_query_limit
(
control_count
)
end
end
it_behaves_like
'backfill migration for project repositories'
,
:hashed
end
spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb
浏览文件 @
4a132952
...
...
@@ -3,43 +3,5 @@
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
BackfillLegacyProjectRepositories
,
:migration
,
schema:
20181218192239
do
describe
'#perform'
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:project_repositories
)
{
table
(
:project_repositories
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:shards
)
{
table
(
:shards
)
}
let
(
:group
)
{
namespaces
.
create!
(
name:
'foo'
,
path:
'foo'
)
}
let
(
:shard
)
{
shards
.
create!
(
name:
'default'
)
}
it
'creates a project_repository row for projects on legacy storage that need one'
do
projects
.
create!
(
id:
1
,
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
nil
)
projects
.
create!
(
id:
2
,
name:
'bar'
,
path:
'bar'
,
namespace_id:
group
.
id
,
storage_version:
0
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
to
change
(
project_repositories
,
:count
).
by
(
2
)
end
it
'does nothing for projects on legacy storage that have already a project_repository row'
do
projects
.
create!
(
id:
1
,
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
0
)
project_repositories
.
create!
(
project_id:
1
,
disk_path:
'phony/foo/bar'
,
shard_id:
shard
.
id
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
change
(
project_repositories
,
:count
)
end
it
'does nothing for projects on hashed storage'
do
projects
.
create!
(
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
1
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
change
(
project_repositories
,
:count
)
end
it
'inserts rows in a single query'
do
projects
.
create!
(
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
0
,
repository_storage:
shard
.
name
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}
projects
.
create!
(
name:
'bar'
,
path:
'bar'
,
namespace_id:
group
.
id
,
storage_version:
0
,
repository_storage:
shard
.
name
)
projects
.
create!
(
name:
'zoo'
,
path:
'zoo'
,
namespace_id:
group
.
id
,
storage_version:
0
,
repository_storage:
shard
.
name
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
exceed_query_limit
(
control_count
)
end
end
it_behaves_like
'backfill migration for project repositories'
,
:legacy
end
spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb
0 → 100644
浏览文件 @
4a132952
shared_examples
'backfill migration for project repositories'
do
|
storage
|
describe
'#perform'
do
let
(
:storage_versions
)
{
storage
==
:legacy
?
[
nil
,
0
]
:
[
1
,
2
]
}
let
(
:storage_version
)
{
storage_versions
.
first
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:project_repositories
)
{
table
(
:project_repositories
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:shards
)
{
table
(
:shards
)
}
let
(
:group
)
{
namespaces
.
create!
(
name:
'foo'
,
path:
'foo'
)
}
let
(
:shard
)
{
shards
.
create!
(
name:
'default'
)
}
it
"creates a project_repository row for projects on
#{
storage
}
storage that needs one"
do
storage_versions
.
each_with_index
do
|
storage_version
,
index
|
projects
.
create!
(
name:
"foo-
#{
index
}
"
,
path:
"foo-
#{
index
}
"
,
namespace_id:
group
.
id
,
storage_version:
storage_version
)
end
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
to
change
(
project_repositories
,
:count
).
by
(
2
)
end
it
"does nothing for projects on
#{
storage
}
storage that have already a project_repository row"
do
projects
.
create!
(
id:
1
,
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
storage_version
)
project_repositories
.
create!
(
project_id:
1
,
disk_path:
'phony/foo/bar'
,
shard_id:
shard
.
id
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
change
(
project_repositories
,
:count
)
end
it
"does nothing for projects on
#{
storage
==
:legacy
?
'hashed'
:
'legacy'
}
storage"
do
projects
.
create!
(
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
storage
==
:legacy
?
1
:
nil
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
change
(
project_repositories
,
:count
)
end
it
'inserts rows in a single query'
do
projects
.
create!
(
name:
'foo'
,
path:
'foo'
,
namespace_id:
group
.
id
,
storage_version:
storage_version
,
repository_storage:
shard
.
name
)
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}
projects
.
create!
(
name:
'bar'
,
path:
'bar'
,
namespace_id:
group
.
id
,
storage_version:
storage_version
,
repository_storage:
shard
.
name
)
projects
.
create!
(
name:
'zoo'
,
path:
'zoo'
,
namespace_id:
group
.
id
,
storage_version:
storage_version
,
repository_storage:
shard
.
name
)
expect
{
described_class
.
new
.
perform
(
1
,
projects
.
last
.
id
)
}.
not_to
exceed_query_limit
(
control_count
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录