Posts

Showing posts from 2018

Mac OS Keyboard shortcuts for developers

As a developer, when I switched from Windows & Ubuntu OS to Mac OS, I struggled a lot to discover the shortcuts. The shortcuts are not very obvious as in Windows or Ubuntu. Hence I have compiled a list of shortcuts which I found very handy in Mac OS. General: Cmd + Space -> Spotlight search. Search/Open any app or files Cmd + Up Arrow -> Home key / Move to the start of the file Cmd + Down Arrow -> End key / Move to the end of the file Cmd + Left Arrow -> Go to start of current line Cmd + Right Arrow -> Go to end of current line Cmd + W -> Close current window or tab Cmd + Q -> Quit or close the application Cmd + Option + W -> Close all windows Cmd + M -> Minimise current window to the dock Cmd + H -> Minimise current window Cmd + Option + H -> Minimise all other application's windows Cmd + Tab -> Toggle between different applications Cmd + ` -> Toggle between windows in same application Cmd + Alt + D -> Show or Hide Do...

Bash Script Loops and Conditional statement examples

loops.sh conditionals.sh Sourcing functions in bash script

Bash Script Example

calculate.sh

Practical rsync command and options

Blazemeter Taurus load testing and offline jmeter html report

Recently I had used Blazemeter Taurus for load testing my application and I was quiet impressed with the features offered by Taurus. It is not a new tool by itself, instead it makes use of existing load testing tools like Apache JMeter or Gatling. However it offers enough abstraction to users from the underlying load testing tool using YAML configuration files. Advantages of using Taurus over JMeter 1) JMeter uses single jmx xml file to simulate the load test, which makes it hard for more than one person to work on the single jmx file and resolving conflicts might turn tricky 2) Easy to review changes made to the Taurus YAML file on commit by commit basis to understand the changes made to the load testing. This is especially handy during pull request process 3) Easy to run in non-interactive command line mode, so easy to integrate with CI tools 4) Official docker image provided by Blazemeter Taurus, which required minimal setup to run load test in development machines and also ...

JSON with curl and jq

This blog post captures some quick commands to deal with JSON from servers (Http APIs) using curl and jq command line tools About Jq: https://stedolan.github.io/jq/ Install jq: Mac: brew install jq Ubuntu or Debian: sudo apt-get install jq Sample JSON content: Assume the following JSON content will be returned from  URL http://api.example.com/some-json-content {     "user_name": "User 123",     "some_other_field": {         "sub_field": "sub_value"     },     "array_field": [         {             "field1": "value1",             "field2": "value2"         },         {             "field1": "value3",             "field2": "value4"         }     ] } UR...

Essential Heroku Commands for Java (Spring Boot) developers

This blog post captures the command used to create and configure java apps or spring boot apps deployed to Heroku Cloud. I use these commands in CI/CD deployment steps for continuous delivery and also to access the application's information from my local development machine. These commands are tested with Heroku Client version: heroku/7.0.33 darwin-x64 node-v10.0.0 View help heroku help Login/Logout to heroku With email and password heroku auth:login heroku auth:whoami heroku auth:logout Login/Logout to heroku With token # set HEROKU_API_KEY environment variable to login export HEROKU_API_KEY=<<API Key from https://dashboard.heroku.com/account>> heroku auth:whoami # unset HEROKU_API_KEY environment variable to logout unset HEROKU_API_KEY # clear the history to clear the API Key history -cw && cat /dev/null > ~/.bash_history Show available regions for deployment heroku regions Create an application heroku apps:create --app app-...

Git bundle and clone as a new repository

The following steps/commands will help to clone a local git repository using git bundle. This is useful when cloning a sample repository or sharing the repository to a peer through email or other channels where git pull/push is not feasible Navigate to existing repository cd ~/source_code/my_existing_repository Create a git bundle from master branch of an existing repository git bundle create /tmp/my_existing_repository_master.bundle master Create a new repository from the bundle git clone -b master /tmp/my_existing_repository_master.bundle ~/source_code/my_new_repository Navigate to the new repository cd ~/source_code/my_new_repository Verify the logs git --no-pager log --max-count 3 Cleanup the pre-existing origin  # verify the pre-existing origin before deleting git remote -v # delete the pre-existing origin git remote rm origin # verify remotes after deleting git remote -v Using git archive There is a git archive command which exports the files i...

Feature Toggle Integration Testing with Spring Boot

This blog explains tries to explain the following concepts: What is a feature toggle? Use case of feature toggle in real life Importance of integration testing with feature on and off What is a feature toggle? The mechanism of controlling the application's behaviour or feature during runtime using an external configuration or property is called feature toggle. Use case of feature toggle in real life Imagine you are a developer working for a telecom provider. Every time a new product or phone is launched by manufacturers, the products should not be displayed in the telecom provider's website, until it is officially launched by the manufacturers like Apple or Google. However as a telecom provider, your organisation should be able to sell or receive orders for the newly launched phones, immediately after the launch of the new phones. Hence, feature toggle becomes quite handy, where the application can be developed with new features targeting the sales of un-lau...

Essential Gradle Commands

I use some of the gradle commands everyday in my project and many times I had to randomly search in the internet (as I don't remember these commands by heart). This article is for my personal reference, so that I don't have to search it in random places. These commands include running tests, generating binaries, filtering tests, changing property values during runtime, listing available tasks for a project, executing task in a subproject, printing dependencies information etc.. If you have reached this paragraph and your are still interested in reading further down, then happy reading.. :) For developers working on Windows platform, please replace './gradlew' with gradlew.bat in the following commands General gradle tasks List available projects ./gradlew projects List available properties ./gradlew properties List available tasks for root project and sub-project ./gradlew tasks :SomeProject:tasks --all Build a project Clean the buil...

JUnit's stopwatch to capture time taken per integration test in csv file

I was looking to improve my integration test suite, which contains large number of integration test (more than 900 test cases). My immediate focus was to tackle the slowest running tests in my test suite. TestNG reports provide the information of slowest running test out of the box, however my project was using JUnit 4. Being a lazy developer, I didn't want to migrate my entire test suite to TestNG in order to get reports about slowest running test. Hence I was looking at other options available in JUnit test framework. JUnit offers a Rule called stopwatch, which notifies us the time taken to complete each test as callback methods. However, most of the examples showed how to print the information on console or some logger. Printing on the console or logger is particularly not very helpful, as it doesn't allow us to analyse the data in an easy way. Hence I had created a custom stopwatch rule which extends JUnit's stopwatch rule and capture the information provided by ...

Headless Web Driver testing with Chrome on Headless Servers

Recently, I had a task to migrate the WebDriver based test cases from PhantomJs to Chrome headless and the tests were running on headless CI docker containers. The migration was not a smooth journey as I had anticipated and this article is based on my learning experience during this migration. PhantomJs was widely used for headless testing and now it has been unofficially abandoned by the PhantomJs team. So we had to switch to some other browser which is under active development and also which supports headless mode. The choice was Google Chrome (or Chromium). As more and more organizations move towards cloud containers or virtual machines to run their CI build, it is quite important to have the ability to run your WebDriver based tests in headless mode. My key learnings from this migration: Avoid using Xvfb (Virtual Frame Buffer) as virtual display when your test suite has hundreds of test cases.  Xvfb crashes in the middle of the test for unknown reason and Chrome fail...

Import Personal Information Exchange (.pfx or .p12) file on Mac

Steps to import Personal Information Exchange (.pfx or .p12) file on Mac using Keychain Access application Goto Keychain Access  application Click on System  Keychains Select File  menu -> Import Items.. Select downloaded_file.p12  file in the dialog box Enter your login password if prompted Enter the keystore password if prompted After successful import, you should see a new certificate Double click on the newly imported certificate Click the Trust  arrow to expand the trust attributes Change the value of When using this certificate:  to Always Trust Close the certificate dialog box and enter login password if prompted A blue '+' symbol should appear on the newly imported certificate, which means the certificate is imported and trusted

How to add additional dns host mapping to localhost

Why we need additional dns host mapping? In enterprise environments, some applications can serve into multiple domains. For example, same running instance(s) can be mapped for guest.example.com and customer.example.com and the functionality of the application could vary based on the domain being used by the user. Lets say, customer.example.com will need authentication, authorization and may contain premium features for customers, whereas guest.example.com will contain limited features. To test this type of application in local, which contains domain aware functionalities, we need to map additional routes in the OS host file to map these domains to localhost. And then the tests can make use of these domains to test the application running in local development machine. For Mac: Add the following lines to /private/etc/hosts file using vi or nano or any text editor application. Might need to use sudo if required. 127.0.0.1       local.example.com ...

Installing chromedriver for Selenium WebDriver testing

For Mac: Using homebrew: brew install --cask chromedriver chromedriver --version Using manual steps: Add the following lines to ~./bash_profile  or ~/.zprofile using vi or nano or any text editor # Installing Chrome Driver export CHROME_DRIVER_HOME=/downloaded_and_extracted_location/chrome_driver_2.33 export PATH=$CHROME_DRIVER_HOME:$PATH Verify the installation by executing the following command in Terminal chromedriver --version For Windows: Add c: \downloaded_and_extracted_location\chrome_driver_2.33\chromedriver to PATH environment variable (most probably through My Computer). Verify the installation by executing the following command in Command Prompt chromedriver --version For Ubuntu (Linux): sudo apt-get install chromium-browser sudo apt-get install chromium-chromedriver sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/local/bin/chromedriver chromium-browser --version chromedriver --version For Debian (Linux): s...