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
83dc8f1c
Commit
83dc8f1c
authored
6 years ago
by
Andrew Newdigate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leak memory, spin cpu and kill the process
parent
cfe3cfb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
app/controllers/chaos_controller.rb
app/controllers/chaos_controller.rb
+23
-0
config/routes.rb
config/routes.rb
+3
-0
No files found.
app/controllers/chaos_controller.rb
View file @
83dc8f1c
# frozen_string_literal: true
class
ChaosController
<
ActionController
::
Base
def
leakmem
memory_mb
=
params
[
:memory_mb
]
?
params
[
:memory_mb
].
to_i
:
100
retainer
=
[]
memory_mb
.
times
{
retainer
<<
"x"
*
(
1024
*
1024
)
}
render
text:
"OK"
,
content_type:
'text/plain'
end
def
cpuspin
duration_s
=
params
[
:duration_s
]
?
params
[
:duration_s
].
to_i
:
30
end_time
=
Time
.
now
+
duration_s
.
seconds
;
while
Time
.
now
<
end_time
10_000
.
times
{
}
end
render
text:
"OK"
,
content_type:
'text/plain'
end
def
sleep
duration_s
=
params
[
:duration_s
]
?
params
[
:duration_s
].
to_i
:
30
Kernel
.
sleep
duration_s
render
text:
"OK"
,
content_type:
'text/plain'
end
def
kill
Process
.
kill
(
"KILL"
,
Process
.
pid
)
end
end
This diff is collapsed.
Click to expand it.
config/routes.rb
View file @
83dc8f1c
...
...
@@ -83,7 +83,10 @@ Rails.application.routes.draw do
draw
:operations
draw
:instance_statistics
get
'/chaos/leakmem'
=>
'chaos#leakmem'
get
'/chaos/cpuspin'
=>
'chaos#cpuspin'
get
'/chaos/sleep'
=>
'chaos#sleep'
get
'/chaos/kill'
=>
'chaos#kill'
end
draw
:api
...
...
This diff is collapsed.
Click to expand it.
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