Solve Ubuntu problems when connecting to 4G networks

Most of you may find a lag when your Ubuntu computer connects to a 4G network.Here are few solutions you can try to overcome this.

Open terminal and go to root in your computer.

type sudo su, you will go to root.

then type below command.

echo "options iwlwifi 11n_disable=1" >> /etc/modprobe.d/iwlwifi.conf

Then type reboot to restart your computer.

What we have done here is disabling 802.11n protocol.Because some of the routers does not support this protocol.Therefore, disabling this can make wifi speedup. 🙂

 

How to create a mock service using WSO2 HTTP Wand

This is another tool that can use to create mock services.

This  has developed by one of the WSO2 members.

You can download this from here.

Before going into the usage scenario of this tool, i would like to add his own words about the tool.

“I have written a tool which can be used to generate various kinds of HTTP
response messages. It was primarily developed as a testing tool that can be
used to reproduce various network conditions and real life application
scenarios. The tool consists of a simple HTTP server and a UI client. You
can find the source code at [1]. I have also attached a screen shot of the
tool herewith. To try out the tool simply checkout the source, build and
extract the distribution archive. I’d appreciate some feedback on it. I have
tentatively named the tool “WSO2 HTTP Wand” 🙂 ”

Now let’s create a mock service using WSO2 WAND.

First go to WSO2_WAND_HOME/bin/http-server.sh and start the server.

Then run command WSO2_WAND_HOME/bin/http-client.sh to start the wand client.And below window will appear.

wand

Method : you can choose the http method (POST or GET) you need to send the response.

URL : this is the url that the mock service will mount on.

Status code : you can type any http status codes (200,302,400 etc…) to be sent with the response.

Headers : can add headers to the response message.

Request Payload : this is where you mention your payload that send with the response.

1.Now let’s create a mock service.

I have created a mock service which send a SOAP message as the response and no headers has attached.

wand2222

2. Now if you click on send button, you will see the response that will go back to any client it invokes as below.

wand3333

3.Now start a ESB server and create a proxy service and include the mock service as the endpoint that it send the requests to.

<?xml version=”1.0″ encoding=”UTF-8″?>
<proxy xmlns=”http://ws.apache.org/ns/synapse&#8221;
       name=”wandproxy”
       transports=”https,http”
       statistics=”disable”
       trace=”disable”
       startOnLoad=”true”>
   <target>
      <inSequence>
         <log level=”full”/>
         <send>
            <endpoint>
               <address uri=”http://127.0.0.1:8080″/&gt;
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log level=”full”/>
         <respond/>
      </outSequence>
   </target>
   <description/>
</proxy>
4.Now, using below curl command invoke the ESB proxy service.

curl -v -H “Content-Type: application/xml”  <mock proxy url>

5.You will see the response in ESB logs as below.

INFO – LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:f02c9e7d-c840-49c1-a169-0704ba2f1a92, Direction: response, Envelope: <?xml version=’1.0′ encoding=’utf-8′?><soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”><soapenv:Body><coordinates&gt;
<location>
<name>Bermuda Triangle</name>
<n>25.0000</n>
<w>71.0000</w>
</location>
<location>
<name>Eiffel Tower</name>
<n>48.8582</n>
<e>2.2945</e>
</location>
</coordinates></soapenv:Body></soapenv:Envelope>

How to use ZAP tool for security testing of WSO2 servers.

ZAP tool is developed by OWASP to test security and stability of websites and applications.

First, download ZAP tool from https://github.com/zaproxy/zaproxy/wiki/Downloadso

Extract the tool and run ./zap.sh to launch the tool.

1.Before that you need to add a proxy in your browser.My browser is Firefox so i add a proxy as below.

Go to preferences -> advanced -> network -> settings

Choose manual proxy configuration and add a host name and a port

I have added host : localhost, port : 8300

Then restart the browser to effect the changes you made.

2.Go to ZAP_HOME/tools/options/Local proxy in the ZAP tool interface.

add the same host and port names you added in the proxy you created in your browser.

Click ok.

zap
3.Start any WSO2 server.Here I am going to use WSO2 ESB.

4.Go to management console using your browser.

(Keep in mind not to open any other pages in your browser, since ZAP tool will record their actions too.Hence, for the ease of use you can open up only the server page).

Login to ESB console.

5.Now, If you go to window underneath workspace window you can see that security alerts are recording.

zap2222

You can see that there are few tabs underneath workspace window.

Under history tab, all the requests that sent to the ESB server has recorded including their risk levels.

Under Alerts tab you can see all the security alerts for the actions you performed on the server.The list of alerts indicate the risk level by the color of the flag before them.

If you click one of the drop down lists, you can see their descriptions and the risk level and from which url the threat is coming from.

zap333333

Also you can try different attack types by attacking through them to the server.

Right click on the url of the server under sites and select Active scan attack

Active Scanning attacks selected targets in order to find potential vulnerabilities. Active scanning can only find certain vulnerabilities (for example, it cannot find logic vulnerabilities).

A new tab called Active Scan will open and all the active scan attacks will be recorded there.

zap4444

Then you can do a Spider attack too.This is used to find all the sites/URLs linked on a particular site.

Once you clicked on Spider tab, you will see the list of URI s connected to the server as below.

zap6666

This includes whether the user wants to use the spider to process forms and whether the spider should use GET or POST requests.

ZAP will use  spider to crawl the application, which will
automatically passively scan all of the pages discovered.

How to use Selenium IDE Plugin to record test cases

In this post I am going to explain you how to create test cases using Selenium IDE.

Selenium IDE helps you to record user interactions with the browser and thus the recorded actions as a whole are termed as Selenium IDE script.

Once we have recorded a stable script, we may want to save it for future runs and regressions.

Let us now see how to create a test script of creating a sequence in WSO2 ESB.

Start the ESB server.

Launch the Firefox and open Selenium IDE from the menu bar.

Enter the address of the ESB server as the Base URL in Selenium IDE.

By default, the Record button is in ON state. Remember to tune it ON if it is in OFF state so as to enable the recording mode.

Selenium-IDE-script-2

Right click anywhere on the page except the hyperlinks or images. The right click opens the Selenium IDE context menu listing few of the commands. To get an entire list, select “Show Available Commands” option. This will open another menu containing rest of the available and applicable commands.

sele2

Now, let’s create the test script of creating a sequence in ESB.Click on record button.and Create a sequence as below.

selenium4

If you right click on one of the commands, you can see that you can add new commands and execute single commands one by one.

selenium5

Now that we have created our first Selenium IDE script, we would want to execute it to see if the script is stable enough. Click on the playback button to execute the script.

Post execution, all the test steps would be color coded in green for the successful run. The same would be visible from the test case pane.

For unsuccessful execution or test case failure, the failed test step would be highlighted in red. And the test case pane would mark the test case execution as failure.

To save the test script, Click on the File menu and select “Save Test Case” option.

Like that we can create test suits and use them for regression testings.

Access DAS REST API using Advanced REST client

WSO2 DAS has a REST API that allow you to check various scenarios on DAS.

This post basically will walk you through how to use Advanced REST client to perform operations on a REST API.

Let’s see how we can use it to list all the tables we have created in DAS server.

Launch Advanced REST client in Google Chrome and you will see an interface as below.

restclient

URL : specify the url of the REST API

From the radio buttons, you can select the type(GET,POST etc…) of the request.

Headers section : can specify any headers you need to include in the request.

Payload section : specify the request body.

In the below drop down menu, you can select the type of the request(application/json or application/xml etc…).

Now let’s send a request to DAS REST API to get the list of all the tables we have created in DAS.

  • Start a DAS server.Create few streams and persist them(if there are no streams).I have created below tables.

JMX_AGENT_TOOLBOX,JMX_AGENT_TESTPROFILE,TABLEONE,TABLETWO,TABLETHREE

  • Since we are sending a GET method request to retrieve list of tables we just have to define a header but not a payload as below image.

Keep in mind that you have to send the encoded username and password of DAS server as the header.

das22

click on send and you will see the list of tables in DAS server as below.

das333

In that way you can invoke any method in DAS REST API.

How to capture requests and responses using Wireshark

Wireshark is an open source packet analyzer.We can use this to capture requests and responses to a server.

In this post, I am going to use WSO2 ESB to invoke SimpleStockQuoteService and capture it’s requests and responses using Wireshark.

Install Wireshark using below command.(for ubuntu machines)

sudo apt-get install wireshark

Download WSO2 ESB4.9.0 from here.

Below steps will walk you through capturing requests and responses using Wireshark.

  • First, Start ESB and deploy SimpleStockQuoteService.
  • Run below command in terminal to capture tcpdump in some directory location of your machine.

sudo tcpdump -i lo port 9000 -w capture.log

port 9000 is the post in ESB, which used to start StockQuote service.So I am going to capture packets that comes to port 9000.

you will see the following log in terminal, once u ran the above command.

tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes.

  • Invoke SimpleStockQuote service using stockquote client.
  • Then start Wireshark.You will see a window as below.

wireshark

  • Now if you go to the directory location in your machine, where you ran the command to capture tcpdump, you will see a file called capture.log.
  • Go to open in Wireshark window and open that capture.log file.You will see the below window.

wireshark2

  • If you click on  HTTP/XML    689    POST /services /SimpleStockQuoteService HTTP/1.1, in the below image you can see the request that has sent to SimpleStockQuote service.

wireshark3

  • Click on HTTP/XML    1109    HTTP/1.1 200 OK  and you can see the response that sent from service to the client using below image.

wireshark4

How to create a mock service using Mocky.io

Previously in another post, i have explained you about creating a mock service using Mockable.io website.

In this post i am going to explain you about creating a mock service using Mocky.io web tool.This is far more easier and simpler than Mockable.io web tool.

First go to http://www.mocky.io/ website.The website itself is act as a tool.

You will find below interface.

mocky

You have to fill the information required under Generate your custom response section.

Let’s create a mock service for a ESB proxy that generates a SOAP/XML response.

You need to fill the information in Mocky.io interface as below.

Status code: you can specify any status code you need in the response.

for this scenario i have specified it as a 200 OK one.

Content type: content types can be mainly SOAP/XML or JSON etc…

in this scenario i needed a SOAP response, so i have specified a XML content type.

Body : In this section specify the message you need as the response.

i have specified a SOAP message.

Then click on generate my HTTP response button and it will start the mock service and the link to the service will appear before “Your link is ready:” label.

mocky2

Start ESB and create a proxy and as an address endpoint give the link in mock service.

Now, using below curl command invoke the ESB proxy service.

curl -v -H “Content-Type: application/xml”  <mock proxy url>

You will see the response in ESB logs as below.

INFO – LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:f02c9e7d-c840-49c1-a169-0704ba2f1a92, Direction: response, Envelope: <?xml version=’1.0′ encoding=’utf-8′?><soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”><soapenv:Body><coordinates&gt;
<location>
<name>Bermuda Triangle</name>
<n>25.0000</n>
<w>71.0000</w>
</location>
<location>
<name>Eiffel Tower</name>
<n>48.8582</n>
<e>2.2945</e>
</location>
</coordinates></soapenv:Body></soapenv:Envelope>

How to connect DAS instance with an external spark cluster

Suppose you have a DAS instance in one node and External spark cluster in another node.

Now, you need to connect DAS instance with the external spark cluster.

First, unzip another DAS instance in node, where the external spark cluster has located.

Then, create a symlink(symbolic link) to DAS_HOME as below in /mnt/das location (you can choose any location you want) of your node.

cd    /mnt/das/das_symlink

cd   /mnt/das/

remove current symlink and create another one by specifying your DAS instance home location as below.

sudo ln -s  /home/centos/das/wso2das-3.0.0-SNAPSHOT das_symlink

Then it will create a symlink in /mnt/das location.

Give this symlink location to DAS_HOME/repository/conf/analytics/spark/spark_default.config file as below.

carbon.das.symbolic.link  /mnt/das/das_symlink

Then go to external spark cluster located node and start the spark cluster.

Create the symlink  by following above procedure for the DAS instance which is going to connect with external spark but not in external spark cluster node.

note that both DAS instances in external spark cluster and other node should have to have exactly the same configurations like databases etc…

(Also don’t start the DAS instance in external spark cluster node.)

Now, if you go to external-spark-node-IP:4040 you will see the following web page.

spark

The spark.driver.extraClassPath should have this symlink location.(mnt/das/das_symlink)

Then, start the DAS node to connect with external spark cluster.

All the server instances should work properly, if the configurations has set properly.

How to invoke a simple web service using Apache JMeter

Let’s see how to invoke a simple SOAP/REST service using WSO2 products.

First, start WSO2 Application Server and deploy the SOAP web service.

Here we have used web service as OrderPWebservice

as-web-service

Now you can see that your SOAP web service is up and running at WSO2 AS.

Let’s create a Test plan in JMeter.

Right click on Test Plan and go Add -> Threads(Users) -> Thread Group

jmeteronw

In the Thread Group element, set the thread properties,
    • Number of threads(users) : No. of concurrent users to be simulated.
    • Ramp – up period(in seconds) :Time taken by the JMeter to invoke the threads
    • Lop count : No of times the test plan should be repeated.

Then right click on Thread Group and add a SOAP/XML-RPC Request as below.

abc

Then right click on Thread Group and add -> Listener -> View Results Tree. This is to view the requests and responses to check whether they executed successfully.

In SOAP/XML-RPC Request window, add the url of the web service and the SOAP request to the web service as below.

url : http://${host}:${port}/services/OrderPWebService/

SOAP?XML-RPC Data :

<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:ord=”http://order.com”&gt;
<soapenv:Header/>
<soapenv:Body>
<ord:displayOrder>
<ord:name>IBM</ord:name>
</ord:displayOrder>
</soapenv:Body>
</soapenv:Envelope>

Here, in the url, i have parameterized the url and port of the service(${host}:${port}).

In order to parameterized values in you request, you can add the parameters to the script as below.

Go to Test Plan–>Pre processors–> User Parameters and add parameters for the host and port as below.

URL_PORT_Par1

jmeter

Now, adding url and port for the script as shown below.

jmeter222222

Also you can add an assertion to the script too.I am going to use a response assertion  to verify whether the response contain pattern 200.

Add a response assertion as below.

jmeter3333

Also you can add an assertion results to see the success and the failure of the tests based on assertions.

Now, save the Test Plan and click on the green arrow button to start sending requests to the web service.

Since we have specified “one” as number of threads in Thread Group, it will send only one message at one start.

Click on View results tree.Click on SOAP/XML-RPC Request and you will see the request, response and sampler result on the right side as below.

gfd

And if you look at the assertion results, it will be shown the test success  as below.

jmeeee

and if the responses do not contain the stated response code, the assertion results window will show it as below.

abc



Now let’s see how to invoke a REST web service.

Deploy a REST web service in WSO2 Application Server.

For the same Thread Group you can add a HTTP Request Sampler.

Right click on Thread Group -> add -> sampler -> HTTP request

123

Next we need to add a HTTP Header Manager to send parameters in the header of the request. We need to send “Content-Type” and “Access” variables as request headers.

345

This is because the REST service might expects “Content-Type” and “Access” parameters in the header request.

Fill in the HTTP request window using the IP, port, path, HTTP request details and request Body data.

real

If you click on the View Result tree you can see the request and response and the response in Json format as well.

ttt

Also, you can use the same steps to invoke SOAP web service as well.

How to use wrk-HTTP benchmark tool to measure performance of WSO2 servers.

This post will describes you how to measure the performance of WSO2 ESB.

You can use the same steps to measure performance of any WSO2 server too.

If you are using Ubuntu OS, use below steps to install wrk.

sudo apt-get install build-essential libssl-dev git
git clone https://github.com/wg/wrk.git
cd wrk
make
# move the executable to somewhere in your PATH
sudo cp wrk /usr/local/bin

1.First start WSO2 ESB.

2.Then type below command in terminal to run a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open.

wrk -t12 -c400 -d30s https://192.168.43.101:9455/carbon/admin/index.jsp

3. Then you will see the below output.

12 threads and 400 connections
Thread Stats   Avg      Stdev        Max     +/- Stdev
Latency    49.21ms  111.29ms   1.44s     92.87%
Req/Sec     1.67k       838.13       5.04k      63.49%
520897 requests in 30.08s, 175.40MB read
Requests/sec:  17316.67
Transfer/sec:      5.83MB

You can use same steps to analyze performance of other WSO2 servers as well.

Let’s do another example on a proxy service as well.

Create a ESB proxy that invoke SimpleStockQuote service.

Now  run a benchmark for 30 seconds, using 20 threads and keeping 500 HTTP connections open.

wrk -t20 -c500 -d30s http://nayomi-ThinkPad-T540p:8280/services/Test

Below are the results we get

Thread Stats   Avg      Stdev        Max     +/- Stdev
Latency    52.12ms  121.29ms    2.44s      94.57%
Req/Sec     2.37k       725.14       6.04k      65.29%
530255 requests in 30.08s, 175.40MB read
Requests/sec:  17514.37
Transfer/sec:      5.74MB

from the statistics we can see that it takes average 52.12ms to serve between two requests.