Table of Contents |
---|
Warning |
---|
This page is being updated! |
Prerequisites
Most developers create an Asterisk work directory like ~/source/asterisk
or /usr/src/asterisk
then in that directory, clone the Asterisk, Testsuite and support repositories. I'll assume /usr/src/asterisk
in the rest of these instructions and that your tree looks (or will look) like...
...
The
...
If you don't already have the Asterisk source tree checked out and all of its prerequisites installed, please visit Installing Asterisk From Source.
Make sure you're using a supported version of libsrtp. See "Installing libsrtp" for more information.
Install Asterisk
Make sure you can actually build and install Asterisk at least once before proceeding. Once you can, you'll need to follow a few more steps to configure Asterisk and rebuild it for testing:
- Add
--enable-dev-mode
and optionally,--disable-binary-modules
to your./configure
command line. Disabling the binary modules just prevents the need to download the external codecs and res_digium_phone. - In menuselect...
- Under Compiler Flags - Development, enable DONT_OPTIMIZE, MALLOC_DEBUG,
DO_CRASH
andTEST_FRAMEWORK
and disableCOMPILE_DOUBLE
.
- Make sure all modules are enabled. You don't need the Test Modules though. If you enter Test Modules and press
F7
, you can quickly disable all modules.
- Under Compiler Flags - Development, enable DONT_OPTIMIZE, MALLOC_DEBUG,
- Build and install Asterisk and the development header files.
make
sudo make install
sudo make install-headers
The testsuite needs the sample configuration files installed but before you do that, make sure you've saved the contents of /etc/asterisk if you've customized any files. Once you're sure you don't need anything in /etc/asterisk...
sudo make samples
Do NOT start Asterisk at this time. The Testsuite will start and stop it for each test.
Info |
---|
If you want to see how the Jenkins CI process configures Asterisk for testing, check out |
Install Support Packages
Note |
---|
The Testsuite is Python based but not yet fully compatible with Python 3. If you have Python 3 installed, make sure you also have a working Python 2 installation before proceeding. I'll assume you do and the executable is called |
The Testsuite needs several support packages to be installed:
yappcap
yappcap is a Python library that allows the Testsuite to capture packets on an interface. Only a few tests actually use but it should be installed nonetheless:
Code Block | ||||
---|---|---|---|---|
| ||||
$ cd /usr/src/asterisk
$ git clone https://github.com/asterisk/yappcap.git
$ cd yappcap
$ make
$ sudo make install
# If your default Python installation is Python 3, run the makes again with PYTHON=python2
$ make PYTHON=python2
$ sudo make PYTHON=python2 install
|
sipp
sipp is a SIP simulation tool that is relied on heavily by the Testsuite. Most distributions have up to date versions of the tool available. If it's version 3.5.0 or greater, simple use your distro's package manager to install it and skip the rest of the sipp instructions. Otherwise download, build and install it yourself. You'll need to install openssl, libsrtp (or libsrtp2), libpcap, gsl (or libgsl), lksctp-tools (or libsctp1), and their associated development packages (-devel or -dev).
Code Block | ||||
---|---|---|---|---|
| ||||
$ cd /usr/src/asterisk
$ git clone https://github.com/SIPp/sipp.git
$ cd sipp
$ git checkout v3.6.0 ## This is the latest version we KNOW works.
$ ./build.sh --prefix=/usr --with-openssl --with-pcap --with-rtpstream --with-sctp --with-gsl CFLAGS=-w |
When the build completes, check the version:
Code Block | ||||
---|---|---|---|---|
| ||||
$ ./sipp -v
SIPp v3.6.0-TLS-SCTP-PCAP-RTPSTREAM.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
... |
If everything's OK, install it:
Code Block |
---|
$ sudo make install |
StarPy
StarPy is a Python + Twisted protocol that provides access to the Asterisk PBX's Manager Interface (AMI). It's actually bundled as part of the Testsuite but it's easier to install it separately.
Code Block | ||||
---|---|---|---|---|
| ||||
$ cd /usr/src/asterisk
$ git clone https://github.com/asterisk/starpy.git
$ cd starpy
$ sudo python setup.py install
# If your default Python installation is Python 3, run again using python2 instead of python.
$ sudo python2 setup.py install
|
Install the Testsuite
Code Block | ||||
---|---|---|---|---|
| ||||
$ cd /usr/src/asterisk
$ git clone https://gerrit.asterisk.org/testsuite
$ cd testsuite
|
Install Prerequisites
There's a contrib/scripts/install_prereq
script but it assumes that the python
executable runs Python 2. If you're running on a system where Python 3 is the default (most are nowadays), you'll need to install the prerequisites yourself.
If your distribution doesn't provide packages for python2, you'll need to install them using pip.
Ubuntu 20.04 (and possible others) do not include pip for python2, which also does not include python-twisted or python-construct. The following method to add pip for python2 has been tested to work as of 10/21.
Code Block | ||||
---|---|---|---|---|
| ||||
$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
$ sudo python2 get-pip.py
$ sudo pip2 install twisted
$ sudo pip2 install construct |
All below is still in progress...
With the Test Suite checked out, we can begin to install its various prerequisites.
ASTTest Installation
Enter the following:
...
$ cd asttest
$ make
$ sudo make install
Verify that asttest was installed by doing the following:
...
$ asttest
asttest: missing arguments -- specify at least one test directory
Usage:
....
When finished, return to the Test Suite directory:
...
$ cd ..
Third Party Libraries
The following needs to be installed:
- lua-devel
- lua
- python-twisted
- libpcap-devel
- python-yaml
- python-devel
- python-construct
StarPY Installation
StarPY is used as a wrapper around AMI for a large number of tests. It depends on Python twisted, which a number of the tests use as well.
Perform the following:
...
$ cd addons
$ make update
$ cd starpy
$ sudo python setup.py install
When finished, return to the testsuite directory:
...
$ cd ../..
SIPp Installation
For SIPp, we'll need to download the source and build it ourselves, as we'll want both pcap and openssl support. The current minimum version required is 3.4.1.
Enter the following:
...
$ mkdir sipp
$ cd sipp
$ wget https://github.com/SIPp/sipp/archive/v3.4.1.tar.gz
$ tar -zxvf v3.4.1.tar.gz
$ cd sipp-3.4.1
$ ./configure --with-pcap --with-openssl
$ sudo make install
By default, sipp is installed in /usr/local/bin. If you want it installed to /usr/bin, add '–prefix=/usr' to the configure command.
Verify that sipp is installed and configured correctly:
...
$ sipp -v
SIPp v3.4.1-TLS-PCAP-RTPSTREAM ...
When finished, return to the testsuite directory
...
$ cd ../..
...
Info |
---|
This step isn't needed if Asterisk was configured with |
Enter the following:
...
$ svn co http://svn.pjsip.org/repos/pjproject/trunk pjproject
$ cd pjproject
$ ./configure CFLAGS=-fPIC
$ cp pjlib/include/pj/config_site_sample.h pjlib/include/pj/config_site.h
$ vim pjlib/include/pj/config_site.h
in the vim console, hit i and insert the following:
...
#define PJ_HAS_IPV6 1
...
Continue the pjsip build process:
...
$ make dep
$ make
Copy the pjsua executable:
...
$ sudo cp pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu /usr/sbin/pjsua
Verify that pjsua executes:
...
$ pjsua
...
You have 0 active call
>>>
...
Install pjsua Python bindings
...
sudo make -C pjsip-apps/src/python install
Return to the testsuite directory:
...
$ cd ~/asterisk/testsuite
Verify the Test Suite
Note |
---|
If you haven't run make samples (which you shouldn't have, if you were following the instructions), you'll need to have an asterisk.conf file in /etc/asterisk before the Test Suite will work. Copy one over - it doesn't matter what is in it for now |
Enter the following:
...
$ ./runtests.py -l
...
StarPy is a Python + Twisted protocol that provides access to the Asterisk PBX's Manager Interface (AMI)
Test Suite has been moved to a Python 3 version with simplified installation. Instructions for this can be found here.