This guide explains how to confirm the version of Python, create a virtual environment, install the necessary requirements, and run the viptest.py
script. The repository is hosted at https://github.com/tmarfil/viptest/tree/main.
First, confirm that you have Python 3.8.x or later installed on your system.
python3 --version
If Python 3.8.x or later is installed, the output should be something like:
Python 3.8.10
Although the documented instructions are for Linux, VIPTest also works on Windows (WSL2), and MacOS (Zsh using homebrew).
-
Update the package list
sudo dnf update
Enable the CodeReady Builder repository
sudo dnf config-manager --set-enabled crb
Install python3-virtualenv
sudo dnf install python3-virtualenv
Install pip3
sudo dnf install python3-pip
-
Update the package list
sudo apt update
Install python3-venv
sudo apt install python3-venv
Install pip3
sudo apt install python3-pip
To install the complementary packages (time, diff, sort, tee, expect):
-
sudo dnf install time diffutils coreutils expect
-
sudo apt-get install time diffutils coreutils expect
The coreutils
package includes tee
and sort
commands.
-
Create the virtual environment:
python3 -m venv myenv
-
Activate the virtual environment:
source myenv/bin/activate
-
Confirm the Python version inside the virtual environment:
python3 --version
This should output the Python version being used in the virtual environment, e.g.,
Python 3.8.10
.
Install the required Python packages using the requirements.txt
file hosted in the git repository.
-
Clone the repository:
git clone https://github.com/tmarfil/viptest.git cd viptest
-
Install the requirements:
pip3 install -r requirements.txt
Ensure viptest.py
is executable. You can either add it to your $PATH
or call it directly. To make it executable:
sudo chmod +x viptest.py
Run the script with the following command:
viptest.py -c 10 --csv testfile.csv
viptest.py
: Executes the script.-c 10
: Specifies the number of concurrent processes.--csv testfile.csv
: Specifies the CSV file to use.
The repository includes a testfile.csv
to run tests against an example list of applications. This can be tested with:
time unbuffer viptest.py --csv testfile.csv -c 50 > >(tee logfile1.log) 2>errors1.log
time
: Measures the time taken to execute the command.unbuffer
: Ensures that the output is not buffered, providing real-time output.viptest.py --csv testfile.csv -c 50
: Executes the script with the specified CSV file and concurrency level.> >(tee logfile1.log)
: Redirects standard output tologfile1.log
while also printing it to the terminal.2>errors1.log
: Redirects standard error toerrors1.log
.
logfile1.log
contains the standard output of the script execution, which includes the results of the URL processing tests.
To quickly report on virtual servers that are not healthy:
cat logfile1.log | grep Error
Example output:
[https://www.python.org] Error processing https://www.python.org: timed out
First run:
time unbuffer viptest.py --csv testfile.csv -c 10 > >(tee logfile1.log) 2>errors1.log
Next run (after some change in the environment):
time unbuffer viptest.py --csv testfile.csv -c 10 > >(tee logfile2.log) 2>errors2.log
Sort the log files and compare the outputs to see what has changed:
-
Sort the log files:
sort logfile1.log > sorted_logfile1.log && sort logfile2.log > sorted_logfile2.log
-
Diff the sorted log files:
diff sorted_logfile1.log sorted_logfile2.log
sort logfile1.log > sorted_logfile1.log
: Sorts the contents oflogfile1.log
and writes it tosorted_logfile1.log
.diff sorted_logfile1.log sorted_logfile2.log
: Compares the sorted log files and outputs the differences.
The following variables can be adjusted within the viptest.py
script:
- USE_HTTP2: Enables or disables HTTP/2 for HTTPS requests.
- IGNORE_CERTIFICATE_WARNINGS: Determines whether to ignore SSL certificate warnings.
- MAX_CONCURRENCY: Sets the maximum number of concurrent processes.
- NAME_RESOLUTION_OVERRIDE: Decides whether to use the IP address provided in the CSV file to override the system DNS resolution.
Note: Exiting a Python Virtual Environment
To exit a Python virtual environment, simply run the
deactivate
command. This will deactivate the virtual environment and return you to your normal shell.deactivateOnce you run this command, your shell prompt should no longer show the name of the virtual environment, indicating that you have successfully exited it.
This guide explains how to create a CSV file for use with the viptest.py
script and the expected behavior of the program. The CSV file consists of two columns: the first column is either a URL scheme or an IP address (with or without a port), and the second column contains an optional IP address.
The CSV file should have two columns:
- First Column: URL scheme or IP address, with or without a port.
- Second Column: Single IP address (optional).
Here is an example of a CSV file with five lines:
https://rudysbbq.com, 203.0.113.5
http://example.com, 192.0.2.1
192.168.50.50:23,
https://anotherexample.com:8443, 198.51.100.10
http://testsite.com,
-
https://rudysbbq.com, 203.0.113.5
- Behavior: The program will report on the TLS version and ciphers and the response code from an HTTPS GET request to
https://rudysbbq.com
. The port defaults to 443 for HTTPS if none is specified. - IP Override: If
NAME_RESOLUTION_OVERRIDE = True
, the FQDNrudysbbq.com
will resolve to the IP address203.0.113.5
for the test.
- Behavior: The program will report on the TLS version and ciphers and the response code from an HTTPS GET request to
-
http://example.com, 192.0.2.1
- Behavior: The program will perform an HTTP GET request to
http://example.com
and report the response code. The port defaults to 80 for HTTP if none is specified. - IP Override: If
NAME_RESOLUTION_OVERRIDE = True
, the FQDNexample.com
will resolve to the IP address192.0.2.1
for the test.
- Behavior: The program will perform an HTTP GET request to
-
192.168.50.50:23,
- Behavior: Since no HTTP or HTTPS scheme is specified, the program will ping the IP address
192.168.50.50
and check the status of port 23 (open or closed).
- Behavior: Since no HTTP or HTTPS scheme is specified, the program will ping the IP address
-
https://anotherexample.com:8443, 198.51.100.10
- Behavior: The program will report on the TLS version and ciphers and the response code from an HTTPS GET request to
https://anotherexample.com:8443
. - IP Override: If
NAME_RESOLUTION_OVERRIDE = True
, the FQDNanotherexample.com
will resolve to the IP address198.51.100.10
for the test.
- Behavior: The program will report on the TLS version and ciphers and the response code from an HTTPS GET request to
-
- Behavior: The program will perform an HTTP GET request to
http://testsite.com
and report the response code. The port defaults to 80 for HTTP if none is specified. - IP Override: No IP address is provided, so the program will use system DNS to resolve the FQDN.
- Behavior: The program will perform an HTTP GET request to
-
https://example.com/path/to/resource, 192.168.1.1
- Behavior: The program will report on the TLS version and ciphers and the response code from an HTTPS GET request to
https://example.com/path/to/resource
. The port defaults to 443 for HTTPS if none is specified. - IP Override: If
NAME_RESOLUTION_OVERRIDE = True
, the FQDNexample.com
will resolve to the IP address192.168.1.1
for the test.
- Behavior: The program will report on the TLS version and ciphers and the response code from an HTTPS GET request to
-
When
NAME_RESOLUTION_OVERRIDE = True
(default):- The program will always override system DNS and resolve FQDNs in the first column to the IP address in the second column. This ensures consistent testing against the same Virtual Server / VIP in environments where an FQDN can resolve to multiple IP addresses or when testing an environment that is not yet resolvable via DNS.
-
When
NAME_RESOLUTION_OVERRIDE = False
:- The program will rely on system DNS to resolve FQDNs in the first column and ignore the IP address in the second column.
By following these guidelines, you can create a CSV file that is compatible with the viptest.py
script and understand how the program will behave based on the entries and configuration.
We welcome contributions to the VIPTest project. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or suggestions, please open an issue or contact tmarfil.
Thank you for using VIPTest!