Esempio n. 1
0
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
Esempio n. 2
0
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