Skip to content
QiTASC.com /
Sharky for Audio and Network Recording Steps
/
Sharky for Audio and Network...





Sharky for Audio and Network Recording Steps

Sharky is a program that runs independent of intaQt as a service. It listens on a given port for HTTP GET requests. HTTP is used as a communication protocol to control Sharky remotely using a web browser or command line tools such as wget or curl.

Depending on Sharky's configuration, it can be used for one or both of the following actions:

  • Record network traffic

  • Record sound

If Sharky is required to perform both actions on the same machine, it needs to be started twice. The first instance offers network traffic recording on one TCP port, with the other offering audio recording on another TCP port. Depending on the TCP port the request is sent to, either the network recording Sharky (arecord) or the audio recording Sharky (tshark) will react.

Sharky
Configuration
Network Recording Service Configuration
Audio Recording Service Configuration
Requests to Sharky
Launching Sharky
Record Audio with Sharky
Record Audio For a Part of a Scenario
Record Audio for an Entire Scenario
Record Audio for all Scenarios Within a Feature File
Record Network Traffic with Sharky
Use Both @TraceNet and @TraceAudio Tags

Configuration

Sharky must be configured in its own file, for example, sharky.conf. A set of Sharky services can be configured to run on different machines, all of which will be used when a test scenario requests it.

intaQt server.conf also needs to be configured to make use of the running Sharky services. These instructions can be found in Sharky Configuration.

Network Recording Service Configuration

The program tshark must be installed on the machine running Sharky in order to use Sharky for network traffic recording. tshark is the command line version of the program wireshark. On request, Sharky will make use of tshark to capture network traffic and save it in the wireshark format, PCAP.

Important! tshark must be invokable without admin permissions by adding the relevant user to the wireshark user group (see: Wireshark).

Syntax

1
2
3
4
5
6
7
8
{
    Tshark : {
        Listen    : <port String>,
        FsRoot    : <fsRoot String>,
        Interface : <networkInterface,
        Filter    : <captureFilter String>
    }
}

Parameters

  • port - The port the Sharky listens to

  • fsRoot - The location where trace files are stored and served from

  • networkInterface - The network interface that tshark monitors when invoked

  • captureFilter - The libpcap filter for only recording specific packets on the network (for the syntax of filters, see Capture Filters

    • To disable filtering, use an empty string ("")

When no network interface is given, tshark listens on the first network interface that is shown upon invocation of tshark -D from the command line.

Example

1
2
3
4
5
6
7
8
{
    Tshark : {
        Listen   : ":6789",
        FsRoot   : "/home/User/networkRecords",
        Interface : "wlan2",
        Filter    : ""
    }
}

Audio Recording Service Configuration

A USB microphone must be attached, and the program arecord must be installed on the machine running Sharky in order to use Sharky for audio recording. On request, Sharky will make use of arecord and the microphone to record audio and save it as a *.wav file. These files can also be converted to *.mp3 if a LAME audio encoder is installed on the Sharky host.

Note: A Samson Go Microphone must be used with arecord.

Syntax

1
2
3
4
5
6
7
8
9
{
    Arecord : {
        Listen    : <port String>,
        FsRoot    : <fsRoot String>,
        Format    : <audioFormat String>,
        Mic       : <audioDevice String>
        Extra     : <qualityOptions String>
        }
}

Parameters

  • port - The port the Sharky listens to

  • FsRoot - The location where trace files are stored and served from

  • audioFormat - The audio recording format

    • U8 is used for mono recording with 8kHz (default), while a high-quality alternative is cd (CD quality – stereo with 44.1 kHz)
  • audioDevice - The audio recording device (check with arecord -L on the command line)

  • qualityOptions (optional) - Tells Sharky to use lame

    • Values are -V<n>, with n ranging from 0 (highest quality, least compression) to 9 (lowest quality, best compression)
    • These options trigger the lame variable bitrate mp3 compression

Example

1
2
3
4
5
6
7
8
9
{
    Arecord : {
        Listen    : ":6790",
        FsRoot    : "/home/User/audioRecords",
        Format   : "U8",
        Mic       : "plughw:CARD=GoMic,DEV=0"
        Extra     : "-V9"
        }
}

Requests to Sharky

Every request is answered with a text response consisting of a Sharky status code ("OK" or "NOK") and a message.

Sharky accepts the following commands:

  • start

  • info

  • stop

The command is part of the URL that is used for the request.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
user@intaqt-devd-03 ~ wget -qO- http://localhost:6789/start

OK
LOG_1401971609_319673.pcap

user@intaqt-devd-03 ~ wget -qO- http://localhost:6789/info

OK
args: tshark -w /home/user/FILESERVER/pcap.pcap -i wlan2
env:
dir:
path: /usr/bin/tshark
PID:  13481
log:  LOG_1401971609_319673.pcap

user@intaqt-devd-03 ~ wget -qO- http://localhost:6789/stop?arg=LOG_1401971609_319673.pcap

OK
App stopped

The example above uses a Sharky running on the local machine, in other words, the same machine the request is issued from, and on port 6789, offering network traffic recording.

  • The first command, start, starts to record the network traffic.

  • The second command, info, returns internal information about what Sharky is doing.

  • The third command, stop, stops the recording and saves the recorded data to a file. The filename is specified as an argument to the stop command. This file is transferred in the HTTP GET response message of the stop command and needs to be saved by the requester.

Launching Sharky

The Sharky binary can be launched using the following options:

  • help - Displays information on the Sharky invocation.

  • config=<FILE> - Defines <FILE> to hold the Sharky configuration and uses it.

  • -nolog - Disables logging of Sharky. All log messages are displayed on stdout.

  • -app=<APP>- Defines which application shall be managed by Sharky. <APP> is one of {"arecord"} or {"tshark"}.

Sharky automatically produces log entries on stdout and writes them to the file /tmp/Sharky.log, except the -nolog option is used.

Example

1
./Sharky -config=/home/user/MySharkyConfiguration.conf -nolog -app=arecord

The above example uses the file MySharkyConfiguration.conf for configuring Sharky, disables logging, and it manages the arecord application.

Once Sharky is started, its logging output can be monitored:

  • On STDOUT if the –nolog option was given.

  • Using tail -f /tmp/Sharky.log if the -nolog option was omitted.

Log Output After Successfully Starting Sharky for Audio Recording Example

After launching Sharky successfully, Sharky will produce output similar to the following:

1
2
3
2014/06/18 09:22:14 Microphone at:  plughw:CARD=GoMic,DEV=0
2014/06/18 09:22:14 Creating worker for arecord ...
2014/06/18 09:22:14 [:6667, serving from /tmp] arecord -f U8 -D plughw:CARD=GoMic,DEV=0  .wav

Record Audio with Sharky

There are two option for using Sharky to record audio. Either the annotation @TraceAudio is used in a Feature File or a Stepdef (../intactbasics/stepdefs) is created to start and stop audio recording.

Record Audio For a Part of a Scenario

An audio recording starts when the step an audio recording is started is executed. It stops a specified number of seconds after the step after <number Number> seconds, an audio recording is stopped is executed. In this case, the annotation @TraceAudio must not be used.

Syntax

1
2
3
4
5
6
7
8
Feature: <name String>

Scenario: <name String>
 ...
 When an audio recording is started
 ...
 Then after <number Number> seconds, an audio recording is stopped
 ...

Parameters

  • name - The parameter's assigned name

  • number - The number of seconds until the audio recording is stopped

Example

1
2
3
4
5
6
When A dials the number mailbox
And an audio recording is started
And within 5 seconds, A connects
And A switches loudspeaker on
And after 15 seconds, A ends the call
And an audio recording is stopped

Record Audio for an Entire Scenario

To record audio for an entire scenario, it must be annotated with @TraceAudio. Here, Stepdefs to start and stop audio recording are not needed. Audio recording will begin before the scenario starts and will stop after the scenario has finished.

Syntax

1
2
3
4
5
Feature: <featureName String>

@TraceAudio
Scenario: <scenarioName String>
  ...

Parameters

  • featureName - The Feature File's name

  • scenarioName - The Scenario's name

Record Audio for all Scenarios Within a Feature File

To record audio for all scenarios within a Feature File, use the annotation @TraceAudio before the keyword Feature in the Feature File.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@TraceAudio
Feature: UI Steps on Chrome

Scenario: 10a/1
    Given open browser chrome as browser
    Then on myBrowser, open Integration Test One website

Scenario: 10a/2
    Given open browser chrome as browser
    Then on myBrowser, open Integration Test Two website

Record Network Traffic with Sharky

For recording network traffic, use the annotation @TraceNet either for a certain scenario or for all scenarios in a Feature File by putting it before the keyword Feature.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Feature: UI Steps on Chrome

@TraceNet
Scenario: 10a/1
    Given open browser chrome as browser
    Then on myBrowser, open Integration Test One website

Scenario: 10a/2
    Given open browser chrome as browser
    Then on myBrowser, open Integration Test Two website

In this example, only Scenario 10a/1 is tagged with @TraceNet, meaning only it will have network tracing enabled. After the Scenario passes, the network trace is available in a report.

Use Both @TraceNet and @TraceAudio Tags

Both of the @TraceNet and @TraceAudio tags can be used in the same scenario. Although an audio-tagged scenario could also use audio steps (such as And an audio recording is started), this complicates the scenario. Additionally, there is no dedicated step for controlling network traffic logging.