Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added method for downloading pip for python2

Table of Contents

Prerequisites

  1. A working knowledge of Linux, Subversion, and Asterisk.
  2. A Linux distribution.  This guide does not assume a lot has been installed on the machine in question; however, some things may be needed on your distribution that were already installed for this guide.  Use common sense here.
  3. SVN is installed

Install Asterisk Prereqs

In order to make sure that all of the current Asterisk prerequisites are installed and set up, we will first check-out Asterisk and make sure that we can build and run Asterisk outside of the control of Bamboo.

Open a terminal and enter the following:

...

$ cd
$ svn co http://svn.asterisk.org/svn/asterisk/trunk asterisk_trunk
$ cd asterisk_trunk
$ cd contrib
$ cd scripts
$ sudo ./install_prereq install

This will typically install a large number of Asterisk prerequisites. When it is finished, you should see:

...

######################################
## install completed successfully
######################################
Info

As of the time writing this, install_prereq does not install the SQLite3 package. If the Asterisk ./configure script fails, install sqlite-devel

Perform the following:

...

$ cd ../../
$ ./configure --enable-dev-mode
$ make
$ sudo make install
$ asterisk -cvvvg

Verify that Asterisk starts. On the Asterisk CLI, enter:

...

CLI> core stop now
Note

If installing Asterisk as a non-root user, Asterisk may not be able to find libasteriskssl.so.1. Verify that the shared library was built and in /usr/lib. If it is, activate the current library path by entering "sudo ldconfig"

Third Party Libraries

Install spandsp

For fax support, you'll need spandsp.

Install libtiff

...

$ sudo yum install libtiff-devel

...

Assuming that you downloaded it to Downloads (we'll assume that this is spandsp-0.0.6):

...

$ cd ~/Downloads/
$ tar -xzf spandsp-0.0.6
$ cd spandsp-0.0.6
$ ./configure
$ make
$ sudo make install
Note

spandsp installs itself into /usr/local/lib. If that isn't in your library include path, res_fax_spandsp will build but will not load, causing the fax tests to fail (typically with INIT failures).

Install libsrtp

For SRTP, you'll need libsrtp. To obtain that library, perform the following:

...

$ wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
$ tar xvf srtp-1.4.2.tgz
$ cd srtp
$ ./configure CFLAGS=-fPIC --prefix=/usr
$ make
$ make runtest
$ sudo make install

Install Asterisk Test Suite Prereqs

Check out the Asterisk Test Suite by doing the following:

$ cd $ cd asterisk_trunk $ svn co http://svn.asterisk.org/svn/testsuite/asterisk/trunk testsuite $ cd testsuite
Code Block
bashbash
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...

No Format
/usr/src/asterisk/
	asterisk/		The asterisk repository cloned from https://gerrit/asterisk.org/asterisk
	testsuite/		The testsuite repository clones from https://gerrit/asterisk.org/testsuite 

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_DEBUGDO_CRASH and TEST_FRAMEWORK and disable COMPILE_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.
  • 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 tests/CI/buildAsterisk.sh in the Asterisk source tree.

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 python2.

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
titleyappcap Installation
languagebash
$ 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
titlesipp Installation
languagebash
$ 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
titleCheck sipp version
languagebash
 $ ./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
titleStarPy Installation
languagebash
$ 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
titleTestsuite Installation
languagebash
$ 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
titleInstall Prerequisites
languagebash
$ 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.

...

  1. Enter the following:

    Code Block
    bash
    bash
    $ cd asttest
    $ make
    $ sudo make install
    
  2. Verify that asttest was installed by doing the following:

    Code Block
    bash
    bash
    $ asttest
    asttest: missing arguments -- specify at least one test directory
    Usage:
     ....
    
  3. When finished, return to the Test Suite directory:

    Code Block
    bash
    bash
    $ 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.

...

  1. Enter the following:

    Code Block
    bash
    bash
    $ 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.

     

  2. Verify that sipp is installed and configured correctly:

    Code Block
    bash
    bash
    $ sipp -v
    
    SIPp v3.4.1-TLS-PCAP-RTPSTREAM ...
    
  3. When finished, return to the testsuite directory

    Code Block
    bash
    bash
    $ cd ../..
    

Anchor
pjsua_installation
pjsua_installation
PJSUA Installation

Info

This step isn't needed if Asterisk was configured with --with-pjproject-bundled

 

  1. Enter the following:

    Code Block
    bash
    bash
    $ 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
    
  2. in the vim console, hit i and insert the following:

    Code Block
    c
    c
    #define PJ_HAS_IPV6 1
    
  3. Hit Esc, then type :wq to save and exit vim
  4. Continue the pjsip build process:

    Code Block
    bash
    bash
    $ make dep
    $ make
    
  5. Copy the pjsua executable:

    Code Block
    bash
    bash
    $ sudo cp pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu /usr/sbin/pjsua
    
  6. Verify that pjsua executes:

    Code Block
    bash
    bash
    $ pjsua
    ...
    You have 0 active call
    >>>
    
  7. Enter q to exit
  8. Install pjsua Python bindings

    Code Block
    bash
    bash
    sudo make -C pjsip-apps/src/python install
    
  9. Return to the testsuite directory:

    Code Block
    bash
    bash
    $ cd ~/asterisk_trunk/testsuite
    

Verify the Test Suite

...

  1. Enter the following:

    Code Block
    bash
    bash
    $ ./runtests.py -l
    
  2. Verify that the tests are listed out, and that the required dependencies (that you care about, anyway) are true.

StarPy is a Python + Twisted protocol that provides access to the Asterisk PBX's Manager Interface (AMI)