Monday, November 24, 2014

How to record test script in JMeter and run through command line?

Below are the steps to record test scripts using JMeter

1. First launch your JMeter app, right click on the "Test Plan" node, select "Add" -> "Threads (Users)" -> "Thread Group"


2. Select "Thread Group" node and right click. Select "Add" -> "Config Element" -> "Http Request Default"


3. In "HTTP Request Defaults" page, enter the value in "Server Name or IP" field. For example, "jmeter.apache.org".

Note: If your portal are using SSL, please enter "443" to the port. The "Path" field can leave it as an empty field.


4. Select "Thread Group" node and right click. Select "Add" -> Logic Controller -> "Recording Controller".



5. Select "Workbench" node and right click. Select "Add" -> "Non-Test Elements" -> "HTTP(S) Test Script Recorder".

6. In "URL Patterns to Include" section, add the value ".*\.html".



Note: Make sure "Target Controller" is selected. Should select the the "Recording Controller" that have created in "Test Plan".

7. Select "HTTP(S) Test Script Recorder" and right click. Select "Add" -> "Listener" -> "View Results Tree"


8. Click on the "HTTP(S) Test Script Recorder", click on "Start" button. "Root CA certificate: ApacheJMeterTemporaryRootCA created in JMeter bin directory" message is displayed.

Configure browser to use JMeter proxy

1. Open the "Chrome", click on the "Setting" menu. Click on "Change Proxy Settings" button in the "Network" section.

2. Click on "LAN settings" button, set the value as Address: localhost Port: 8080


3. Open the Chrome browser and type in the command as "http://jmeter.apache.org/", the activity request will be captured at jmeter tools.


4. Make sure the "Recording Controller" consists of the intercept request. Click on "File" -> "Save Test Plan as" to save the test plan in jmx extension.



5. Run the jmeter test script through the command line as described below. Assume the test plan file name is "jmeter.jmx"
jmeter -n -t jmeter.jmx
Install SSL certificate browser to intercept the request

1. When the JMeter tool is started, a temporary SSL certificate "ApacheJMeterTemporaryRootCA.crt" will be generated. It always located at [JMETER_HOME]\bin.

2. Import the certificate "ApacheJMeterTemporaryRootCA.crt" into browser.



Tuesday, October 21, 2014

How to solve pod stop working once upgraded to "OS X Yosemite"?

Once I upgraded my Mac machine to "OS X Yosemite", I execute the command "pod install" to update the library, I encounter the error as showed below

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError)
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:6:in `rescue in '
 from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:3:in `'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj.rb:30:in `'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods.rb:2:in `'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/bin/pod:32:in `'
 from /usr/bin/pod:23:in `load'
 from /usr/bin/pod:23:in `
To resolve the error as described above, uninstall cocoapod, reinstall xcodeproj and cocoapods.

    $ sudo gem uninstall cocoapod 
    $ sudo gem install xcodeproj 
    $ sudo gem install cocoapods

Saturday, October 18, 2014

How to solve WAMP server unable to start due to conflict of port 80?

Stop HTTP.sys server by using the command as described below

- Run command window using administrator rights (Right click "Command Window" icon and click on "Run as administrator" menu)

net stop http /y
sc config http start= disabled

Sunday, July 6, 2014

How to setup Ubuntu on Virtual Box?

Wish to explore Ubuntu but lack of machine to deploy and try. This is really frustrated especially for poor programmer like me who always struggling to upgrade my technical knowledge but not well equipped with neither hardware nor software. Out of disappointment, manage to discover virtual box as other option in setup Ubuntu on top of my Window 7 machine for exploration.

Note: 
1. Assume VirtualBox 4.3.12 has been installed on Window 7. Refer to http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html?ssSourceSiteId=otnjp

2. Assume Ubuntu version 14.04 installer CD is ready.

Create New Virtual Machine


- Click on "New" button, enter the details as described below

Name: Ubuntu
Type: Linux
Version: Ubuntu (32 bit)


- Click on "Next" button, allocate memory size as "1024" MB


- Click on "Next" button, hard drive allocation screen is displayed. Use the default allocation size as 8GB.


- Click on "Create" button, "Hard drive file type" screen will be displayed. Use the default "VDI (VirtualBox Disk Image" file type.


- Click on "Next" button, "Storage on physical hard drive" page is displayed. Select "Dynamically allocated" radio button.


- Click on "Next" button, "File location and size" screen is displayed. Default the name of virtual harddrive as "Ubuntu" and allocate the size limit of the file data on the hard drive as "40GB"


- Click on "Create" button, a new virtual machine is created and is as shown in the screenshot below 


Install Ubuntu

- Click on "Start" button, "Select start-up disk" page is displayed.   


- Make sure the Ubuntu start-up disk is inserted into the "Hard Drive D:". Click on "Start" button. Ubuntu installation screen is displayed.


- After few minutes of loading, the Ubuntu installation screen is displayed.


- Click on "Install Ubuntu" button to kick start the installation."Preparing to install Ubuntu" page is displayed.


- Checked the options below during the installation

1. Download updates while installing
2. Install this third party software

- Click on "Continue" button. "Installation Type" screen is displayed. Use the default setting as shown below. Click on "Install Now" button, the installation kick started. 


- Current location page as shown below is displayed. Select your current location. Click on "Continue" button.


- "Keyboard Layout" page as shown in the screenshot below is displayed. Follow the instruction as prompted in the screen. Once "Continue" button is enabled, click on "Continue" button.


- "Who are you" page as shown in the screenshot below is displayed. Enter all the necessary information. Click on  "Continue" button.


- The installation complete screen as shown in the screenshot below is displayed when the installation completed.


Voila, you will have Ubuntu run on your Window machine once you have restarted your virtualbox.

Friday, June 13, 2014

How to enable your Postgres database accessible by PgAdmin client from other machine remotely?

It is really inconvenience when I found out that I can't connect to my Postgres database (sit in Linux server) remotely through PgAdmin client tools to conduct my troubleshooting works. Even though from security perspective, should turn off the remote access. But, if my PgAdmin client is sitting within the same private network (behind the firewall), I think it is no harm to enable it. The reality is PgAdmin client on Window  is much more user friendly then I use command line tool on Linux.

Step 1 - Edit the Postgres database configuration file to enable remote machine to connect

vi /var/lib/pgsql/data/pg_hba.conf
Add the line as described below:-

host    all         all         [REMOTE MACHINE IP ADDRESS]/24       trust
Step 2 - Enable Postgres database to listen to all the IP address

vi /var/lib/pgsql/data/postgresql.conf
Edit the setting as described below

listen_addresses = '*'
Step 3 - Restart your postgresql database

service postgresql restart
Note: iptables on my Linux box has been turned off. You might want to edit the iptables setting (/etc/sysconfig/iptables) to enable port 5432 for your Linux server

iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d [REMOTE MACHINE IP ADDRESS]  --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s [REMOTE MACHINE IP ADDRESS] --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

Note: Just in case "/etc/sysconfig/iptables" doesn't exists, maybe due to the first configuration, please type in command "service iptables save". This will save the rules at "/etc/sysconfig/iptables".

Monday, June 9, 2014

How to resolve the issue when your laptop can't connect to iPhone personal hotspot?

In order to resolve my laptop unable to join my iPhone personal hotspot issue, below are the steps that I personally has gone through.

Change the name of my phone
- Tap on "Setting" in your iPhone
- Tap on "General" menu
- Tap on "About" menu
- Tap on "Name" menu
- Change the name of your phone

Note: Once the name of your phone has changed, use your laptop to connect to the personal hotspot network with new name, you should be prompted to enter the personal hotspot passcode. But, you still unable to connect to the network for now.

Reset the WiFi password
- Tap on "Setting" in your iPhone
- Tap on "Personal Hotspot" menu
- Tap on "Wi-Fi Password"menu
- Key in the password for your personal hotspot
- Tap on "Done" button

Note: Reconnect your laptop to the hotspot with newly entered password, you should be able to get your laptop connected to your personal hotspot this time.


Monday, June 2, 2014

How to fix "User is not in the sudoers file. This incident will be reported" error when sudo bash is executed?

Below are the steps to grant user to sudo rights when message "[USER] is not in the sudoers file. This incident will be reported" is prompted upon "sudo bash" command is entered

- Type in "visudo" command
- Navigate to the bottom of the file, edit the file with user name as "[USER] ALL=(ALL) ALL".
- Save the sudo file



Thursday, April 24, 2014

How to configure CURL command to access website with SSL configured?

To check my server has "PHP expose_php Information Disclosure" vulnerability, basically I can check the php.ini file for "expose_php" parameter and turn it off will do. But this doesn't provide me a proof that I has fixed this issue.

I use "curl -I https://[website]" command to retrieve the header of the website to check whether PHP information is included in the header and I encountered this error because SSL is being turned on at my website.

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

To fix this problem, I download the certification provider file from "http://curl.haxx.se/ca/cacert.pem" and rename it to become "curl-ca-bundle.crt". Put this file in the same folder as your curl.exe or C:\windows\system32 folder, run "curl -I https://[website]" command again, you will be able to get details as described below
HTTP/1.1 200 OK
Date: Thu, 24 Apr 2014 07:48:22 GMT
Server: Apache/2.2.15 (Red Hat)
X-Powered-By: PHP/5.3.3
Set-Cookie: PHPSESSID=lim3eoqjrs75cnn72tk2pdp910; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: SMP_PERMAUTH=deleted; expires=Wed, 24-Apr-2013 07:48:21 GMT
Connection: close
Content-Type: text/html; charset=UTF-8

Through the details as described above, "X-Powered-By: PHP/5.3.3" prove that "expose_php" parameter has not turned off.

Tuesday, February 11, 2014

Enable SSL on WAMP server and error encountered

In order to get my WAMP server to support SSL, below are the steps to configure

1. Open httpd.conf that located at [WAMP_HOME]\bin\apache\Apache2.4.4\conf

Uncomment line as described below

LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
2. Open php.ini that located at [WAMP_HOME]\bin\php\php5.4.12

Uncomment line as described below

extension=php_openssl.dll
3. Open httpd-ssl.conf that located at [WAMP_HOME]\bin\apache\Apache2.4.4\conf\extra, edit the parameter as described below

<VirtualHost _default_:443>
#   General setup for the virtual host
DocumentRoot "c:/wamp/www"
ServerName localhost:443
ServerAdmin admin@example.com
ErrorLog "[WAMP_HOME]/logs/apache_ssl_error.log"
TransferLog "[WAMP_HOME]/logs/access_ssl.log"
</VirtualHost>
SSLCertificateFile "[CERTIFICATE_FILE]"
SSLCertificateKeyFile "[CERTIFICATE_KEY_FILE]"
SSLCertificateChainFile "[CERTIFICATE_CHAIN_FILE]"
4. Restart WAMP services, encountered the WAMP service icon is displayed as brown color and unable to start.


5. Open DOS command and change to directory [WAMP_HOME]\bin\apache\Apache2.4.4\bin. Type command to cross check the Apache configuration file

 httpd -t
Encountered error as described below is displayed

AH00526: Syntax error on line 76 of C:/wamp/bin/apache/Apache2.4.4/conf/extra/ht
tpd-ssl.conf:
SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you
need to load the appropriate socache module (mod_socache_shmcb?).
Open httpd.conf, uncomment the line as described below

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Type command to cross check the Apache configuration file

 httpd -t
Encountered error as described below is displayed

(OS 3)The system cannot find the path specified.  : AH02297: Cannot access direc
tory 'C:/Apache24/logs/' for log file 'c:/Apache24/logs/ssl_request.log' defined
 at C:/wamp/bin/apache/Apache2.4.4/conf/extra/httpd-ssl.conf:250
AH00014: Configuration check failed
Open httpd-ssl.conf, change the custom log directory to point to correct directory.

CustomLog "[WAMP_HOME]/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
Restart WAMP services, you should be able to start your Apache Web Server. Your SSL has been enabled.