Script Generation Tools

Script generation tool (nsu_gen_cscript) is used to generate script using URL. Script generated by this utility can be used in any scenario for running any test. Without this, record a script and then use this script (or any other existing script) in scenario for testing. Many times, user may need to test one or more URLs. To make it simpler, NetStorm comes with this utility to automatically generate scripts using any URL(s).

Usage

nsu_gen_cscript usage is:

nsu_gen_cscript -s <proj/subproj/scriptname> -f <url file name> or -u URL1, URL2,… -d [to enable debug log] –r [for replay access log] or -F <flow name> -b [for body of methods]

Where

  • -s <script-name> is required and is used to specify the name of the script to be generated.
    • Script with the same name should not be present in the system
    • Script is created in $NS_WDIR/scripts directory
  • -f and -u are exclusive. User can give either -f or -u option.
  • -u <URL List> is used to specify the URL(s).
    • URL may repeat. At least one is required (e.g. -u url1 -u url2)
    • Multiple URL can also be given using comma separated list (e.g. -u http://abc.com, https://xyz.com)
    • Through this option only URL can be given not the level, method etc.
  • -f <input-file> is used to specify input file from where URL(s) are taken for script creation.
    • Only one -f <input-file> can be provided
  • -d is used to enable debug log.
  • -r is used to create script for replay access log.
  • -F is used to specify flow name given by user.
  • -r and -F options are exclusive. User can give either -r or -F.
  • -b is used when using body with methods GET, PUT, POST and HEAD methods.

Input File Format

Input file for replay access log has following format:

# Input file for nsu_gen_cscript utility with -r option has following format:

# [http|smtp] [level] [get | post] [http][s]://<hostname>[:<port>]/[<url>] [flow/page name]
1 GET http://127.0.0.1/file_set/dir00000/class0_0.html (First Main URL)
2 GET http://127.0.0.1/file_set/dir00000/class0_0.html (Embedded of First Main URL)
1 POST http://127.0.0.1/file_set/dir00000/class1_8.html (Second Main URL)

Command : nsu_gen_cscript –s default/default/scriptname –f script.inp -r

Command Output

In case of error, it shows error message and proper (non zero) exit value. If successful, it creates script (${NS_WDIR}/scripts/<Project Name>/<Sub Project Name>/<script-name>) with following files:

  • flow.c
  • init_script.c
  • exit_script.c
  • registrations.spec
  • runlogic.c
  • dump file(s)

The file(s) and depth is created in <script name>/dump/flow in respective to the URL. This file is generated according to the given main and embedded URL value and depth. These are created for demo purpose only and do not contain real response. This creates the file which contains the below string followed by body if given for that URL:

This file is generated by nsu_gen_cscript for page – <Page Name>

 NoteThese files are generated only for HTTP.

Header file(s)

These file are generated in <Script Name>/dump/flow/headers/ for main page only. The file name is as page_<Number Of Page>.txt. This file contains the data in below format:

–Request

POST /tours/index.html HTTP/1.1^M

Host: 192.168.1.40^M

–Response

Response is not applicable, as this is generated by nsu_gen_cscript

 NoteThese files are generated only for HTTP.

URL Info List

URL Info List is a file that contains all URLs in it. In a script, each flow file contains a separate URL Info list file that is placed in Dump directory. URL Info List contains entries of all URLs (main and inline) in it.

Format of flow file

/*-----------------------------------------------------------------------------

Name: flow
Recorded By: netstorm
Date of recording: 12/10/2014 04:03:55
Flow details:
Build details: 4.0.1 (build# 12)
Modification History:
----------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ns_string.h"

void flow()
{
ns_web_url ("Page Name",
"URL=Page URL",
"HEADER= Header Info",
"PreSnapshot= webpage_xxxxxxxx.png ",
"Snapshot= webpage_xxxxxxxx.png",
INLINE_URLS,
"URL= inline URL path",
"HEADER=Header Info", END_INLINE,
"URL= inline URL path",
"HEADER=Header Info", END_INLINE,
);

ns_page_think_time(page think time);
}