You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_ftp-commits@incubator.apache.org by ji...@apache.org on 2005/10/06 13:17:04 UTC

svn commit: r306631 [8/8] - in /incubator/mod_ftp/trunk: ./ conf/ docs/ include/ modules/ patches/ src/ tests/ tests/conf/ tests/logs/ tests/tests/ utils/ utils/ftp_proxy/ utils/static_build/ utils/stresstest/

Added: incubator/mod_ftp/trunk/utils/stresstest/maketree.sh
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/utils/stresstest/maketree.sh?rev=306631&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/utils/stresstest/maketree.sh (added)
+++ incubator/mod_ftp/trunk/utils/stresstest/maketree.sh Thu Oct  6 06:16:28 2005
@@ -0,0 +1,181 @@
+#!/bin/bash
+#
+# Simple script to generate a directory tree for testing the FTP module.
+#
+# This must be run on the same machine as the FTP server.
+#
+# Run ./maketree.sh --help for usage options
+#
+# Ryan Morgan 7/16/2001
+#
+
+# Defaults
+DIR=.               # The directory to start in
+DEPTH=2             # Directory tree depth
+WIDTH=6             # Directory tree width (per directory)
+MAXFILESIZE=100     # Maximum files size, in kbytes
+MAXFILES=20         # Maximum files in a directory
+
+# Statistics
+files=0
+dirs=0
+
+# Nifty function for generating random file names
+gen_filename()
+{
+    MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+    LENGTH="8"
+
+    while [ ${n:=1} -le $LENGTH ]
+    do
+        NAME="$NAME${MATRIX:$(($RANDOM%${#MATRIX})):1}"
+        let n+=1
+    done
+
+    echo $NAME;
+}
+
+# Grab command line options
+doinit()
+{
+    for option
+    do
+    case "$option" in
+        -*=*)
+        optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'`
+        ;;
+        *)
+        optarg=
+        ;;
+    esac
+
+    case "$option" in
+        *-help | -h | -help )
+        echo
+        echo "Usage: $0 [options]"
+        echo "Options: [defaults in brackets]"
+        echo "General Options:"
+        echo " --dir=[$DIR]: Directory to start in"
+        echo " --depth=[$DEPTH]: Max directory tree depth"
+        echo " --width=[$WIDTH]: Max directory tree width"
+        echo " --maxfilesize[$MAXFILESIZE]: Max file size, in kbytes"
+        echo " --maxfiles=[$MAXFILES]: Max files per directory"
+        echo
+        echo "Note that the number files created in each directory will"
+        echo "not exceed --maxfiles, and each file size will not exceed"
+        echo "--maxfilesize.  Also be careful with --depth and --width."
+        echo
+        exit 0
+        ;;
+        *-dir=*)
+        DIR="$optarg";
+        ;;
+        *-depth=*)
+        DEPTH="$optarg";
+        ;;
+        *-width=*)
+        WIDTH="$optarg";
+        ;;
+        *-maxfilesize=*)
+        MAXFILESIZE="$optarg";
+        ;;
+        *-maxfiles=*)
+        MAXFILES="$optarg";
+        ;;
+    esac
+    done
+}               
+
+# Recursive call to make the directory tree
+maketree()
+{
+    local depth=$1 # Must be local!
+    local newdepth # Must be local!
+    local i
+
+    if [ ${depth} -eq 0 ]
+    then
+        # At the leaf.  Create at most MAXFILES
+        maxfiles=$(($RANDOM%${MAXFILES}))
+        i=1
+        while [ ${i} -le ${maxfiles} ]
+        do
+            filename=`gen_filename`
+            dd if=/dev/zero of=${filename} bs=1k \
+                count=$(($RANDOM%${MAXFILESIZE})) > /dev/null 2>&1
+            let files+=1
+            let i+=1
+        done
+    else
+        echo "Creating files at depth ${depth}"
+        # Create at most MAXFILES
+        maxfiles=$(($RANDOM%${MAXFILES}))
+        i=1
+        while [ ${i} -le ${maxfiles} ]
+        do
+            filename=`gen_filename`
+            dd if=/dev/zero of=${filename} bs=1k \
+                count=$(($RANDOM%${MAXFILESIZE})) > /dev/null 2>&1
+            let files+=1
+            let i+=1
+        done
+
+        # Not deep enough, recurse
+        let "newdepth = depth - 1"
+        i=1
+        while [ ${i} -le ${WIDTH} ]
+        do
+            filename=`gen_filename`
+            mkdir ${filename}
+            cd ${filename}
+            maketree ${newdepth}  # Recurse
+            cd ..
+            let dirs+=1
+            let i+=1
+        done
+    fi
+
+    return
+}
+
+# Read in the command line arguments
+doinit $*
+
+# Print out defaults, and see if we should continue
+echo
+echo "Creating directory tree structure in $DIR with the options:"
+echo "Maxdepth = ${DEPTH}"
+echo "Maxwidth = ${WIDTH}"
+echo "Maxfilesize = ${MAXFILESIZE}"
+echo "Maxfiles = ${MAXFILES}"
+echo -n "Continue? (y/n) "
+read ANS
+if test "X${ANS}" != "Xy" && test "X${ANS}" != "XY"; then
+    echo "Exiting.  See $0 --help for options"
+    exit 0;
+fi
+
+# Make sure the target directory exists
+if test ! -d "${DIR}" ; then
+    echo -n "Target directory ${DIR} does not exist, Create? (y/n) "
+    read ANS
+    if test "X${ANS}" = "Xy" || test "X${ANS}" = "XY"; then
+        mkdir ${DIR}
+        if test $? -ne 0; then
+            echo "Failed to create directory: ${DIR}"
+            exit 1
+        fi
+    else
+        echo "Exiting. ${DIR} not created"
+        exit 0
+    fi
+fi
+
+cd ${DIR}
+
+# Make the tree
+maketree ${DEPTH}
+
+echo "Done.  Created ${dirs} directories and ${files} files in ${DIR}"
+
+exit 0

Propchange: incubator/mod_ftp/trunk/utils/stresstest/maketree.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/mod_ftp/trunk/utils/stresstest/maketree.sh
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/mod_ftp/trunk/utils/stresstest/mirror.sh
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/utils/stresstest/mirror.sh?rev=306631&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/utils/stresstest/mirror.sh (added)
+++ incubator/mod_ftp/trunk/utils/stresstest/mirror.sh Thu Oct  6 06:16:28 2005
@@ -0,0 +1,144 @@
+#!/bin/bash
+#
+# Script to mirror ftp sites.  Used for stress testing the ftp module.
+#
+# This may be run on any host that has wget.
+#
+# See ./mirror.sh --help for usage options
+#
+# Ryan Morgan 7/16/2001
+
+# Defaults
+DIR=.            # Directory to place the mirror
+HOST=localhost   # Host to connect to
+PORT=21          # Port to connect to
+CONCURRENCY=1    # Set the concurrency count
+ITERATIONS=1     # Number of iterations to run
+PASSIVE=0        # Toggle passive mode FTP
+OUTPUT=/dev/null # Where wget's output should go
+
+doinit()
+{
+    for option
+    do
+    case "$option" in
+    -*=*)
+    optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'`
+    ;;
+    *)
+    optarg=
+    ;;
+    esac
+
+    case "$option" in
+    *-help | -h | -help )
+    echo
+    echo "Usage: $0 [options]"
+    echo "Options: [defaults in brackets]"
+    echo "General Options:"
+    echo " --dir=[$DIR]: Directory to place mirror in"
+    echo " --host=[$HOST]: Host to connect to"
+    echo " --port=[$PORT]: Port to connect to"
+    echo " --concurrency=[$CONCURRENCY]: Set the concurrency count"
+    echo " --iterations=[$ITERATIONS]: Number of iterations to run"
+    echo " --output=[$OUTPUT]: Where wget's output should go"
+    echo " --passive: Toggle passive mode"
+    echo
+    exit 0
+    ;;
+    *-dir=*)
+    DIR="$optarg";
+    ;;
+    *-host=*)
+    HOST="$optarg";
+    ;;
+    *-port=*)
+    PORT="$optarg";
+    ;;
+    *-concurrency=*)
+    CONCURRENCY="$optarg";
+    ;;
+    *-iterations=*)
+    ITERATIONS="$optarg";
+    ;;
+    *-output=*)
+    OUTPUT="$optarg";
+    ;;
+    *-passive*)
+    PASSIVE=1;
+    ;;
+    esac
+    done
+}
+
+domirror()
+{
+    mkdir $1; # In the case of concurrent wgets
+    cd $1;
+    if test ${PASSIVE} -eq 1; then
+        wget -m -nv --passive-ftp -o $OUTPUT ftp://$HOST:$PORT
+    else
+        wget -m -nv -o $OUTPUT ftp://$HOST:$PORT
+    fi
+}
+    
+# Initialze
+doinit $*
+
+# Show the options before running
+echo
+echo "Doing mirror of $HOST:$PORT into $DIR"
+echo "Will run $ITERATIONS iterations with concurrency = $CONCURRENCY"
+echo "Output will be placed in $OUTPUT"
+echo -n "Continue? (y/n) "
+read ANS
+if test "X${ANS}" != "Xy" && test "X${ANS}" != "XY"; then
+    echo "Exiting.  See $0 --help for options"
+    exit 0
+fi
+
+# Make sure the target directory exists
+if test ! -d "${DIR}" ; then
+    echo -n "Target directory ${DIR} does not exist, Create? (y/n) "
+    read ANS
+    if test "X${ANS}" = "Xy" || test "X${ANS}" = "XY"; then
+    mkdir ${DIR}
+    if test $? -ne 0; then
+        echo "Failed to create directory: ${DIR}"
+        exit 1
+    fi
+    else
+    echo "Exiting. ${DIR} not created"
+    exit 0
+    fi
+fi
+
+cd ${DIR}
+
+# Mirror it
+while [ ${j:=1} -le ${ITERATIONS} ]
+do
+    echo "Running iteration $j"
+    i=1
+    while [ ${i} -le ${CONCURRENCY} ]
+    do
+        # Launch in a subshell
+        (domirror $i)
+        let i+=1
+    done
+
+    wait # Wait for all the subshells to finish
+
+    # Cleanup
+    i=1
+    while [ ${i} -le ${CONCURRENCY} ]
+    do
+        rm -rf $i
+        let i+=1
+    done
+    let j+=1
+done
+
+echo "Done.  Mirror of $HOST:$PORT done"
+
+exit 0

Propchange: incubator/mod_ftp/trunk/utils/stresstest/mirror.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/mod_ftp/trunk/utils/stresstest/mirror.sh
------------------------------------------------------------------------------
    svn:executable =