Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #21 from rn/moperf
Browse files Browse the repository at this point in the history
More tests, in particular perf tests
  • Loading branch information
rn committed Mar 23, 2018
2 parents e195f8c + 1b67a6b commit a368a53
Show file tree
Hide file tree
Showing 33 changed files with 546 additions and 2 deletions.
28 changes: 28 additions & 0 deletions tests/cases/100_volume/050_flock_volume/check_flock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/sh

set -e
set -x

FILE=$1
ret=0

# First check that flock works
flock -x "$FILE" echo "flock works"

# disable exit on error as we expect an error below
set +e

# start a background process locking a file
flock -x "$FILE" sleep 1000 &
pid=$!

# try to lock the file
flock -xn "$FILE" echo "locked although locked"
res=$?
[ $res -eq 0 ] && $ret = 1 # If we did not get an error this test failed

# clean up
kill $pid
flock -u "$FILE" echo "unlocked"

exit $ret
27 changes: 27 additions & 0 deletions tests/cases/100_volume/050_flock_volume/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SUMMARY: Check that flock() works on a shared volume
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

$fileName = "lockfile"
$testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
New-Item -ItemType Directory -Force -Path $env:TEST_TMP

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $env:TEST_TMP`:/test `
-v $p`:/script `
-e TZ=UTC alpine:3.7 sh /script/check_flock.sh /test/$fileName
if ($lastexitcode -ne 0) {
$ret = 1
}

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit $ret
21 changes: 21 additions & 0 deletions tests/cases/100_volume/052_flock_volume_containers/check_flock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/sh

set -x

FILE=$1
ret=0

# start a background process locking a file
flock -x "$FILE" sleep 1000 &
pid=$!

# try to lock the file
flock -xn "$FILE" echo "locked although locked"
res=$?
[ $res -eq 0 ] && $ret = 1 # If we did not get an error this test failed

# clean up
kill $pid
flock -u "$FILE" echo "unlocked"

exit $ret
41 changes: 41 additions & 0 deletions tests/cases/100_volume/052_flock_volume_containers/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SUMMARY: Check that flock() works between containers sharing the same volume
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

$fileName = "lockfile"
$testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName
$containerName = $env:RT_TEST_NAME

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
New-Item -ItemType Directory -Force -Path $env:TEST_TMP

# Check that flock works first
docker run --platform linux --rm --name $containerName -v $env:TEST_TMP`:/test alpine:3.7 `
flock -x /test/$fileName echo "flock works"
if ($lastexitcode -ne 0) {
Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit 1
}

# Start a container in the background which locks the file
docker run --platform linux --rm -d --name $containerName -v $env:TEST_TMP`:/test alpine:3.7 `
flock -x /test/$fileName sleep 1000

# Start another container trying to lock the same file. This should fail
docker run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 `
flock -xn /test/$fileName echo "locked although locked"
if ($lastexitcode -eq 0) {
$ret = 1
}

# remove the background container
docker kill $containerName

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit $ret
4 changes: 2 additions & 2 deletions tests/cases/100_volume/150_utime/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ New-Item -ItemType Directory -Force -Path $env:TEST_TMP
#
# Create a file in a container and check on the host
#
docker run --rm -v $env:TEST_TMP`:/test -e TZ=UTC alpine touch -t 197002010000.00 /test/$fileName
docker run --rm -v $env:TEST_TMP`:/test -e TZ=UTC alpine:3.7 touch -t 197002010000.00 /test/$fileName

# check timestamp
$expected = Get-Date -Date "1970-02-01 00:00:00Z"
Expand All @@ -41,7 +41,7 @@ $p = [string]$pwd.Path
docker run --platform linux --rm `
-v $env:TEST_TMP`:/test `
-v $p`:/script `
-e TZ=UTC alpine sh /script/check_time.sh /test/$fileName
-e TZ=UTC alpine:3.7 sh /script/check_time.sh /test/$fileName
if ($lastexitcode -ne 0) {
$ret = 1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /bin/sh

set -e
# don't set -x as it creates a lot of noise

DIR=$1

# find calls lstat()
find "$DIR" -type f > dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SUMMARY: Stat 5000 files in a single directory created on the host
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

$testPath = Join-Path -Path $env:TEST_TMP_ROOT -ChildPath "single-dir-stat"

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $testPath`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test
if ($lastexitcode -ne 0) {
$ret = 1
}

exit $ret
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh

# set -e
# don't set -x as it creates a lot of noise

DIR=$1

for i in $(seq 5000); do
stat "$DIR/file-$i" 2> /dev/null
done
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SUMMARY: Stat 5000 non-existing files in a single directory on a shared volume
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
New-Item -ItemType Directory -Force -Path $env:TEST_TMP

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $env:TEST_TMP`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test
if ($lastexitcode -ne 0) {
$ret = 1
}

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit $ret
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/sh

set -e
# don't set -x as it creates a lot of noise

DIR=$1

for i in $(seq 5000); do
touch "$DIR/file-$i"
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SUMMARY: Create 5000 files in a single directory on a shared volume
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
New-Item -ItemType Directory -Force -Path $env:TEST_TMP

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $env:TEST_TMP`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test
if ($lastexitcode -ne 0) {
$ret = 1
}

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit $ret
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/sh

set -e
# don't set -x as it creates a lot of noise

DIR=$1

for i in $(seq 5000); do
touch "$DIR/file-$i"
done

# find calls lstat()
find "$DIR" -type f > dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SUMMARY: Create 5000 files in a single directory on a shared volume and then stat them
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
New-Item -ItemType Directory -Force -Path $env:TEST_TMP

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $env:TEST_TMP`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test
if ($lastexitcode -ne 0) {
$ret = 1
}

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit $ret
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /bin/sh

set -e
# don't set -x as it creates a lot of noise

DIR=$1

# find calls lstat()
find "$DIR" -type f -print0 | xargs -0 touch > dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SUMMARY: Stat and then touch 5000 files in a single directory created on the host
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

$testPath = Join-Path -Path $env:TEST_TMP_ROOT -ChildPath "single-dir-touch"

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $testPath`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test
if ($lastexitcode -ne 0) {
$ret = 1
}

exit $ret
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /bin/sh

set -e

DIR=$1

# find calls lstat()
find "$DIR" -type f -print0 | xargs -0 touch > dev/null
find "$DIR" -type f > dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SUMMARY: Stat, touch and then stat again 5000 files on a shared volume
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

$testPath = Join-Path -Path $env:TEST_TMP_ROOT -ChildPath "single-dir-touch-stat"

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $testPath`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test
if ($lastexitcode -ne 0) {
$ret = 1
}

exit $ret
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/sh

set -e

DIR=$1
SIZE=$2

for i in $(seq 5000); do
dd if=/dev/zero of="$DIR/file-$i" bs="$SIZE" count=1
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SUMMARY: Write 5000 small files in a single directory
# LABELS:
# REPEAT:

$libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib
$lib = Join-Path -Path $libBase -ChildPath lib.ps1
. $lib

$ret = 0

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
New-Item -ItemType Directory -Force -Path $env:TEST_TMP

$p = [string]$pwd.Path
docker run --platform linux --rm `
-v $env:TEST_TMP`:/test `
-v $p`:/script `
alpine:3.7 sh /script/run.sh /test 512
if ($lastexitcode -ne 0) {
$ret = 1
}

Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP
exit $ret
Loading

0 comments on commit a368a53

Please sign in to comment.