Skip to content

Commit

Permalink
Merge branch 'feature-test_scripts' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm1986 committed Jun 4, 2015
2 parents 9163016 + f2f365e commit a4452fa
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 13 deletions.
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# HTTP-2-Testing
# HTTP/2 - Testing
This repository contains all necessary for deploy HTTP/2 testing server or clients. The "clients" directory contains the scripts for download and install clients with HTTP 2 support easily. The "tests" folder contains some test templates and bash scripts for test automatization. You can get more info in to the README.md file located inside each folder.


### Version
0.0.1
## Version
0.1.0


### Installation
## Installation

You need Git installed on your computer:

Expand All @@ -23,7 +23,7 @@ $ cd http2-testing
```


### Content
## Content

This repository is organized under directories according with the content:

Expand All @@ -41,24 +41,21 @@ This repository is organized under directories according with the content:
└───scripts/ # Bash scripts for test automation.
│ README.md: # This file contains info about how to configure and launch tests automatically.
|
├───h2/ # HTTP/2 scripts (for https:// URLs).
└───h2c/ # HTTP/2 Clear Text scripts (for http:// URLs).
└───results/ # The file result of each test will be save under this directory.
```


### Tests
## Tests

This repository contains a lot of tests for HTTP/2. The description about these tests are inside tests/README.md file. You can access to this file directly clicking [here](tests/README.md).


### Todo
## Todo

- Test Bash Scripts
- Clients installers


License
----

MIT
MIT
56 changes: 56 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# HTTP/2 - Testing Framework Script

## Requirements
This script use [NGHTTP2](https://nghttp2.org/) client for make the HTTP/2 tests. If this client is not present on your system, you can use the installation script from this repository under "clients" directory.


## How it works?

The main functionality of this script is load the list of tests defined on "tests.list" directories and launch all of them sequentially.

You can launch the tests using the following command:

```sh
$ ./run_tests.sh 1000
```

You have to define the amount number that each test will be executed as input parameter. On the previous line, the script repeats each HTTP/2 test 1000 times.

The results of the tests, will be saved under "results" directory. The name of the output file, is defined on "test.list" file individually for each test.


## Config file
You have to customize the test script configuration file using a text editor before start. For example:

```sh
$ sudo nano config.conf
```

Each field on this configuration file is described inside the file.


## Test list file
All tests to be executed by this script, must be defined inside "test.list" file. You can edit using this command:

```sh
$ sudo nano test.list
```

The only way for defined a test is using four arrays with the same index. These arrays are the following:

- **TestName:** Contains the route to the template file from the remote test server.
- **TestFilename:** Set the name for the output where the test results will be saved.
- **TestParameter:** Define the input options for NGHTTP client. For get more info about all possibilities, please click [here](https://nghttp2.org/documentation/nghttp.1.html#options).

This is an example of test definition:

```bash
TestName=(${TestName[@]} "/test/test_01.html")
TestFilename=(${TestFilename[@]} "h2c_Performance_01_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
```

The user only have to modify the values between double quotes for defined or customize a test.

**WARNING:** The rest of the code inside test.list file must be the same without changes.
21 changes: 21 additions & 0 deletions scripts/config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#########################################################
# HTTP/2 - Test Framework Script Config File #
#########################################################

#--------------------------------------------------------
# Server Parameters
#--------------------------------------------------------
# Write the URL without http:// or https://
URL="testhttp2.bluevia.com"

# If your server uses other ports than the defaults,
# please change this values with the correct port number.
HTTP_PORT=80
HTTPS_PORT=443

#--------------------------------------------------------
# Client Parameters
#--------------------------------------------------------
# Write here the route or command of your NGHTTP2 client
# binary.
NGHTTP2=nghttp
69 changes: 69 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -e
# Load configuration file:
source config.conf

# Read the number of the repetitions for each test
NUM_REPETI=1 # Default value
if [[ $# -ne 0 ]] && [[ $1 -gt 0 ]];
then
echo "[ INFO ]The tests will be repeated: $1 times."
NUM_REPETI=$1
fi

# Load the Tests description file
source test.list

# Launch each test
TOTALTESTS=${#TestFilename[@]}-1
for (( i=0; i<${#TestFilename[@]}; i++ ))
do
echo "[ INFO ] Executing test number: $i"

# Selecting correct port in function of the URL preamble
if [ ${TestUrlPreamb[$i]} == "http://" ];
then
PORT=$HTTP_PORT
elif [ ${TestUrlPreamb[$i]} == "https://" ];
then
PORT=$HTTPS_PORT
else
echo "[ ERROR ] Bad URL preamble selected on test number $i."
continue
fi
# Creating the command to be execcuted
FULL_COMMAND="$NGHTTP2 ${TestParameter[$i]} ${TestUrlPreamb[$i]}$URL:$PORT${TestName[$i]}"
echo "[ COMMAND ] $FULL_COMMAND"

for(( j= 0; j<$NUM_REPETI; j++ ))
do
printf "[ STATUS ] Running test number $i repetition $j... "
# Test Command Execution and getting the last output line
TEST_LAST_LINE=$(eval $FULL_COMMAND | tail -n 1)
echo "[ OK ]"
echo "[ DEBUG ] $TEST_LAST_LINE"

# Getting the test total time
responseTime=$(echo $TEST_LAST_LINE | awk '{print $2}') # Get the total time. Example: +34.34s
responseTime=${responseTime:1} # Deleting + symbol from the value (first character)

# Calculating multiplier to parse responseTime to microseconds (us)
valueUnit=$(echo $responseTime | tail -c 3)
echo "[ DEBUG ] Text of the unit value: $valueUnit"
case $valueUnit in
[0-9]*s) multiplier=1000000 ;;
ms) multiplier=1000 ;;
us) multiplier=1 ;;
*) echo "[ERROR] Not valid unit for total test time. Received: $valueUnit"
continue;;
esac
responseTime=$(echo $responseTime | grep -Po '(\d+.*\d+)') # Deleting units from the value
echo "[ DEBUG ] Response time: $responseTime"
valueToSave=$(python -c "print $responseTime * $multiplier") # Parsing time to microseconds
echo "[ DEBUG ] Value to save on result file: $valueToSave"

# Saving test time to results file
echo "$valueToSave" >> "results/${TestFilename[i]}"
done
done
exit 0
140 changes: 140 additions & 0 deletions scripts/test.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#########################################################
# HTTP/2 - Test Framework Script Test List #
#########################################################
# Each test is defined as an array with the following
# structure:
#--------------------------------------------------------
# TEST xx: Test Description
#--------------------------------------------------------
# TestName=(${TestName[@]} "/test/file_01.html")
# TestFilename=(${TestFilename[@]} "h2c_7.2.1_$NUM_REPETI.dat")
# TestParameter=(${TestParameter[@]} "-uvnas")
# TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 00 - H2C: Performance Template 01
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_01.html")
TestFilename=(${TestFilename[@]} "h2c_Performance_01_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 01 - H2: Performance Template 01
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_01.html")
TestFilename=(${TestFilename[@]} "h2_Performance_01_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 02 - H2C: Performance Template 02
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_02.jpg")
TestFilename=(${TestFilename[@]} "h2c_Performance_02_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 03 - H2: Performance Template 02
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_02.jpg")
TestFilename=(${TestFilename[@]} "h2_Performance_02_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 04 - H2C: Performance Template 03
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_03.html")
TestFilename=(${TestFilename[@]} "h2c_Performance_03_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 05 - H2: Performance Template 03
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_03.html")
TestFilename=(${TestFilename[@]} "h2_Performance_03_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 06 - H2C: Performance Template 04
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_04.php")
TestFilename=(${TestFilename[@]} "h2c_Performance_04_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 07 - H2: Performance Template 04
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_04.php")
TestFilename=(${TestFilename[@]} "h2_Performance_04_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 08 - H2C: Performance Template 05
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_05.txt")
TestFilename=(${TestFilename[@]} "h2c_Performance_05_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 09 - H2: Performance Template 05
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_05.txt")
TestFilename=(${TestFilename[@]} "h2_Performance_05_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 10 - H2C: Performance Template 06
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_06.html")
TestFilename=(${TestFilename[@]} "h2c_Performance_06_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 11 - H2: Performance Template 06
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_06.html")
TestFilename=(${TestFilename[@]} "h2_Performance_06_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 12 - H2C: Performance Template 10
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_10.html")
TestFilename=(${TestFilename[@]} "h2c_Performance_10_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 13 - H2: Performance Template 10
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_10.html")
TestFilename=(${TestFilename[@]} "h2_Performance_10_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")


#--------------------------------------------------------
# 14 - H2C: Performance Template 11
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_11.html")
TestFilename=(${TestFilename[@]} "h2c_Performance_11_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-uvnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "http://")
#--------------------------------------------------------
# 15 - H2: Performance Template 11
#--------------------------------------------------------
TestName=(${TestName[@]} "/test/test_11.html")
TestFilename=(${TestFilename[@]} "h2_Performance_11_$NUM_REPETI.dat")
TestParameter=(${TestParameter[@]} "-vnas")
TestUrlPreamb=(${TestUrlPreamb[@]} "https://")
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HTTP-2-Testing Framework
# HTTP/2 - Testing Framework

## Requirements
All test pages use [Bootstrap](http://getbootstrap.com/) Framework for its design. On the other hand, your server must be [PHP 5](http://php.net/) support enabled.
Expand Down

0 comments on commit a4452fa

Please sign in to comment.