Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9ac732dd
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,发现更多精彩内容 >>
提交
9ac732dd
编写于
10月 04, 2017
作者:
M
Michael Kozono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add migration specs
上级
1879980f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
92 addition
and
0 deletion
+92
-0
spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb
...ground_migration/normalize_ldap_extern_uids_range_spec.rb
+36
-0
spec/migrations/normalize_ldap_extern_uids_spec.rb
spec/migrations/normalize_ldap_extern_uids_spec.rb
+56
-0
未找到文件。
spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb
0 → 100644
浏览文件 @
9ac732dd
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
NormalizeLdapExternUidsRange
,
:migration
,
schema:
20170921101004
do
let!
(
:identities
)
{
table
(
:identities
)
}
before
do
# LDAP identities
(
1
..
4
).
each
do
|
i
|
identities
.
create!
(
id:
i
,
provider:
'ldapmain'
,
extern_uid:
" uid = foo
#{
i
}
, ou = People, dc = example, dc = com "
,
user_id:
i
)
end
# Non-LDAP identity
identities
.
create!
(
id:
5
,
provider:
'foo'
,
extern_uid:
" uid = foo 5, ou = People, dc = example, dc = com "
,
user_id:
5
)
# Another LDAP identity
identities
.
create!
(
id:
6
,
provider:
'ldapmain'
,
extern_uid:
" uid = foo 6, ou = People, dc = example, dc = com "
,
user_id:
6
)
end
it
'normalizes the LDAP identities in the range'
do
described_class
.
new
.
perform
(
1
,
3
)
expect
(
identities
.
find
(
1
).
extern_uid
).
to
eq
(
"uid=foo 1,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
2
).
extern_uid
).
to
eq
(
"uid=foo 2,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
3
).
extern_uid
).
to
eq
(
"uid=foo 3,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
4
).
extern_uid
).
to
eq
(
" uid = foo 4, ou = People, dc = example, dc = com "
)
expect
(
identities
.
find
(
5
).
extern_uid
).
to
eq
(
" uid = foo 5, ou = People, dc = example, dc = com "
)
expect
(
identities
.
find
(
6
).
extern_uid
).
to
eq
(
" uid = foo 6, ou = People, dc = example, dc = com "
)
described_class
.
new
.
perform
(
4
,
6
)
expect
(
identities
.
find
(
1
).
extern_uid
).
to
eq
(
"uid=foo 1,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
2
).
extern_uid
).
to
eq
(
"uid=foo 2,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
3
).
extern_uid
).
to
eq
(
"uid=foo 3,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
4
).
extern_uid
).
to
eq
(
"uid=foo 4,ou=people,dc=example,dc=com"
)
expect
(
identities
.
find
(
5
).
extern_uid
).
to
eq
(
" uid = foo 5, ou = People, dc = example, dc = com "
)
expect
(
identities
.
find
(
6
).
extern_uid
).
to
eq
(
"uid=foo 6,ou=people,dc=example,dc=com"
)
end
end
spec/migrations/normalize_ldap_extern_uids_spec.rb
0 → 100644
浏览文件 @
9ac732dd
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170921101004_normalize_ldap_extern_uids'
)
describe
NormalizeLdapExternUids
,
:migration
,
:sidekiq
do
let!
(
:identities
)
{
table
(
:identities
)
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
before
do
stub_const
(
"Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_BATCH_SIZE"
,
2
)
stub_const
(
"Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE"
,
2
)
# LDAP identities
(
1
..
4
).
each
do
|
i
|
identities
.
create!
(
id:
i
,
provider:
'ldapmain'
,
extern_uid:
" uid = foo
#{
i
}
, ou = People, dc = example, dc = com "
,
user_id:
i
)
end
# Non-LDAP identity
identities
.
create!
(
id:
5
,
provider:
'foo'
,
extern_uid:
" uid = foo 5, ou = People, dc = example, dc = com "
,
user_id:
5
)
end
it
'correctly schedules background migrations'
do
Sidekiq
::
Testing
.
fake!
do
Timecop
.
freeze
do
migrate!
expect
(
BackgroundMigrationWorker
.
jobs
[
0
][
'args'
]).
to
eq
([
described_class
::
MIGRATION
,
[
1
,
2
]])
expect
(
BackgroundMigrationWorker
.
jobs
[
0
][
'at'
]).
to
eq
(
10
.
seconds
.
from_now
.
to_f
)
expect
(
BackgroundMigrationWorker
.
jobs
[
1
][
'args'
]).
to
eq
([
described_class
::
MIGRATION
,
[
3
,
4
]])
expect
(
BackgroundMigrationWorker
.
jobs
[
1
][
'at'
]).
to
eq
(
20
.
seconds
.
from_now
.
to_f
)
expect
(
BackgroundMigrationWorker
.
jobs
[
2
][
'args'
]).
to
eq
([
described_class
::
MIGRATION
,
[
5
,
5
]])
expect
(
BackgroundMigrationWorker
.
jobs
[
2
][
'at'
]).
to
eq
(
30
.
seconds
.
from_now
.
to_f
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
end
it
'migrates the LDAP identities'
do
Sidekiq
::
Testing
.
inline!
do
migrate!
identities
.
where
(
id:
1
..
4
).
each
do
|
identity
|
expect
(
identity
.
extern_uid
).
to
eq
(
"uid=foo
#{
identity
.
id
}
,ou=people,dc=example,dc=com"
)
end
end
end
it
'does not modify non-LDAP identities'
do
Sidekiq
::
Testing
.
inline!
do
migrate!
identity
=
identities
.
last
expect
(
identity
.
extern_uid
).
to
eq
(
" uid = foo 5, ou = People, dc = example, dc = com "
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录