tsung not sending or receiving any data - load-testing

i have an api which i was load testing with tsung.All was ok. Now , i am getting no result using varibles data from file in load testing.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE tsung SYSTEM "/usr/local/Cellar/tsung/1.7.0/share/tsung/tsung-1.0.dtd">
<tsung loglevel="warning">
<clients>
<client host="localhost" use_controller_vm="true"/>
</clients>
<servers>
<server host="127.0.0.1" port="8030" type="tcp"/>
</servers>
<load>
<arrivalphase phase="1" duration="1" unit="minute">
<users arrivalrate="100" unit="second"/>
</arrivalphase>
</load>
<options>
<option name="file_server" id="ids" value="id.csv" ></option>
</options>
<sessions>
<session name="dummy" weight="1" type="ts_http">
<setdynvars sourcetype="file" fileid="ids" order="iter">
<var name="uid" />
</setdynvars>
<request subst="true">
<http url="/api/v1/locations?user_ids=%%_uid" method="GET" version="1.1" >
<http_header name="Content-Type" value="application/json"/>
<http_header name="RLS-Referrer" value="vivasoftltd.com"/>
</http>
</request>
</session>
</sessions>
</tsung>
this config file.
and the id.csv is
1
2
3
4
5
6
7
now generating report showing
size_rcv is equal to 0 !
size_sent is equal to 0 !
And the report.html is showing all empty and all errors.
How can i solve this

Your dynamic variable substitution is incorrect inside your request.
<http url="/api/v1/locations?user_ids=***%%_uid%%***" method="GET" version="1.1" >
Please check this link for Tsung documentation regarding Dynamic variables.

Related

How to call API with Bearer token Wso2 EI?

I have 2 api to request:
API get token
API request to work something (use OAuth2)
Below is code to call get token:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/default" name="PostToken" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<payloadFactory description="Setting payload for GetAccessToken API" media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root xmlns="">
<grant_type>$1</grant_type>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg value="client_credentials"/>
</args>
</payloadFactory>
<!-- Below configurations are required to send data as application/x-www-form-urlencoded -->
<header name="Content-Type" scope="transport" value="application/x-www-form-urlencoded"/>
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
<header name="Authorization" scope="transport" value="Basic xxxxxxxx"/>
<property name="POST_TO_URI" scope="axis2" type="STRING" value="true"/>
<call>
<endpoint>
<http method="post" uri-template="https://sample.com/token">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
How next step I can get token from response to apply the 2nd API with Bearer token?
Many thanks!
You can refer to the following blog regarding the Using OAuth2 Protected Back-ends With API Manager., This blog is regarding handling that in the WSO2 API Manager. But this is applicable in the EI as well.
[1] https://medium.com/#menakajayawardena/wso2-how-to-using-oauth2-protected-back-ends-with-api-manager-5d7e234c61c

WSO2 API Manager 2.0.0- Receive GET request and send POST to backend

I've created an RESTful API in wso2-am 2.0.0. But I'm face a problem and a would some help.
I have a resource wiht GET http method which receive an url param and I made a SOAP payload to send via POST to backend (backend is soap11).
For this, I used a custom 'in' sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="JSONtoSOAP" trace="disable"
xmlns="http://ws.apache.org/ns/synapse">
<log description="Entrada" level="full" separator=",">
<property expression="get-property('uri.var.cpfCnpj')" name="cpfcnpj" />
<property name="trace"
value="IN LOG" />
</log>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING" />
<property name="messageType" scope="axis2" type="STRING"
value="application/soap+xml" />
<enrich>
<source type="inline">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body />
</soap:Envelope>
</source>
<target action="replace" type="envelope" />
</enrich>
<payloadFactory media-type="xml">
<format>
<man:QueryCustomerDetailsRequestMessage
xmlns:man="http://www.algartelecom.com.br/SOA/Service/ManageCustomerInformationPortalClientesReqCS">
<man:documentNumber>$1</man:documentNumber>
<man:tagetCRM />
</man:QueryCustomerDetailsRequestMessage>
</format>
<args>
<arg evaluator="xml" expression="get-property('uri.var.cpfCnpj')" />
</args>
</payloadFactory>
<property name="REST_URL_POSTFIX" value="" scope="axis2" />
<header name="Action" scope="default" value="queryCustomerDetails" />
<log description="Saida" level="full" separator=",">
<property name="trace" value="DEBUG LOG" />
</log>
</sequence>
Until here, without problem.
But when I try to call the resource from any restClient (SOAPui for example or wso2-am store) result in Runtime exception, like this:
<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code/>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description/>
</am:fault>
</soap:Body>
</soap:Envelope>
Note that code and description tags are empty, and when I checked the server's log I found:
[2016-09-30 16:53:44,603] INFO - LogMediator STATUS = Executing default 'fault' sequence, ERROR_CODE = null, ERROR_MESSAGE = null
This is the correct way to produces a restful API and call a SOAP backend?
Anybody knows about this issue? (I believe, this feature works on WSO2 ESB).
You can try the following:
In the publisher, set your endpoint type to HTTP/SOAP endpoint
In your sequence don't set the REST_URL_POSTFIX to "", but remove the property completely

How to call Wso2bps using wso2esb

I am using wso2esb4.8.0 and wso2bps3.0.1 while i am working with 2 servers both are working fine .But i wish incorporate both severs for that i written sample BPEL
sample BPLE file is like this
<bpel:process name="multiply2integers"
targetNamespace="http://wso2.org/bps/sample"
suppressJoinFailure="yes"
xmlns:tns="http://wso2.org/bps/sample"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
>
<!-- Import the client WSDL -->
<bpel:import location="multiply2integersArtifacts.wsdl" namespace="http://wso2.org/bps/sample"
importType="http://schemas.xmlsoap.org/wsdl/" />
<!-- ================================================================= -->
<!-- PARTNERLINKS -->
<!-- List of services participating in this BPEL process -->
<!-- ================================================================= -->
<bpel:partnerLinks>
<!-- The 'client' role represents the requester of this service. -->
<bpel:partnerLink name="client"
partnerLinkType="tns:multiply2integers"
myRole="multiply2integersProvider"
/>
</bpel:partnerLinks>
<!-- ================================================================= -->
<!-- VARIABLES -->
<!-- List of messages and XML documents used within this BPEL process -->
<!-- ================================================================= -->
<bpel:variables>
<!-- Reference to the message passed as input during initiation -->
<bpel:variable name="input"
messageType="tns:multiply2integersRequestMessage"/>
<!--
Reference to the message that will be returned to the requester
-->
<bpel:variable name="output"
messageType="tns:multiply2integersResponseMessage"/>
</bpel:variables>
<!-- ================================================================= -->
<!-- ORCHESTRATION LOGIC -->
<!-- Set of activities coordinating the flow of messages across the -->
<!-- services integrated within this business process -->
<!-- ================================================================= -->
<bpel:sequence name="main">
<!-- Receive input from requester.
Note: This maps to operation defined in multiply2integers.wsdl
-->
<bpel:receive name="start" partnerLink="client"
portType="tns:multiply2integers"
operation="process" variable="input"
createInstance="yes"/>
<!-- Generate reply to synchronous request -->
<bpel:assign validate="no" name="Assign">
<bpel:copy>
<bpel:from>
<bpel:literal>
<tns:multiply2integersResponse xmlns:tns="http://wso2.org/bps/sample" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><tns:mul>0</tns:mul>
</tns:multiply2integersResponse>
</bpel:literal>
</bpel:from>
<bpel:to variable="output" part="payload"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from>
<![CDATA[$input.payload/tns:c*$input.payload/tns:d]]>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:mul]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="end"
partnerLink="client"
portType="tns:multiply2integers"
operation="process"
variable="output"
/>
</bpel:sequence>
</bpel:process>
even i am publishing my bpel wsdl also
if i try with wso2bps TRYIT tool its working fine but while calling with wso2esb is not working
WSDL file is
<?xml version="1.0"?>
<definitions name="multiply2integers"
targetNamespace="http://wso2.org/bps/sample"
xmlns:tns="http://wso2.org/bps/sample"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TYPE DEFINITION - List of types participating in this BPEL process
The BPEL Designer will generate default request and response types
but you can define or import any XML Schema type and use them as part
of the message types.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<types>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://wso2.org/bps/sample"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="multiply2integersRequest">
<complexType>
<sequence>
<element name="c" type="int"/>
<element name="d" type="int"/>
</sequence>
</complexType>
</element>
<element name="multiply2integersResponse">
<complexType>
<sequence>
<element name="mul" type="int"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MESSAGE TYPE DEFINITION - Definition of the message types used as
part of the port type defintions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<message name="multiply2integersRequestMessage">
<part name="payload" element="tns:multiply2integersRequest"/>
</message>
<message name="multiply2integersResponseMessage">
<part name="payload" element="tns:multiply2integersResponse"/>
</message>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PORT TYPE DEFINITION - A port type groups a set of operations into
a logical service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- portType implemented by the multiply2integers BPEL process -->
<portType name="multiply2integers">
<operation name="process">
<input message="tns:multiply2integersRequestMessage" />
<output message="tns:multiply2integersResponseMessage"/>
</operation>
</portType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PARTNER LINK TYPE DEFINITION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="multiply2integers">
<plnk:role name="multiply2integersProvider" portType="tns:multiply2integers"/>
</plnk:partnerLinkType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BINDING DEFINITION - Defines the message format and protocol details
for a web service.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<binding name="multiply2integersBinding" type="tns:multiply2integers">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="process">
<soap:operation
soapAction="http://wso2.org/bps/sample/process" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SERVICE DEFINITION - A service groups a set of ports into
a service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<service name="multiply2integers">
<port name="multiply2integersPort" binding="tns:multiply2integersBinding">
<soap:address location="http://*********:8080/multiply2integers" />
</port>
</service>
</definitions>
and i written sample proxy which will call the BPEL endpoint that sample proxy define below
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="BPELProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="value1"
expression="//c/text()"
scope="default"
type="STRING"/>
<property name="value2"
expression="//d/text()"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<p:AddingPLRequest xmlns:p="http://wso2.org/bps/sample">
<c xmlns="http://wso2.org/bps/sample">$1</c>
<d xmlns="http://wso2.org/bps/sample">$2</d>
</p:AddingPLRequest>
</format>
<args>
<arg evaluator="xml" expression="get-property('c')"/>
<arg evaluator="xml" expression="get-property('d')"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint key="BPEL"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
defined endpoint view is my endpoint is
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="BPEL">
<address uri="http://*************:9763/services/multiply2integers/" format="soap12">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
i am sending request from CURL command to ESB I am getting errors my CURL Command is.
curl -v -H "Accept: application/json" -H "Content-Type:application/json" -d '{"c":"55","d":"3"}' http://***t:8282/services/BPELProxy
and its showing errors if i change the format of endpoint its showing some other error error log like this
[2014-01-13 15:20:01,070] INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} - 'admin#carbon.super [-1234]' logged in at [2014-01-13 15:20:01,070+0530]
[2014-01-13 15:22:44,887] WARN {org.wso2.carbon.server.admin.module.handler.AuthenticationHandler} - Illegal access attempt at [2014-01-13 15:22:44,0886] from IP address null while trying to authenticate access to service StatisticsAdmin
[2014-01-13 15:22:44,887] ERROR {org.wso2.carbon.statistics.ui.StatisticsAdminClient} - Cannot get service stats for service multiply2integers. Backend server may be unavailable.
org.apache.axis2.AxisFault: The input stream for an incoming message is null.

Tsung: Using iterator in loop

I'm trying to create load testing scenario for ejabberd with tsung.
I want simulate thousands of XMPP events from thousands clients. According tsung's manual I can create repeated actions using for loop:
<for from="1" to="10" incr="1" var="counter">
[...]
<request> <http url="/page?id=%%_counter%%"></http> </request>
[...]
</for>
But this example don't working for me:
alex#alex:~/.tsung$ tsung -f jabber.xml start
Starting Tsung
"Log directory is: /home/alex/.tsung/log/20130417-1404"
3306- fatal: {error,{validity_constraint_Name_Token,37}}
Config Error, aborting ! {fatal,{{error,{validity_constraint_Name_Token,37}},
{file,"jabber.xml"},
{line,10},
{col,29}}}
Full config file:
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.5">
<clients>
<client host="localhost" use_controller_vm="true"></client>
</clients>
<!-- Server side setup -->
<servers>
<for from="1" to="1000" incr="1" var="counter">
<server host="t%%_counter%%.testserver.org" port="5222" type="tcp"></server>
</for>
</servers>
<load>
<arrivalphase phase="1" duration="1" unit="minute">
<users interarrival="2" unit="second"></users>
</arrivalphase>
</load>
<!-- JABBER parameters -->
<!-- to synchronise users, use a global acknoledgement -->
<options>
<option type="ts_jabber" name="global_number" value="100"></option>
<option type="ts_jabber" name="userid_max" value="10000"></option>
<option type="ts_jabber" name="domain" value="mydomain.org"></option>
<option type="ts_jabber" name="username" value="user"></option>
<option type="ts_jabber" name="passwd" value="pass"></option>
</options>
<sessions>
<session probability="100" name="jabber-loadtest" type="ts_jabber">
<request><jabber type="presence:broadcast" show="online" status="Status: online" ack="no_ack"/></request>
<thinktime value="1"></thinktime>
<request><jabber type="presence:broadcast" show="offline" status="Status: offline" ack="no_ack"/></request>
</session>
</sessions>
</tsung>
How can I use loops in tsung configuration file?
You can't use loops in <servers> section, loops are available in <session> only.

error in persistence.xml

I am trying to deploy a simple EJB project onto Jboss 7.1.1. I have a separate installation of H2 database.
So I changed the standalone.xml as follows:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:tcp://localhost/~/test</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
Now I have also edited the persistence.xml to match the names in the standalone.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="scube" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.sample.model.Property</class>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
Eclipse, points an error at line: java:jboss/datasources/ExampleDS
Error is as follows:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'jta-data-source'. One of '{"http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/
xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":shared-cache-mode, "http://java.sun.com/xml/ns/persistence":validation-mode,
"http://java.sun.com/xml/ns/persistence":properties}' is expected.
I searched for similar errors and all the resolutions said that either the order of xml elements were important, which I checked or the jndi name should match with standalone.xml, which does match.
Can someone help me with this?
The right order of XML elements (according to schema document) is:
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<class>com.sample.model.Property</class>

Resources