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
e9e4bd23
Commit
e9e4bd23
authored
May 03, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for FastDestroyAll
parent
dffc2cb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
spec/models/concerns/fast_destroy_all_spec.rb
spec/models/concerns/fast_destroy_all_spec.rb
+69
-0
No files found.
spec/models/concerns/fast_destroy_all_spec.rb
0 → 100644
View file @
e9e4bd23
require
'spec_helper'
describe
FastDestroyAll
,
:clean_gitlab_redis_shared_state
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
before
do
stub_feature_flags
(
ci_enable_live_trace:
true
)
end
describe
'Forbid #destroy and #destroy_all'
do
let
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:trace_chunks
)
{
build
.
trace_chunks
}
it
'does not delete database rows and associted external data'
do
expect
(
trace_chunks
.
first
).
to
be_a
(
described_class
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
expect
(
redis
.
scan_each
(
match:
"gitlab:ci:trace:*:chunks:*"
).
to_a
.
size
).
to
eq
(
1
)
expect
(
trace_chunks
.
count
).
to
eq
(
1
)
expect
{
trace_chunks
.
first
.
destroy
}.
to
raise_error
(
'`destroy` and `destroy_all` are forbbiden. Please use `fast_destroy_all`'
)
expect
{
trace_chunks
.
destroy_all
}.
to
raise_error
(
'`destroy` and `destroy_all` are forbbiden. Please use `fast_destroy_all`'
)
expect
(
trace_chunks
.
count
).
to
eq
(
1
)
expect
(
redis
.
scan_each
(
match:
"gitlab:ci:trace:*:chunks:*"
).
to_a
.
size
).
to
eq
(
1
)
end
end
end
describe
'.fast_destroy_all'
do
let
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:trace_chunks
)
{
build
.
trace_chunks
}
it
'deletes database rows and associted external data'
do
expect
(
trace_chunks
.
first
).
to
be_a
(
described_class
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
expect
(
redis
.
scan_each
(
match:
"gitlab:ci:trace:*:chunks:*"
).
to_a
.
size
).
to
eq
(
1
)
expect
(
trace_chunks
.
count
).
to
eq
(
1
)
expect
{
build
.
trace_chunks
.
fast_destroy_all
}.
not_to
raise_error
expect
(
trace_chunks
.
count
).
to
eq
(
0
)
expect
(
redis
.
scan_each
(
match:
"gitlab:ci:trace:*:chunks:*"
).
to_a
.
size
).
to
eq
(
0
)
end
end
end
describe
'.use_fast_destroy'
do
let
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
,
pipeline:
pipeline
,
project:
project
)
}
let
(
:trace_chunks
)
{
build
.
trace_chunks
}
it
'performs cascading delete with fast_destroy_all'
do
expect
(
trace_chunks
.
first
).
to
be_a
(
described_class
)
expect
(
project
).
to
be_a
(
described_class
::
Helpers
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
expect
(
redis
.
scan_each
(
match:
"gitlab:ci:trace:*:chunks:*"
).
to_a
.
size
).
to
eq
(
1
)
expect
(
trace_chunks
.
count
).
to
eq
(
1
)
project
.
destroy
expect
(
trace_chunks
.
count
).
to
eq
(
0
)
expect
(
redis
.
scan_each
(
match:
"gitlab:ci:trace:*:chunks:*"
).
to_a
.
size
).
to
eq
(
0
)
end
end
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