Tuesday, 16 April 2013

Significance of Host File in Windows

What is host file?

Almost every operating system that communicates via TCP/IP, the standard of communication on the Internet, has a file called the HOSTS file. This file allows you to create mappings between domain names and IP addresses.

You can command your machine to contact the only a particular machine for replies.

How to set your local machine to contact only a particular machine for the replies with the host file on Windows?

1.Click on Win+R or Start -> run and type drivers as below:

1

2. Goto the “etc” directory and open the hosts file

3

3. Add the entries in the following format and save it

{IP}         {Domain Name}

Example:

127.0.0.1              localhost

10.90.112.101     domainname

5

Note:

You must have the administrative rights to modify/add the entries in hosts file.

4. After saved the above host entries, whenever you gave the request the particular domain configured in the hosts file then response will come directly from the ip which we configured(example: 10.90.112.101)

5. If you need to host entries, just delete the line which you added or insert “#” in front of the line as below

#10.90.112.101  domainname

Thursday, 11 April 2013

iOS UI Automation






Introduction / Overview

iPhone apps are developed using native or native-hybrid bridge.

native-hybrid : The datas are rendered in HTML and the native actions are performed using js callbacks

Automation testing framework for these applications is mainly to,

  • Reduce the manual testing effort

  • Reduce the testing cycles involved for any changes to the application

  • Provide maximum test coverage


images



Why UIAutomation ?


Selenium Automation

Using selenium the basic level functionalities like tapping, swiping could not be done in the iPhone app. so,selenium could not be an option to automate the iPhone app
Jasmine framework


  •     Jasmine is a BDD (Behavior Driven Development) framework.

  •     Jasmine is mainly used for Unit testing

  •     More or less jasmine is same as tuneup framework

  •    Jasmine provides good reporting structure

  •    Reports can be in xml or html format


UI Automation + tuneup.js


  •     It is the Apple's inbuilt Automation testing framework.

  •     It is highly stable and also reliable testing framework.

  •     It uses javascript to automate the testcases.

  •     Automation can also be performed in the specified devices

  •     It can also be accessible from command line so that we can also integrate this with Hudson

  •     Considering its salient features,simplicity UIAutomation is preferred for automating the test cases over other testing frameworks


Tools used



  •      Xcode IDE (Version 4.X and above)

  •      Instruments


Instruments Tool

Instruments is a tool for UIAutomation provided by Xcode. Instruments provides us the record and playback feature which will be very useful in doing automation

It can be used to collect data about the performance and behavior of one or more processes on the system and track that data over time.
Test Case Log

The test case when executed on the iOS application target, using Instruments,

The Instruments console will show the details of,

Log Message - What Test case is being executed

Log Type - Test case is Pass or Fail.

If a test case fails, it would display the

  •  Element tree in the failed page meaning, what are the UI elements present in the current page.

  •   Also the screen shot of the page in which error occured.


Automation Framework


Tune-up  is the framework used for automation

Tune-up is a collection of JavaScript utilities that builds upon and improves the UIAutomation library provided by Apple for testing iOS applications via Instruments.
You can find more details about the Tune-up framework from here:https://github.com/alexvollmer/tuneup_js/blob/master/README.md
an also in http://alexvollmer.com/posts/2010/07/03/working-with-uiautomation/

Test Structure in Tune-up


To create a test case, use the test() function, which takes the name of the test case as a string, and a function. The function will be given a UIATarget instance and a UIAApplication instance.

For example:


test("Sign In to the app", function(target, app) {

// The target and app arguments are root elements

/* (i.e) The element structure of every element in the app goes in this way
UIATarget.localTarget().frontMostApp().(position of the particular element in the view)
for reusing UIATarget.localTarget().frontMostApp() we store it in target,app   */

// The UIATarget is the primary portal into the application running on the device or simulator

// Steps for Sign-in

});

test("Sign out from the app", function(target, app) {

// Steps for Sign-out

});





Integrating with the Project



MakeFile configuration:


Configure the MakeFile which is in the project home , with the command lines which is used to build the project and Launch the instrument.

Add the following configuration,

1.TRACE_PATH : Location to store the .trace file, which will create after the execution of test script using instruments.

2.TEMPLATE_PATH : Location where the test case TemplateTrace files are stored, which is created from the instruments by saving the testSuite script as Template.

3.uiautomation :

Shell command which

  • Builds the project ,

  • Executes the test case script by launching the Instruments tool.

  • And this executes the test Suite which has the entire flow.


Ex.
/* Specify the Trace path, Template path and App path */












TRACE_PATH = TraceDocument/UIAutomationTrace

TEMPLATE_PATH = Test/Automation/Resources/TestCaseTemplates

APP_PATH = /Users/${projectpath}//Products/Debug-iphonesimulator/sample.app





/* Shell commands to Run the Test cases */












uiautomation:


    xcodebuild -workspace sample.xcworkspace -scheme Release -sdk iphonesimulator5.0


    instruments -t ${TEMPLATE_PATH}/testSuiteTemplate.tracetemplate -D ${TRACE_PATH} ${APP_PATH}





Running the Automation Script


Command to run automation from Terminal using the MakeFile ,

In Terminal ,Move to the directory where the ‘.xcodeproj‘ file resides

And execute the following Command,











make uiautomation





Additional Info about Shell Commands


Write a Shell Script to execute the following commands

1) Building the Project


At first the Project should be build through ‘xcodebuild’ command

xcodebuild:

This command is used to build the xcode project.

Xcodebuild Usage

Xcodebuild -- workspace [PROJECT-WORKSPACE] --scheme [SCHEME-NAME] --sdk [DEVICE/SIMULATOR NAME]




















Option Description
-- workspacePROJECT-WORKSPACE
Name of the Project file(ex sample.xcworkspace)
--schemeSCHEME-NAME
Name of the Sheme
--sdkSpecify the device/simulator name(ex: simulator name – iPhoneSimulator5.0)


Move to the directory where the ‘.xcodeproj‘ file resides and then the command Should be executed

Ex:

Move to the directory where the project resides

Execute the xcodebuild command

$bash: xcodebuild -workspace sample.xcworkspace -scheme Release -sdk iphonesimulator5.0

This command will build the project with configuration as release and sdk as iphone simulator5.0

2) Launching the Instruments tool


Execute a command to launch the Instrument with the latest build

This command executes the saved ‘.tracetemplate’ file and saves the result in the path specified
Instruments Command Usage

instruments [-t template] [-d document] [-w device] [-p pid] | [application [-e variable value ]]




































Options                                                 Description
-t     templateFile name of type ‘ .tracetemplate ‘ with the path of  the file location
-s     Show list of known templates and exit
-d     documentThe path to save the trace document data to (This may already exist, in which case
a new Run will be added)
-p     pidThe ID of the process to attach to
application     The path to the application or command to launch
-w     hardware deviceThe identifier of the hardware to target
-e     variable valueAn environment variable setting (You may specify more than one)


Ex :

       instruments -t $TEMPLATE_PATH -D $TRACE_PATH  $APP_PATH
























OptionDescriptionExample
TEMPLATE_PATHTemplate path is the path of the saved template file$PROJECT_HOME/Test/Automation/Resources/TestCaseTemplates/testSuite.tracetemplate
TRACE_PATHIt is the path where the .trace will be saved after executing the automation$PROJECT_HOME/TraceDocument/UIAutomationTrace
APP_PATHIt is the path of the latest build of the APP~/Library/Developer/Xcode/DerivedData/sample-gxfepasnjxtmhjcevjkpyunezjca/Build/Products/Debug-iphonesimulator/sample.app


Note: After the execution of the xcodebuild command the app will be build in a directory; APP_PATH should have that directory path

The Build path can be customized. To change the app build path, In  the Xcode Choose the Xcode option int the Menu bar choose Preferences – Locations and then give the custom location in the derived data field

On executing this command, the script loaded in the .tracetemplate file will get executed on the specified simulator/device and stores the .trace file in the specified path



Friday, 5 April 2013

Light smart by going green

I was in dilemma, when I started to write this blog. Because the content that am going to narrate here is a well known fact.  But still, a recent incident has urged me post this blog.

How many of us have cursed the Tamil Nadu or Indian government for inconsistent power supply. We blame political parties, politicians and even God at times for lack of rain which has a direct influence in power production.  But we fail to think that there is only few that can be done by the government and we as a citizen of this country need to take responsibility and do some possible deed.

There is a simple step that you can contribute to nature in two ways, one by consuming less energy and another by polluting the environment less.

Its nothing but replacing incandescent bulbs with CFL bulbs. How this will help us ???.

DSC_0285-1

A CFL consumes 25% less energy when compared to an incandescent bulb. This saves electricity by 70%. An incandescent bulb glowing for 1 hr consumes 60 watts, whereas a CFL glowing for 1 hour consumes 10 watts only. You will get the same glow from both these bulbs. We save 50 Watts of energy per hour, if we do a simple change.  This is how we consume less energy.

"We never know the worth of water till the well is dry".  ~Thomas Fuller,Gnomologia. Same is the case for power we waste most of the time without knowing its value. 

On the other side of the story, If we light an incandescent lamp for one hour it produces 5 kg of co2, which is an endanger for the environment. This is equal to riding a bike for 8 km. So the first immediate step we need to do is to change all the incandescent bulb with CFL wherever  we could.  So that you can contribute something valuable to the environment and to the nation by saving a decent amount of electricity.

You may have lot of questions that, who is buying incandescent these days and where will be these kind of bulbs found now a days. Yes, we have many people around who are unaware of it. The reason why am writing this here is, one of my well educated friend has recently bought a incandescent bulb to our home.  That's the time I have decided to post this blog and create awareness about the same.  You can find these kind of bulbs in rural areas mostly than the urban. It is not uncommon to find these kind of bulb in rural areas.

If we change every such Bulb in our state(Tamil Nadu), we can get an extra 15 mins of power for each day in our state. We can do this instead blaming our government or politicians. If we could make it happen and if we do the same in all states of our country, we could save a lot of power and that can be used for many other industrialization purposes.

I thought of this blog a long time back and drafted this, But I need to be a "Doer before a Sayer".  It took a months time for me to change all incandescent lamps wherever I could (In my home, My Grandma's home, Our current rented home in Chennai). Totally 5 is what I have changed so far.  Even its a little am happy that I have contributed something to the environment and did a good deed as a citizen to my country.

Little progress together makes a brighter and greener future. I want my friends to do and Share the same.

Lets create a better future together.....

Tuesday, 26 March 2013

GenericOptionsParser, Tool, and ToolRunner for running Hadoop Job

Hadoop comes with a few helper classes for making it easier to run jobs from the command line. GenericOptionsParser is a class that interprets common Hadoop command-line options and sets them on a Configuration object for your application to use as desired. You don’t usually use GenericOptionsParser directly, as it’s more convenient to implement the Tool interface and run your application with the ToolRunner, which uses GenericOptionsParser internally:
public interface Tool extends Configurable {
int run(String [] args) throws Exception;
}

Below example shows a very simple implementation of Tool, for running the Hadoop Map Reduce Job.
public class WordCountConfigured extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
Configuration conf = getConf();

return 0;
}
}
public static void main(String[] args) throws Exception {
int exitCode = ToolRunner.run(new WordCountConfigured(), args);
System.exit(exitCode);
}

We make WordCountConfigured a subclass of Configured, which is an implementation of the Configurable interface. All implementations of Tool need to implement Configurable (since Tool extends it), and subclassing Configured is often the easiest way to achieve this. The run() method obtains the Configuration using Configurable’s getConf() method, and then iterates over it, printing each property to standard output.

WordCountConfigured’s main() method does not invoke its own run() method directly. Instead, we call ToolRunner’s static run() method, which takes care of creating a Configuration object for the Tool, before calling its run() method. ToolRunner also uses a GenericOptionsParser to pick up any standard options specified on the command line, and set them on the Configuration instance. We can see the effect of picking up the properties specified in conf/hadoop-localhost.xml by running the following command:
hadoop WordCountConfigured -conf conf/hadoop-localhost.xml -D mapred.job.tracker=localhost:10011 -D mapred.reduce.tasks=n

Options specified with -D take priority over properties from the configuration files. This is very useful: you can put defaults into configuration files, and then override them with the -D option as needed. A common example of this is setting the number of reducers for a MapReduce job via -D mapred.reduce.tasks=n. This will override the number of reducers set on the cluster, or if set in any client-side configuration files. The other options that GenericOptionsParser and ToolRunner support are listed in Table.

GenericOptionsParser and ToolRunner option Description



































Property>Description
-D property=valueSets the given Hadoop configuration property to the given value. Overrides any default or site properties in the configuration, and any properties set via the -conf option.
-conf filename ...Adds the given files to the list of resources in the configuration. This is a convenient way to set site properties, or to set a number of properties at once.
-fs uriSets the default filesystem to the given URI. Shortcut for -D fs.default.name=uri
-jt host:portSets the jobtracker to the given host and port. Shortcut for -D mapred.job.tracker=host:port
-files file1,file2,...Copies the specified files from the local filesystem (or any filesystem if a scheme is specified) to the shared filesystem used by the jobtracker (usually HDFS) and makes them available to MapReduce programs in the task’s working directory.
-archives archive1,archive2,...Copies the specified archives from the local filesystem (or any filesystem if a scheme is
specified) to the shared filesystem used by the jobtracker (usually HDFS), unarchives them, and makes them available to MapReduce programs in the task’s working directory.
-libjars jar1,jar2,...Copies the specified JAR files from the local filesystem (or any filesystem if a scheme is specified) to the shared filesystem used by the jobtracker (usually HDFS), and adds them to the MapReduce task’s classpath. This option is a useful way of shipping JAR files that a job is dependent on

Monday, 25 March 2013

Apache Ant - Tutorial

1. Build Tools
Build tools are used to automate the repetitive task like compiling source code, generating documentation, running tests, uilding the jar and so on. Some of the well known build tools are Apache Ant, Maven.


2. Overview of Ant

Ant(Another Neat Tool) is the java library and mostly used to building and deploying the java application. Ant provides the built-in tools to compile, build, test and packing the java application. Ant builds are based on three blocks.
Tasks: Task is the unit of work. For example compile, packing.
Targets: Targets can be invoked via Ant.
Extension Points: Extension points are same as targets and it won't any operation and just coordinate the targets.

3. Building the Java Application: Using Apache Ant

Create the build.xml(not as same) in your project root directory. Given below is the sample build xml(self explanatory - comments inline)
<?xml version="1.0" ?>
<project name="nRelate Analytics" >
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="dist.dir" location="dist" />
<property name="lib.dir" location="lib" />

<!--
Create a classpath container which can be later used in the ant task
-->
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>

<!-- Deletes the existing build, dist directory-->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>

<!-- Creates the build, dist directory-->
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
</target>

<!-- Compiles the java code (including the usage of library -->
<target name="compile" depends="clean, makedir">
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="build.classpath">
</javac>
</target>

<!--Creates the deployable jar file -->
<target name="createjar" depends="compile">
<jar destfile="${dist.dir}LogNormalizer.jar" basedir="${build.dir}">
<!-- Adding to Manifest file, from which class to start exceution -->
<manifest>
<attribute name="Main-Class" value="test.MainClass" />
</manifest>
</jar>
</target>
</project>

4) Run your Ant build from the command line

Open a command line and switch to your project directory. Type in the following commands.
# Run the build
ant -f build.xml
# build.xml is default you can also use
ant
Specify the target as below.
#Run the build.xml by specifying the target.
ant -f build.xml createjar

The build should finish successfully and generate the build artifacts under the dist directory.

Subscribe to get updates on this article.

Friday, 22 March 2013

My Personal collections

This is my personal collection of books that I wish to read and also books that I have accomplished so far. I firmly believe in  Thomas Jefferson's quote - "A life without a book is meaningless". I want my life to be meaningful and so here comes this blog. I will keep on updating this list and also welcome people who suggest me some good books and give me some feedback.

Drowned ...


Two States - Chetan bhagat


2-states-cover

This is beautiful love story between an IIM guy from Delhi and a girl from Tamil nadu. This is how they fall in love and carrying it till their marriage. Over coming their problems of being from different caste, culture, language and family back ground. This is the author's own story. A good one to read.






One night at the call center - Chetan bhagat


one_night_@_the_call_centre Another drama from Chetan, where the entire book is about the story that happens over a night. This explains the life at call center and along with a love drama in between. A kind of interesting, though it doesn't sound as two states.








Who will cry when you die - Robin Sharma


Who_will_cry_when_you_die

Author Robin speaks about life's simple things which will make life happier. This will be a collection of different lessons where he touch base all areas from being kind to others, mental and physical fitness, going green, being positive and lot more.








The Greatness guide - Robin Sharma


the-greatness-guide

Robin explains how one should lead his life both as a leader and a follower. He has embedded great sayings of Legends and  proverbs that will sting to your mind. He simply states that , "the first point of how a world sees you, should begin from you.







Five point someone - Chetan bhagat


5_Point_Someone This another real life incident happened to author in IIT. A mix of fun and love in his college days. Well written in simple language as like his other books. Once you start, you can never close without finishing it.






What young India Wants - Chetan Bhagat


ChetanBhagatWhatYoungIndiaWants

Its the collection of essays and articles written by the author in various newspapers in the north. He has also some good letters written by him to Political leaders. Most of the incidents in this book speaks about things that cling around northern part of India.








The Alchemist - Paul Coelho


The Alchemist

This is a story where the author speaks about treasure, desert, travel and love. Its about a young boy who risks his life in fulfilling his destiny. He insists that "“If you really desire to achieve something, the whole world conspires in helping you to achieve it”.








Revolution 2020 - Chetan Bhagat


200px-Revolution2020_Love_Corruption_Ambition

A triangle love story between three. One guy who failed to IIT but becoming a director of an Engineering college. Another guy who cracked the exams to get in to the best college and at last ended up in running his own news paper publication who is willing to correct the corrupted nation with his thoughts and broad mind. The final touch of whom the girl will be married to is an interesting ending.







Kane and Abel - Jeffrey Archer


kane-and-abel


This is one of the best books that I have ever read. It explains life of 2 persons from their birth to death. The journey they went through, difficulties in bringing themselves up their life. I highly recommend this book for anyone. The author has kept his nerve through out the story. I have decided to read the few other books of this author. He deserves the title to be one of the best authors in the world.









To be drowned....


A Thousand Splendid Suns -  Khaled Hosseini


splendid suns

Wednesday, 20 March 2013

Google Launches Realtime API for Google Drive

Google has launched a Realtime API for Google Drive, enabling developers to create apps that can tap into Drive's real-time editing capabilities.

The API provides developers with collaborative versions of data objects such as maps, lists, strings, and JSON values, which are automatically synchronized, and all modifications to them are stored. Developers can create apps that read from and write to these objects like any local object.

If the basic set of objects isn't enough, developers can also create custom objects and references, which includes trees and arbitrary graph structures.

interested developers can check out the Google Drive Realtime API technical documentation here.

 

Source: Mashable.com