void call_to_set_cookie_val_ex() { char *cookie = %COOKIE_NAME ; printf("\nNS_SET_COOKIE_VAL_EX API called"); ns_set_cookie_val_ex(cookie,NULL,NULL,%COOKIE_VAL); ns_save_string(ns_get_cookie_val_ex(cookie,NULL,NULL),"NS_DP"); printf("Value saved = %s\n",ns_eval_string("{NS_DP}")); }
void Url_Res() { int size = 1; ns_save_data_ex(ns_eval_string("{random}"), NS_TRUNC_FILE, "%s", ns_url_get_resp_msg(&size)); }
void call_to_all_get_api() { int nvmid = ns_get_nvmid(); int userid = ns_get_userid(); int sessid = ns_get_sessid(); int testid = ns_get_testid(); int thinktime = ns_get_pg_think_time(); int randomnum = ns_get_random_number_int(1,99); long uniqnum = ns_get_unique_number(); int ka_time = ns_get_ka_time(); int page_status = ns_get_page_status() ; int tx_status = ns_get_tx_status("API_T01") ; int sess_status = ns_get_session_status() ; int num_nvm = ns_get_num_nvm(); int num_ka_pct = ns_get_num_ka_pct(); int min_ka = ns_get_min_ka(); int max_ka = ns_get_max_ka(); char *guid = ns_get_guid(); char buffer[512] ; fprintf(stdout,"[info] nvmid = [%d], userid = [%d], sessid = [%d], testid = [%d]\n",nvmid, userid, sessid, testid); fprintf(stdout,"[info] thinktime = [%d], randomnum = [%d], uniqnum = [%ld], ka_time = [%d]\n",thinktime,randomnum,uniqnum,ka_time); fprintf(stdout,"[info] num_nvm = [%d], page_status = [%d], tx_status = [%d], sess_status = [%d]\n",num_nvm,page_status,tx_status,sess_status); fprintf(stdout,"[info] num_ka_pct = [%d], min_ka = [%d], max_ka = [%d], guid = [%s]\n",num_ka_pct,min_ka,max_ka,guid); sprintf(buffer,"nvmid = [%d], userid = [%u], sessid = [%u], testid = [%d]",nvmid, userid, sessid, testid); ns_save_string(buffer,"NS_DP"); fprintf(stdout,"[debug] %s\n",ns_eval_string("{NS_DP}")); sprintf(buffer,"thinktime = [%d], randomnum = [%d], uniqnum = [%ld], ka_time = [%d]",thinktime,randomnum,uniqnum,ka_time); ns_save_string(buffer,"NS_DP"); fprintf(stdout,"[debug] %s\n",ns_eval_string("{NS_DP}")); sprintf(buffer,"num_nvm = [%d], page_status = [%d], tx_status = [%d], sess_status = [%d]",num_nvm,page_status,tx_status,sess_status); ns_save_string(buffer,"NS_DP"); fprintf(stdout,"[debug] %s\n",ns_eval_string("{NS_DP}")); sprintf(buffer,"num_ka_pct = [%d], min_ka = [%d], max_ka = [%d], guid = [%s]",num_ka_pct,min_ka,max_ka,guid); ns_save_string(buffer,"NS_DP"); fprintf(stdout,"[debug] %s\n",ns_eval_string("{NS_DP}")); }
//Will take the KisokId from NS static void set_kiosk_id_for_debug() { if(KioskDebug == 0) { KioskDebug = 1; strcpy(KioskIdForDebug, ns_eval_string("{KioskIdVar}")); #ifdef NS_DEBUG_ON fprintf(stderr, "%s - Info: KioskId for debug = %s\n", tsToStr(-1), KioskIdForDebug); #endif } }
void call_to_eval_string_api() { char *eval_string ; fprintf(stdout,"\nNS_EVAL_STRING API Called"); ns_save_string("EVALUATED TEST STRING","NS_DP_EVAL"); eval_string = ns_eval_string("{NS_DP_EVAL}"); fprintf(stdout,"\nNS_DECL_VAR String=%s",eval_string); if ( eval_string == NULL ) fprintf(stderr,"\nSTATUS=FAIL\n"); else fprintf(stdout,"\nSTATUS=PASS\n"); }
void call_to_advance_param_api(int type) { int status ; fprintf(stdout,"\nNS_ADVANCE_PARAM API Called"); if ( type == 0 ) { status = ns_advance_param("F1"); status = ns_advance_param("F1"); fprintf(stdout,"\nValue Read=%s, status=%d",ns_eval_string("{F1}"),status); } if ( type == 1 ) { status= ns_advance_param("F2"); char *tmp = ns_eval_string("{F2}"); status = ns_advance_param("F3"); char *tmp2 = ns_eval_string("{F2}"); status = ns_advance_param("F3"); fprintf(stdout,"\nValue Read=%s, status=%d",ns_eval_string("{F2}"),status); } if ( status !=0 ) fprintf(stderr,"\nSTATUS=FAIL\n"); else fprintf(stdout,"\nSTATUS=PASS\n"); }
void db_select_flow() { char buf[2048]; void *stmt = NULL; char tablename[30], qstr[256]; sprintf(tablename, "products_%d", atoi(ns_eval_string("{uniq_num}"))); // Initialize db environement and variables if(0>ns_db_odbc_init()) return; ns_page_think_time(1); ns_start_transaction("Connect_db_for_select"); // Connect to database with DSN PostgresSQL, username netstorm and password test123 if(0>ns_db_connect("DSN=PostgreSQL; Username=netstorm; Datbase=test")) return; ns_end_transaction("Connect_db_for_select", NS_AUTO_STATUS); ns_page_think_time(2); // Allocate statement handle. if(0>ns_db_alloc_stmt_handle(&stmt)) return; ns_start_transaction("Run_select"); sprintf(qstr, "select * from %s;", tablename); // Executing select query if(0>ns_db_execute(stmt, qstr)) return; ns_end_transaction("Run_select", NS_AUTO_STATUS); ns_page_think_time(2); if(0>ns_db_get_value(stmt, buf, 2048)) return; ns_page_think_time(2); printf("\n======\nBuffer = %s\n======\n", buf); ns_save_data_var("/tmp/db_result.txt", 1, buf); ns_db_free_stmt(stmt); ns_db_odbc_close(); }
void db_update_flow() { void *stmt = NULL; char tablename[30], qstr[256]; sprintf(tablename, "products_%d", atoi(ns_eval_string("{uniq_num}"))); // Initialize db environement and variables if(0>ns_db_odbc_init()) return; ns_page_think_time(1); if(0>ns_start_transaction("Connect_db_for_update")) return; // Connect to database with DSN PostgresSQL, username netstorm and password test123 if(0>ns_db_connect("DSN=PostgreSQL; Username=netstorm; Datbase=test")) return; ns_end_transaction("Connect_db_for_update", NS_AUTO_STATUS); ns_page_think_time(2); // Allocate statement handle. if(0>ns_db_alloc_stmt_handle(&stmt)) return; ns_start_transaction("Run_update"); // Executing select query sprintf(qstr, "update %s set quantity = 4 where name = 'bedsheet';", tablename); if(0>ns_db_execute(stmt, qstr)) return; ns_end_transaction("Run_update", NS_AUTO_STATUS); ns_page_think_time(2); ns_db_free_stmt(stmt); ns_db_odbc_close(); }
// will check the KioskId should not be null static int isKioskSetForDebug() { if(strcmp(KioskIdForDebug, ns_eval_string("{KioskIdVar}")) == 0) return 1; return 0; }
//Gets the next page id and page think time static int getNextPageAndThinkTime(char *curPageName, int curPageId, double *pg_think_time_out) { int nextPageId; unsigned int pg_think_time; int curServiceId = ns_get_int_val("ServiceIdVar"); unsigned long curTS = ns_get_ms_stamp(); set_kiosk_id_for_debug(); // This will set KioskId once for debug log strcpy(KioskId, ns_eval_string("{KioskIdVar}")); setTimeLeft(RB_KIOSK_PING_ID, curTS, getLastPingTS(), KioskPing, -1); setTimeLeft(RB_RENT_SERVICE_ID, curTS, getLastRentalTS(), RentService, ReconcileService); setTimeLeft(RB_RETURN_SERVICE_ID, curTS, getLastReturnTS(), ReturnService, -1); setTimeLeft(RB_FAILURE_RENT_SERVICE_ID, curTS, getLastFailureRentalTS(), AuthorizeFailure, ReconcileFailure); setTimeLeft(RB_OFFLINE_RENT_SERVICE_ID, curTS, getLastOfflineRentalTS(), ReconcileService, -1); #ifdef RB_ENABLE_NEW_SVC setTimeLeft(RB_UNPLAYABLE_ID, curTS, getLastUnplayableTS(), UnplayableReturnService, ReturnService2); setTimeLeft(RB_KIOSK_ANALYTICS_ID, curTS, getLastKioskAnalyticsTS(), KioskAnalytics, -1); setTimeLeft(RB_DISCOUNT_VALIDATION_ID, curTS, getLastDiscountValidationTS(), DiscountValidationService, RentService); setTimeLeft(RB_GETCUST_CREDIT_ID, curTS, getLastGetCustCreditTS(), GetCustCredit, RentService); setTimeLeft(RB_RENT_OPTIN_ID, curTS, getLastOptInRentalTS(), RentService, KioskOptInService); setTimeLeft(RB_DISC_ACTION_ID, curTS, getLastDiscActionTS(), DiscActionService, -1); setTimeLeft(RB_EMAIL_CONFIRM_ID, curTS, getLastEmailConfirmTS(), EmailConfirmation, -1); setTimeLeft(RB_PICK_UP_ID, curTS, getLastPickUpValidationTS(), PickUpValidation, PickUp); setTimeLeft(RB_GIFTCARD_ID, curTS, getLastGCRentalTS(), RentService, ReconcileService); setTimeLeft(RB_GC_PICKUP_ID, curTS, getLastGCPickUpValidationTS(), PickUpValidation, PickUp); #endif int curPageStatus = ns_get_page_status(); // 0 - Success else fail if(curPageStatus != 0) { #ifdef NS_DEBUG_ON fprintf(stderr, "%s - Warning: %s page failed. KioskId = %s\n", tsToStr(curTS),curPageName, KioskId); #endif curPageId = -1; // Set to -1 so avoid going to Reconcile after ping } // TODO: Can we elimiate this? if((curPageId == GetCustCredit) && (curPageStatus == 0)) { nextPageId = RentService; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForRent(), &nextPageId, "GetCustCredit"); } else if((curPageId == DiscountValidationService) && (curPageStatus == 0)) { nextPageId = RentService; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForRent(), &nextPageId, "DiscountValidationService"); } // if current page is RentService, next page can be Reconcile or OptIn else if((curPageId == RentService) && (curPageStatus == 0) && (curServiceId == RB_RENT_OPTIN_ID)) { nextPageId = KioskOptInService; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForOptIn(), &nextPageId, "RentService"); } else if((curPageId == RentService) && (curPageStatus == 0) && (curServiceId != RB_RENT_OPTIN_ID)) { nextPageId = ReconcileService; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForReconcile(), &nextPageId, "RentService"); } else if((curPageId == KioskOptInService) && (curPageStatus == 0) && (curServiceId == RB_RENT_OPTIN_ID)) { nextPageId = ReconcileService; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForReconcile(), &nextPageId, "KioskOptInService"); } // If current page is UnplayableReturnService then next can either be ReturnService2 or Ping else if ((curPageId == AuthorizeFailure) && (curPageStatus == 0)) { nextPageId = ReconcileFailure; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForReconcile(), &nextPageId, "AuthorizeFailure"); } else if ((curPageId == UnplayableReturnService) && (curPageStatus == 0)) { nextPageId = ReturnService2; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForReturnService2(), &nextPageId, "UnplayableReturnService"); } else if ((curPageId == PickUpValidation) && (curPageStatus == 0)) { nextPageId = PickUp; pg_think_time = getTTForNextPgOfAService(curTS, getThinkTimeForPickUp(), &nextPageId, "PickUpValidation"); } else if(curPageId == KioskPing) // Check if due to ping, we did not do ReconcileService last time { if((getPageIdBeforePing() == GetCustCredit) && (getServiceIdBeforePing() == RB_GETCUST_CREDIT_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = RentService; } else if((getPageIdBeforePing() == DiscountValidationService) && (getServiceIdBeforePing() == RB_DISCOUNT_VALIDATION_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = RentService; } else if((getPageIdBeforePing() == RentService) && (getServiceIdBeforePing() != RB_RENT_OPTIN_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = ReconcileService; } else if((getPageIdBeforePing() == RentService) && (getServiceIdBeforePing() == RB_RENT_OPTIN_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = KioskOptInService; } else if((getPageIdBeforePing() == KioskOptInService) && (getServiceIdBeforePing() == RB_RENT_OPTIN_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = ReconcileService; } else if((getPageIdBeforePing() == UnplayableReturnService) && (getServiceIdBeforePing() == RB_UNPLAYABLE_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = ReturnService2; } else if((getPageIdBeforePing() == AuthorizeFailure) && (getServiceIdBeforePing() == RB_FAILURE_RENT_SERVICE_ID)) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = ReconcileFailure; } else if((getPageIdBeforePing() == PickUpValidation) && ((getServiceIdBeforePing() == RB_PICK_UP_ID) || (getServiceIdBeforePing() == RB_GC_PICKUP_ID))) { pg_think_time = ns_get_int_val("PgThinkTimeVar"); nextPageId = PickUp; } else pg_think_time = selectService(curTS, &nextPageId); } else { pg_think_time = selectService(curTS, &nextPageId); } if(nextPageId == KioskPing) { setPageIdBeforePing(curPageId); setServiceIdBeforePing(curServiceId); } // ns_set_pg_think_time(pg_think_time); *pg_think_time_out = (double )pg_think_time/1000.0; // page think time in C Type is passed in seconds #ifdef NS_DEBUG_ON if(isKioskSetForDebug()) fprintf(stderr, "%s - Info: getNextPageAndThinkTime() - KioskId = %s , pg_think_time = %u, nextPageId = %d\n", tsToStr(curTS), KioskId, pg_think_time, nextPageId); #endif return(nextPageId); }
int check_page_welcome(void) { ns_log_msg(NS_LOG_STD, "################### The ramdom number is = %s", ns_eval_string("{abc}")); return -1; }
void flow1() { ns_start_transaction("hpd_ex_login"); ns_web_url("index_html", "METHOD=GET", "URL=http://127.0.0.1/tours/index.html", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", INLINE_URLS, "URL=http://127.0.0.1/tours/Merc10-dev/images/banner_animated.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/Merc10-dev/images/sun_swede.gif", "COOKIE =test;", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/Merc10-dev/images/login.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/images/banner_merctur.jpg", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE ); ns_page_think_time(0.0); ns_web_url("login", "METHOD=GET", "URL=http://127.0.0.1/cgi-bin/login?userSession=75893.0884568651DQADHfApHDHfcDtccpfAttcf&username={Username}&password={Password}&login.x=51&login.y=16&login=Login&JSFormSubmit=off", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", INLINE_URLS, "URL=http://127.0.0.1/tours/Merc10-dev/images/flights.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/Merc10-dev/images/home.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/Merc10-dev/images/signoff.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/vep/images/velocigen.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE ); ns_end_transaction("hpd_ex_login",0); ns_page_think_time(0.0); ns_start_transaction("hpd_ex_findflight"); ns_web_url("reservation", "METHOD=GET", "URL=http://127.0.0.1/cgi-bin/{Pagename}", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", INLINE_URLS, "URL=http://127.0.0.1/tours/Merc10-dev/images/splash_Findflight.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/images/continue.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE ); ns_end_transaction("hpd_ex_findflight",0); ns_page_think_time(0.0); ns_web_url("findflight", "METHOD=GET", "URL=http://127.0.0.1/cgi-bin/findflight?depart={DepCity}&departDate={DepDate}&arrive={ArrCity}&returnDate={RetDate}&numPassengers={NumPass}&seatPref={SeatPref}&seatType={SeatType}&findFlights.x=72&findFlights.y=14&findFlights=Submit", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", INLINE_URLS, "URL=http://127.0.0.1/tours/images/splash_Searchresults.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/images/startover.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE ); ns_page_think_time(0.0); ns_start_transaction("hpd_ex_reservation"); ns_web_url("findflight_2", "METHOD=GET", "URL=http://127.0.0.1/cgi-bin/findflight?outboundFlight=button0&hidden_outboundFlight_button0=260%7C438%7C12-06-2005&hidden_outboundFlight_button1=261%7C399%7C12-06-2005&hidden_outboundFlight_button2=262%7C418%7C12-06-2005&hidden_outboundFlight_button3=263%7C359%7C12-06-2005&numPassengers={NumPass}&advanceDiscount=&seatType={SeatType}&seatPref=None&reserveFlights.x=95&reserveFlights.y=13", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", INLINE_URLS, "URL=http://127.0.0.1/tours/images/splash_creditcard.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/images/purchaseflight.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE ); char tmp_buf[2048]; p=atoi(ns_eval_string("{NumPass}")); int i; char f[]="firstname"; char l[]="lastname"; tmp_buf[0]=0; buffer[0]=0; for (i = 1; i < p+1; i++) { strcat(buffer, tmp_buf); } ns_save_string(buffer,"buffer"); ns_page_think_time(0.0); ns_web_url("findflight_3", "METHOD=GET", "URL=http://127.0.0.1/cgi-bin/findflight?firstName=Tiger&lastName=Scott&address1=4261+Stevenson+Blvd.&address2=Fremont%2C+CA+94538&{buffer}creditCard=1234&expDate=0109&oldCCOption=&numPassengers={NumPass}&seatType={SeatType}&seatPref={SeatPref}&outboundFlight=260%7C438%7C12-06-2005&advanceDiscount=&buyFlights.x=88&buyFlights.y=11&.cgifields=saveCC", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", INLINE_URLS, "URL=http://127.0.0.1/tours/images/splash_flightconfirm.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE, "URL=http://127.0.0.1/tours/images/bookanother.gif", "HEADER=Accept-Language: en-us, en;q=0.50", "HEADER=Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66", END_INLINE ); ns_end_transaction("hpd_ex_reservation",0); ns_page_think_time(0.0); ns_start_transaction("hpd_ex_logout"); ns_web_url("welcome", "METHOD=GET", "URL=http://127.0.0.1/cgi-bin/welcome", "HEADER=Accept-Language: en-us,en;q=0.5", "HEADER=Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", ); ns_end_transaction("hpd_ex_logout",0); ns_page_think_time(0.0); }