Commit 6367cdd5 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'slow-fs-simulator' into 'master'

Added shell script for simulating slow filesystems

This is Linux only as I'm not familiar with traffic shaping on other platforms (e.g. OS X).

See merge request !120
parents 0737c143 13c73960
......@@ -49,6 +49,8 @@ sockets to avoid port conflicts.
- ['bundle install' fails while compiling eventmachine gem](#bundle-install-fails-while-compiling-eventmachine-gem)
- ['Invalid reference name' when creating a new tag](#invalid-reference-name-when-creating-a-new-tag)
- [Other problems](#other-problems)
- [Executables](#executables)
- [mount-slow-fs](#mount-slow-fs)
- [License](#license)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
......@@ -645,6 +647,39 @@ git commit --allow-empty -m 'I can commit'
Please open an issue on the [GDK issue tracker](
## Executables
A collection of executables can be found in the `bin/` directory. You can use
these executables by adding this directory to your shell's executable path. For
example, when using Bash:
export PATH="${PATH}:path/to/gdk/bin"
### mount-slow-fs
This script can be used to mount a source directory at a given mount point via
SSHFS and slow down network traffic as a way of replicating a slow NFS. Usage of
this script is as following:
mount-slow-fs path/to/actual/repositories /path/to/mountpoint
As an example, we'll use the following directories:
* Source directory: ~/Projects/repositories
* Mountpoint: /mnt/repositories
First create the mountpoint and set the correct permissions:
sudo mkdir /mnt/repositories
sudo chown $USER /mnt/repositories
Now we can run the script:
mount-slow-fs ~/Projects/repositories /mnt/repositories
Terminating the script (using ^C) will automatically unmount the repositories
and remove the created traffic shaping rules.
## License
The GitLab Development Kit is distributed under the MIT license,
#!/usr/bin/env bash
# This script mounts a given path at a given location using SSHFS while slowing
# down traffic on the loopback interface. This combination can be used to
# replicate a slow file system without having to set up an entire NFS cluster.
# Requirements:
# * Bash 4 or newer
# * Linux
# * sshfs (
# * sshd running locally
# * pgrep
function print_usage {
echo 'Usage: mount-slow-fs [SOURCE DIRECTORY] [MOUNTPOINT]'
exit 1
function main {
local os
local source_dir
local mountpoint
os="$(uname -s)"
if [[ "${source_dir}" == "" || "${mountpoint}" == "" ]]
if [[ "${os,,}" != "linux" ]]
echo 'Only Linux is supported'
exit 1
if ! test -d "${source_dir}"
if ! test -d "${mountpoint}"
if ! hash sshfs 2>/dev/null
echo 'sshfs is not installed'
exit 1
if ! hash tc 2>/dev/null
echo 'The "tc" command could not be found'
exit 1
if ! hash sudo 2>/dev/null
echo 'The "sudo" command could not be found'
exit 1
if ! hash pgrep 2>/dev/null
echo 'The "pgrep" command could not be found'
exit 1
if [[ "$(pgrep sshd)" == "" ]]
echo 'sshd does not appear to be running locally'
exit 1
echo 'Delaying loopback interface, you may be prompted for your password...'
# This command may fail if no existing rules are present, in that case we'll
# just ignore the output.
sudo tc qdisc del dev lo root 2>/dev/null
sudo tc qdisc add dev lo root netem delay 2ms
echo "Mounting under ${mountpoint}, exit with ^C"
sshfs -o cache=no -f "${USER}@localhost:${source_dir}" "${mountpoint}"
echo 'Removing loopback delay, you may be prompted for your password...'
sudo tc qdisc del dev lo root
main "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment