コード例 #1
0
ファイル: vuser_init.c プロジェクト: Rosuav/LoadRunner
int vi_set_Verbosity_attribute(){

	   LPCSTR_Verbosity = lr_get_attrib_string("Verbosity"); // from Run-time settings Attributes or command line.
	if(LPCSTR_Verbosity==NULL){                 // Not specified in Run-Time Settings Attributes or command line.
            iVerbosity=iVerbosity_default; // =default.
		    wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"Verbosity\" not specified in command-line or run-time settings. Default to \"%d\"."
					,iVerbosity
					);
			wi_stopPrinting();
		// NOTE: Don't return LR_FAIL; // fail here because default can be used.
	}else{
		iVerbosity=atoi(LPCSTR_Verbosity);
	} // if(LPCSTR_Verbosity==NULL)

	// TODO: 23. Set each web_set_max_html_param_len based on the largest individual server response detrermined from initial runs.	   
	if( iVerbosity == 1 ){
	    web_set_max_html_param_len("10240"); 
	}else
	if( iVerbosity == 2 ){
	    web_set_max_html_param_len("10240");
	}else
	if( iVerbosity == 3 ){
	    web_set_max_html_param_len("10240");
	}else
	if( iVerbosity == 4 ){
	    web_set_max_html_param_len("10240");
	}else
	if( iVerbosity == 5 ){
	    web_set_max_html_param_len("20240");
	}else{
	   	iVerbosity=iVerbosity_default; // =default.
		    wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"Verbosity\" not specified in command-line or run-time settings. Default to \"%d\"."
					,iVerbosity
					);
			wi_stopPrinting();

			wi_startPrintingError();
		    lr_output_message(">> Attribute \"Verbosity\" not recognized as valid value."
					,iVerbosity
					);
			wi_stopPrinting();
	}
	return LR_PASS;
} // vi_set_Verbosity_attribute()
コード例 #2
0
ファイル: vuser_init.c プロジェクト: Rosuav/LoadRunner
int wi_end_transaction(){
	int rc=LR_PASS;
	
	/* Defined as globals at top of vuser_init():
	int 			  intHttpRetCode;
	int 			  intHttpMilliseconds;
	float 			floatHttpMilliseconds;
	int 			  intHttpSize;
	float 			floatHttpKBytes;
	*/

	// Using pTransName saved in wi_start_transaction before the transaction:
    lr_end_transaction(lr_eval_string("{pTransName}"),LR_AUTO);

    // Verify bad 400 HTTP return code from server and associated response such as "{error : invalid_grant}"
    // using LoadRunner internal function web_get_int_property():
	    intHttpRetCode 		= web_get_int_property(HTTP_INFO_RETURN_CODE);
  	    intHttpSize 		= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
	    intHttpMilliseconds = web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
	  floatHttpMilliseconds = (float)intHttpMilliseconds / 1000; // Convert from milliseconds to seconds.

	if (intHttpRetCode == 200 // no problem! OK
	||  intHttpRetCode == 304 // Already cached.
	){
		// move on.
	}else{
		wi_startPrintingError();
    	lr_error_message(">> HTML Return Code=%d, pJSONResponse=%s." 
		                 , intHttpRetCode
		                 , lr_eval_string("{pJSONResponse}") 
		                 );
		wi_stopPrinting();
		rc=LR_FAIL;
	}

    return rc;
} // wi_end_transaction
コード例 #3
0
ファイル: vuser_init.c プロジェクト: Rosuav/LoadRunner
vi_set_RunType_attribute(){

	LPCSTR_RunType = lr_get_attrib_string("RunType"); // from run-time settings Attributes or command line.
 	if(LPCSTR_RunType==NULL){ // Not specified in Run-Time Settings Attributes or command line.
	   LPCSTR_RunType="All"; // =default.
			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"RunType\" not specified in command-line or run-time settings. Default to \"%s\"."
					,LPCSTR_RunType 
					);
			wi_stopPrinting();
	}else{ // Ensure only acceptable values were input:
		if( stricmp("All",LPCSTR_RunType ) == FOUND ){ // Run-time Attribute "RunType" or command line option "-RunType"
			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"RunType\"=%s."
					,LPCSTR_RunType 
					);
			wi_stopPrinting();
       	}else
		if( stricmp("NoOp",LPCSTR_RunType ) == FOUND ){ // Run-time Attribute "RunType" or command line option "-RunType"
			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"RunType\"=%s for no operation."
					,LPCSTR_RunType 
					);
			wi_stopPrinting();
		}else{
			wi_startPrintingError();
		    lr_output_message(">> Attribute \"RunType\"=%s not valid. lr_exit() stopping script execution."
					,LPCSTR_RunType 
					);
			wi_stopPrinting();
			lr_exit(LR_EXIT_VUSER,LR_FAIL);
		}
	} // if(LPCSTR_RunType==NULL)

	return LR_PASS;
} // vi_set_RunType_attribute()
コード例 #4
0
ファイル: goggle_apis.c プロジェクト: Rosuav/LoadRunner
get_google_short_url_qrcode(){
	int rc=0;
		char            strFileName[256]; // largest size of file.
		char           *szBuf;
		unsigned long   nLength;

	if( stricmp("Y",LPCSTR_SaveImageYN ) == FOUND ){ // Run-time Attribute "SaveImageYN" or command line option "-SaveImageYN"
	   // continue if SaveImageYN was specified with Y
	}else{
		return LR_PASS;
	}

		set_pShortHostKey_from_url( lr_eval_string("{pShortURL}") ); // from get_google_short_url()
			//wi_startPrintingTrace();
			//lr_output_message(">> pShortHostKey=\"%s\"." ,lr_eval_string("{pShortHostKey}") );
			//wi_stopPrinting();

		// For shortened URL http://goo.gl/AC4IW", details are at http://goo.gl/#analytics/goo.gl/AC4IW/all_time
		// {pShortHostKey}=AC4IW in example: URL http://goo.gl/AC4IW.qr redirects to 
		// The QR code impage at http://chart.googleapis.com/chart?cht=qr&chs=100x100&choe=UTF-8&chld=H|0&chl=http://goo.gl/AC4IW
		web_reg_save_param_ex("ParamName=pImage", "LB=\r\n\r\n", "RB=\"",  "Notfound=warning", LAST); // The \r\n\r\n is to begin capture after the two blank lines between HTTP header and body.
		web_reg_save_param_ex("ParamName=pImage_len", "LB=Content-Length: ", "Notfound=warning", "RB=\r\n", LAST);

		sprintf(       tempString1, "%s_3image", lr_eval_string("{pTransSequence}") );
		lr_save_string(tempString1,"pTransName");
	    wi_start_transaction();
	    
    // This URL was obtained from the DNS-level redirect in the HTML header in response to request for .qr, such as:
    // The document has moved <A 
    //        HREF="http://chart.googleapis.com/chart?cht=qr&amp;chs=150x150&amp;choe=UTF-8&amp;chld=H&amp;chl=http://goo.gl/x6wUIS">here</A>.\n
    	// &amp; needs to be coverted to & character in URLs.
    	
		// WARNING: The 150x150 in this URL may change over time as more characters are needed for uniqueness.
		// Previously,  100x100 was being returned:
		//    "URL={pShortURL}.qr",
		web_url("imagefile",
	        "URL=http://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl={pShortURL}",
	        "Resource=1",
	        "RecContentType=image/png",
	        "Snapshot=t1.inf",
	        LAST);
		// FIXME: File created has black box at bottom.
	
	    rc = wi_end_transaction();

		// strFileName=wi_define_FileName():
		lr_save_datetime("%Y%m%d%H%M%S", DATE_NOW, "pYMDHMS"); // YYMMDDHHMMSS (12 char), no micro seconds
		sprintf(strFileName, "%s%s_%d_T%s_%s_%s.png"
		        ,lr_eval_string("{pImageFilePath}")
				,global_unique_id
				,iActionIterations
				,lr_eval_string("{pYMDHMS}")
		        ,lr_eval_string("{pShortHostKey}")
		        ,lr_eval_string("{pImage_len}")
		       );

		lr_eval_string_ext("{pImage}", strlen("{pImage}"), &szBuf, &nLength, 0, 0, -1);
		// lr_eval_string_ext( in_str, in_len,    pointer out_str, out_len, Reserved for future use. 
		if( nLength <= 0 ){
			lr_error_message(">> No image returned for %s.",strFileName);
		}else{
			if( wi_WriteDataToFile(strFileName, szBuf, nLength) == LR_PASS ){
				wi_startPrintingInfo();
				lr_output_message(">> QRcode_image file created at \"%s\".",strFileName);
				wi_stopPrinting();
			   	// TODO: 23. Remember after runs to clear out the files to an archive filer.
			}else{
				wi_startPrintingError();
				lr_error_message(">>> QRcode_image file NOT created at \"%s\".",strFileName);
				wi_stopPrinting();
			}
		}
	return rc;
} // retrieve_pShortURL_qrcode()
コード例 #5
0
ファイル: goggle_apis.c プロジェクト: Rosuav/LoadRunner
get_long_url_to_shorten(){
	int rc=LR_PASS;
	int i=0;
	
	if( iURLSource_setting == 1 && nURLtoShorten_file_recs > 0 ){
		for( nURLtoShorten_index=1; nURLtoShorten_index < nURLtoShorten_file_recs +1; nURLtoShorten_index++ ){
			// Loop to skip data records marked No for usage.
			// Referencing data in file URLtoShorten.dat:
			if( stricmp( "N", lr_eval_string("{pURL_use}") ) == FOUND ){
				lr_advance_param("pURL_long"); // Increment file one record.
			} // else fall through to use it.
		}
		lr_save_string(lr_eval_string("{pURL_use}"),"pURLtoShorten");

	#ifdef USE_VTS
	}else
	if( iURLSource_setting == 2 ){ // (use VTS)

		// ENHANCEMENT: The alternative to this loop is to use an increment.

		// Scan through the VTS table from top to bottom.
		// If short_url is not blank in VTS table, it's alreadry processed, so skip to next row:
		for( i=1; i <= nVTS_row_count; i++ ){
			rc = vtc_query_column(pvci, "web", i, &outvalue); // retrieve single field from a designated row.
			if( outvalue == NULL || sizeof( outvalue ) <= 0 ){ // there is no longURL, so skip that row;
				wi_startPrintingTrace();
				lr_output_message(">> row %d \"web\" value is blank. Skipping to next row. rc=%d.", i, rc);
				wi_stopPrinting();
			}else{
				rc = vtc_query_column(pvci, "shorturl", i, &shorturl); // retrieve single field from a designated row.
				// FIXME: Why is rc=10111 ?
				if( shorturl == NULL || sizeof( shorturl ) <= 0 ){ // a blank cell, so it needs a shorturl.
					lr_save_string(outvalue,"pURLtoShorten");
					wi_startPrintingTrace();
					lr_output_message(">> row %d \"shorturl\" is needed for \"web\"=%s. rc=%d.", i, lr_eval_string("{pURLtoShorten}"), rc);
					wi_stopPrinting();
					vtc_free(outvalue);
					rc=0; // FIXME: Why need to override rc=10111 again?
					break; // break out of loop for this script to get a shorturl for the web URL in VTS.
				}else{ 
					// there is a shortURL already, so cycle back up to top for another
					// unless this is the last row in the table:
					if( i == nVTS_row_count ){
						wi_startPrintingTrace();
						lr_output_message(">> Last row at %d has a shorturl of \"%s\". So no more to process.", i, shorturl);
						wi_stopPrinting();
						vtc_free(shorturl);
						rc = LR_FAIL;
					}
				}
	   		}
		} // for loop

	#endif // USE_VTS

	// ENHANCEMENT: else option to retrieve from on-line Google spreadsheet, etc.

	}else{
		wi_startPrintingError();
       	lr_output_message(">> iURLSource_setting=%s is invalid.", iURLSource_setting);
		wi_stopPrinting();
		rc=LR_FAIL; // This would be a programming error since editing occurred before this.
	} // if( iURLSource_setting 
	
	return rc;
} // get_long_url_to_shorten()
コード例 #6
0
ファイル: vuser_init.c プロジェクト: Rosuav/LoadRunner
vi_set_URLSource_attribute(){

	int rc=LR_PASS;
	
	   LPCSTR_URLSource = lr_get_attrib_string("URLSource"); // from run-time settings Attributes or command line "-URLSource".
 	if(LPCSTR_URLSource==NULL){ // Not specified in Run-Time Settings Attributes or command line.
		     iURLSource_setting=iURLSource_default;

			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"URLSource\" not specified in command-line or run-time settings. Default to \"%d\".", iURLSource_setting );
			wi_stopPrinting();
	}else{ // Ensure only acceptable values were input:
		if( stricmp("All",iURLSource_setting ) == FOUND ){ // Run-time Attribute "URLSource" or command line option "-URLSource"
			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"URLSource\"=%s."
					,iURLSource_setting
					);
			wi_stopPrinting();
       	}else
		if( iURLSource_setting == 1 ){
			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"URLSource\"=%s for using file URLtoShorten.dat in script folder." ,iURLSource_setting );
			wi_stopPrinting();

		#ifdef USE_VTS
       	}else
		if( iURLSource_setting == 2 ){
			wi_startPrintingInfo();
		    lr_output_message(">> Attribute \"URLSource\"=%s for using VTS." ,iURLSource_setting);
			wi_stopPrinting();
		#endif // USE_VTS
		
		}else{
			wi_startPrintingError();
		    lr_output_message(">> Attribute \"URLSource\"=%s not valid. lr_exit() stopping script execution." ,iURLSource_setting );
			wi_stopPrinting();
			lr_exit(LR_EXIT_VUSER,LR_FAIL);
		}
	} // if(iURLSource_setting==NULL)

	// Regardless of iURLSource_setting selection,
	// define number of records in file (for all iURLSource_setting options because this is the fall-back):
	    nURLtoShorten_file_recs = vi_set_pURLtoShorten_file_recs();
	if( nURLtoShorten_file_recs == -1 ){
		lr_error_message("> vi_set_pURLtoShorten_file_recs() nURLtoShorten_file_recs=%d",nURLtoShorten_file_recs);
	}else{
	  	wi_startPrintingInfo();
		lr_output_message(">> nURLtoShorten_file_recs=%d.", nURLtoShorten_file_recs);
		wi_stopPrinting();
	}

	#ifdef USE_VTS
    if( iURLSource_setting == 2 ){
	    rc=vi_set_VTS3(); // Find the count of records in VTS table into nVTS_row_count.
		if( rc != LR_PASS ){
	    	// TODO: 12. If you prefer, if VTS cannot be used, change coding to error out instead of falling back if records were found earlier:
	    	if( nURLtoShorten_file_recs > 0 ){ // if records were found earlier?
				iURLSource_setting = 1; // use local data source
				
				wi_startPrintingInfo();
				lr_output_message(">> rc=%d fall-back to local data source with nURLtoShorten_file_recs=%f when iURLSource_setting=%d.", rc, nURLtoShorten_file_recs, iURLSource_setting);
				wi_stopPrinting();
			}
	    }else{
			// Add column "shorturl" to VTS for holding output from Google API calls:
			rc = vtc_create_column (pvci, "shorturl", &status); // status=1 is success.
				wi_startPrintingDebug();
				lr_output_message(">> rc=%d from vi_set_VTS3() with status=%d (should=1) when iURLSource_setting=%d.", rc, status, iURLSource_setting);
				wi_stopPrinting();
			if( status == 1 ){
				iUpdate_shorturl_in_VTS = 1; // 1=Yes

				wi_startPrintingInfo();
				lr_output_message(">> rc=%d with status=%d (should=1), so iUpdate_shorturl_in_VTS =%d (1=1Yes).", rc, status, iUpdate_shorturl_in_VTS );
				wi_stopPrinting();
			}else{
				iUpdate_shorturl_in_VTS = 0; // 0=No

				wi_startPrintingInfo();
				lr_output_message(">> rc=%d with status=%d (should=1), so iUpdate_shorturl_in_VTS =%d (0=NO).", rc, status, iUpdate_shorturl_in_VTS );
				wi_stopPrinting();
			}
	    }
    }
	#endif // USE_VTS

	return LR_PASS;
} // vi_set_URLSource_attribute()
コード例 #7
0
ファイル: wi_functions.c プロジェクト: bhimjis/LoadRunner
int wi_end_transaction(int in_rc){
	int rc=LR_PASS;
	int 			  intHttpRetCode;
	int 			  intHttpMilliseconds;
	float 			floatHttpMilliseconds;
	int 			  intHttpSize;
	float 			floatHttpKBytes;

	
	/* Defined as globals at top of vuser_init():
	int 			  intHttpRetCode;
	int 			  intHttpMilliseconds;
	float 			floatHttpMilliseconds;
	int 			  intHttpSize;
	float 			floatHttpKBytes;
	*/

	if( in_rc == LR_FAIL ){
		lr_end_transaction(lr_eval_string("{pTransName}"),LR_FAIL);		
	}else{
		rc=lr_get_transaction_status( lr_eval_string("{pTransName}") );
		// Using pTransName saved in wi_start_transaction before the transaction:
		if( rc == LR_FAIL ){
			lr_end_transaction(lr_eval_string("{pTransName}"),LR_FAIL);
    		wi_startPrintingError();
    		lr_error_message(">> Iteration=%d User=\"%s\" Trans=%s FAIL ERROR." 
		                  ,iActionIterations
		                  ,lr_eval_string("{parmLoginUserID}")
		                  ,lr_eval_string("{pTransName}")
		                 );
			wi_resetPrinting();
		}else{
			lr_end_transaction(lr_eval_string("{pTransName}"),LR_AUTO);		
		}
	
    	// Verify bad 400 HTTP return code from server and associated response such as "{error : invalid_grant}"
    	// using LoadRunner internal function web_get_int_property():
		    intHttpRetCode 		= web_get_int_property(HTTP_INFO_RETURN_CODE);
  		    intHttpSize 		= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
		    intHttpMilliseconds = web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
		  floatHttpMilliseconds = (float)intHttpMilliseconds / 1000; // Convert from milliseconds to seconds.

		if (intHttpRetCode == 200 // no problem! OK
		||  intHttpRetCode == 304 // Already cached.
		){
			// move on.
			rc=LR_PASS;
		}else{
			// intHttpRetCode == 500
			// intHttpRetCode == 503

			wi_startPrintingError();
   		 	lr_output_message(">> Iteration=%d User=\"%s\" HTML Return Code=%d." 
			                  ,iActionIterations
			                  ,lr_eval_string("{parmLoginUserID}")
			                 , intHttpRetCode
			                ); // QUESTION: What does rc -1 mean?
			wi_resetPrinting();
			rc=LR_FAIL;
		}
	}
	
    return rc;
} // wi_end_transaction