Data Structures | Defines | Typedefs | Enumerations | Functions

InkAPITestTool.cc File Reference

Implements unit test for SDK APIs. More...

#include "Regression.h"
#include "api/ts/ts.h"
#include <arpa/inet.h>
#include "P_Net.h"
#include <records/I_RecHttp.h>
Include dependency graph for InkAPITestTool.cc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ServerTxn
struct  SocketServer
struct  ClientTxn

Defines

#define SDBG_TAG   "SockServer"
#define CDBG_TAG   "SockClient"
#define IP(a, b, c, d)   htonl((a) << 24 | (b) << 16 | (c) << 8 | (d))
#define SET_TEST_HANDLER(_d, _s)   {_d = _s;}
#define MAGIC_ALIVE   0xfeedbaba
#define MAGIC_DEAD   0xdeadbeef
#define SYNSERVER_LISTEN_PORT   3300
#define PROXY_CONFIG_NAME_HTTP_PORT   "proxy.config.http.server_port"
#define PROXY_HTTP_DEFAULT_PORT   8080
#define REQUEST_MAX_SIZE   4095
#define RESPONSE_MAX_SIZE   4095
#define HTTP_REQUEST_END   "\r\n\r\n"
#define X_REQUEST_ID   "X-Request-ID"
#define X_RESPONSE_ID   "X-Response-ID"
#define ERROR_BODY   "TESTING ERROR PAGE"
#define TRANSFORM_APPEND_STRING   "This is a transformed response"
#define HTTP_REQUEST_DEFAULT_FORMAT
#define HTTP_REQUEST_FORMAT1
#define HTTP_REQUEST_FORMAT2
#define HTTP_REQUEST_FORMAT3
#define HTTP_REQUEST_FORMAT4
#define HTTP_REQUEST_FORMAT5
#define HTTP_REQUEST_FORMAT6
#define HTTP_REQUEST_FORMAT7
#define HTTP_REQUEST_FORMAT8
#define HTTP_REQUEST_FORMAT9
#define HTTP_REQUEST_FORMAT10
#define HTTP_REQUEST_TESTCASE_FORMAT
#define HTTP_RESPONSE_DEFAULT_FORMAT
#define HTTP_RESPONSE_FORMAT1
#define HTTP_RESPONSE_FORMAT2
#define HTTP_RESPONSE_FORMAT4
#define HTTP_RESPONSE_FORMAT5
#define HTTP_RESPONSE_FORMAT6
#define HTTP_RESPONSE_FORMAT7
#define HTTP_RESPONSE_FORMAT8
#define HTTP_RESPONSE_FORMAT9
#define HTTP_RESPONSE_FORMAT10

Typedefs

typedef int(* TxnHandler )(TSCont contp, TSEvent event, void *data)

Enumerations

enum  RequestStatus { REQUEST_SUCCESS, REQUEST_INPROGRESS, REQUEST_FAILURE }

Functions

static char * get_body_ptr (const char *request)
static char * generate_request (int test_case)
static char * generate_response (const char *request)
static int get_request_id (TSHttpTxn txnp)
static ClientTxnsynclient_txn_create (void)
static int synclient_txn_delete (ClientTxn *txn)
static int synclient_txn_close (TSCont contp)
static int synclient_txn_send_request (ClientTxn *txn, char *request)
static int synclient_txn_send_request_to_vc (ClientTxn *txn, char *request, TSVConn vc)
static int synclient_txn_read_response (TSCont contp)
static int synclient_txn_read_response_handler (TSCont contp, TSEvent event, void *data)
static int synclient_txn_write_request (TSCont contp)
static int synclient_txn_write_request_handler (TSCont contp, TSEvent event, void *data)
static int synclient_txn_connect_handler (TSCont contp, TSEvent event, void *data)
static int synclient_txn_main_handler (TSCont contp, TSEvent event, void *data)
SocketServersynserver_create (int port)
static int synserver_start (SocketServer *s)
static int synserver_stop (SocketServer *s)
static int synserver_delete (SocketServer *s)
static int synserver_accept_handler (TSCont contp, TSEvent event, void *data)
static int synserver_txn_close (TSCont contp)
static int synserver_txn_write_response (TSCont contp)
static int synserver_txn_write_response_handler (TSCont contp, TSEvent event, void *data)
static int synserver_txn_read_request (TSCont contp)
static int synserver_txn_read_request_handler (TSCont contp, TSEvent event, void *data)
static int synserver_txn_main_handler (TSCont contp, TSEvent event, void *data)

Detailed Description

Implements unit test for SDK APIs.

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file InkAPITestTool.cc.


Define Documentation

#define CDBG_TAG   "SockClient"
#define ERROR_BODY   "TESTING ERROR PAGE"

Definition at line 55 of file InkAPITestTool.cc.

Referenced by ssn_handler().

#define HTTP_REQUEST_DEFAULT_FORMAT
Value:
"GET http://127.0.0.1:%d/default.html HTTP/1.0\r\n" \
                                     "X-Request-ID: %d\r\n" \
                                     "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_END   "\r\n\r\n"

Definition at line 49 of file InkAPITestTool.cc.

Referenced by synserver_txn_read_request().

#define HTTP_REQUEST_FORMAT1
Value:
"GET http://127.0.0.1:%d/format1.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT10
Value:
"GET http://trafficserver.apache.org/format10.html HTTP/1.0\r\n" \
                              "X-Request-ID: %d\r\n" \
                              "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT2
Value:
"GET http://127.0.0.1:%d/format2.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Content-Type: text/html\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT3
Value:
"GET http://127.0.0.1:%d/format3.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Response: Error\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT4
Value:
"GET http://127.0.0.1:%d/format4.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Request:%d\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT5
Value:
"GET http://127.0.0.1:%d/format5.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Request:%d\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT6
Value:
"GET http://127.0.0.1:%d/format.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Accept-Language: English\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT7
Value:
"GET http://127.0.0.1:%d/format.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Accept-Language: French\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT8
Value:
"GET http://127.0.0.1:%d/format.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "Accept-Language: English,French\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_FORMAT9
Value:
"GET http://trafficserver.apache.org/format9.html HTTP/1.0\r\n" \
                             "X-Request-ID: %d\r\n" \
                             "\r\n"

Referenced by generate_request().

#define HTTP_REQUEST_TESTCASE_FORMAT
Value:
"GET %1024s HTTP/1.%d\r\n" \
                                     "X-Request-ID: %d\r\n"

Referenced by generate_response().

#define HTTP_RESPONSE_DEFAULT_FORMAT
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "Content-Type: text/html\r\n" \
                              "\r\n" \
                              "Default body"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT1
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Content-Type: text/html\r\n" \
                              "Cache-Control: no-cache\r\n" \
                              "\r\n" \
                              "Body for response 1"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT10
Value:
"HTTP/1.0 200 OK\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "\r\n" \
                              "Body for response 10"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT2
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "Content-Type: text/html\r\n" \
                              "\r\n" \
                              "Body for response 2"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT4
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "Content-Type: text/html\r\n" \
                              "\r\n" \
                              "Body for response 4"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT5
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Content-Type: text/html\r\n" \
                              "\r\n" \
                              "Body for response 5"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT6
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "Content-Language: English\r\n" \
                              "\r\n" \
                              "Body for response 6"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT7
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "Content-Language: French\r\n" \
                              "\r\n" \
                              "Body for response 7"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT8
Value:
"HTTP/1.0 200 OK\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "Content-Language: French, English\r\n" \
                              "\r\n" \
                              "Body for response 8"

Referenced by generate_response().

#define HTTP_RESPONSE_FORMAT9
Value:
"HTTP/1.0 200 OK\r\n" \
                              "Cache-Control: max-age=86400\r\n" \
                              "X-Response-ID: %d\r\n" \
                              "\r\n" \
                              "Body for response 9"

Referenced by generate_response().

#define IP (   a,
  b,
  c,
  d 
)    htonl((a) << 24 | (b) << 16 | (c) << 8 | (d))

Definition at line 34 of file InkAPITestTool.cc.

Referenced by synclient_txn_create().

#define MAGIC_ALIVE   0xfeedbaba
#define MAGIC_DEAD   0xdeadbeef

Definition at line 39 of file InkAPITestTool.cc.

#define PROXY_CONFIG_NAME_HTTP_PORT   "proxy.config.http.server_port"

Definition at line 43 of file InkAPITestTool.cc.

#define PROXY_HTTP_DEFAULT_PORT   8080

Definition at line 44 of file InkAPITestTool.cc.

Referenced by synclient_txn_create().

#define REQUEST_MAX_SIZE   4095

Definition at line 46 of file InkAPITestTool.cc.

Referenced by generate_request(), and synserver_txn_read_request().

#define RESPONSE_MAX_SIZE   4095

Definition at line 47 of file InkAPITestTool.cc.

Referenced by generate_response(), and synclient_txn_read_response().

#define SDBG_TAG   "SockServer"
#define SET_TEST_HANDLER (   _d,
  _s 
)    {_d = _s;}
#define SYNSERVER_LISTEN_PORT   3300
#define TRANSFORM_APPEND_STRING   "This is a transformed response"

Definition at line 56 of file InkAPITestTool.cc.

Referenced by SDK_API_HttpTxnTransform(), and transform_hook_handler().

#define X_REQUEST_ID   "X-Request-ID"

Definition at line 52 of file InkAPITestTool.cc.

Referenced by get_request_id().

#define X_RESPONSE_ID   "X-Response-ID"

Definition at line 53 of file InkAPITestTool.cc.


Typedef Documentation

typedef int(* TxnHandler)(TSCont contp, TSEvent event, void *data)

Definition at line 62 of file InkAPITestTool.cc.


Enumeration Type Documentation

Enumerator:
REQUEST_SUCCESS 
REQUEST_INPROGRESS 
REQUEST_FAILURE 

Definition at line 93 of file InkAPITestTool.cc.


Function Documentation

static char * generate_request ( int  test_case  )  [static]
static char * generate_response ( const char *  request  )  [static]
static char * get_body_ptr ( const char *  request  )  [static]

Definition at line 172 of file InkAPITestTool.cc.

Referenced by cont_test_handler().

static int get_request_id ( TSHttpTxn  txnp  )  [static]
static int synclient_txn_close ( TSCont  contp  )  [static]
static int synclient_txn_connect_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
static ClientTxn * synclient_txn_create ( void   )  [static]
static int synclient_txn_delete ( ClientTxn txn  )  [static]
static int synclient_txn_main_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
static int synclient_txn_read_response ( TSCont  contp  )  [static]
static int synclient_txn_read_response_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
static int synclient_txn_send_request ( ClientTxn txn,
char *  request 
) [static]
static int synclient_txn_send_request_to_vc ( ClientTxn txn,
char *  request,
TSVConn  vc 
) [static]
static int synclient_txn_write_request ( TSCont  contp  )  [static]
static int synclient_txn_write_request_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
static int synserver_accept_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
SocketServer * synserver_create ( int  port  ) 
static int synserver_delete ( SocketServer s  )  [static]
static int synserver_start ( SocketServer s  )  [static]
static int synserver_stop ( SocketServer s  )  [static]
static int synserver_txn_close ( TSCont  contp  )  [static]
static int synserver_txn_main_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
static int synserver_txn_read_request ( TSCont  contp  )  [static]
static int synserver_txn_read_request_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]
static int synserver_txn_write_response ( TSCont  contp  )  [static]
static int synserver_txn_write_response_handler ( TSCont  contp,
TSEvent  event,
void *  data 
) [static]