Thursday, December 27, 2012

Using JSON with Jmeter

Thanks to Deepak and his post here, I could get JSON working with Jmeter which was essential for testing when the payload was a json object when sending and receiving.

For the lazier people who might not visit the link, just download the json reference implementation code, compile and make a jar and put it in the lib directory of jmeter.

Another thing, keep looking at the code in the JSON implementations for the correct signatures when writing stuff.

Good luck!

Sunday, December 23, 2012

Monday, December 17, 2012

Causal inference from dynamic systems upon events of low probability

The Old man sat on a log,
sipping from the jug, his daily quota of grog.

Down by the log,
sat the old man's dog.

The old man's dog followed a frog and pushed him into the old man's grog.

The old man's grog now had a a frog and a sly smile stuck to the old man's dog.

Wednesday, November 14, 2012

JMeter


took a while to figure out how to get around to using another one of the immensely simple yet powerful arrows from Apache's amply filled quiver.

The biggest problem with working with Jmeter was that I could not get a head-start. For the uninitiated, it is a load-testing platform developed by Apache.

To start with, ensure you download the latest source code. Fooling around with the one installed with apt-get ensures hours of frustration with no results. The results from internet searches are deceptively informative. Next, well we would prefer having our very own sampler. Why?
 //need to answer this one bro!!

Here we go. First, a little peek into the application I was trying to clobber with requests. A platform to book cabs called pyngcabs was the project. The cab booking was to be done using different clients, to start with, android.
 The Server side code was handled by a team of four writing in Spring and using the akka framework for asynchronously handling calls. This would facilitate a behaviour wherein the cab driver would be given the liberty to choose between cab requests he is given. The flow is as follows :
  1. The customer requests a cab.
  2. Filtered cabs using google maps API are shortlisted with assistance from the customer's GPS.
  3. The cabs are sent the requests.
  4. The cab drivers approve or reject requests. 
  5. The customers are notified of the cab that wishes to accept.
When performing a single test case, the main difference between android and desktop client was the ability to use the awesomely-cool server-to-client notification mechanism using GCM, which although not documented to be guaranteed to receive proved to be nearly as fast and as reliable also without the need for a long living TCP connection with heartbeat messages or other similar mechanism adopted by most notification softwares which can be plugged in with android.

Back to jmeter, so what I wanted was a mechanism to perform requests from a customer, accept/reject one of the requests and notify the same to the customer. A polling based approach which was considered a second-line of defence approach if the GCM message does not arrive till a certain time period,was the path to go with jmeter. So, first we have a HTTP POST where the customer puts in a request. This request was being done using a JSON Object. Hang on!! Load testing would mean multiple customers, multiple users, how does that work? The first thing to notice/ use is a thread group. A thread group allows running a set of threads which would perform similar operations. So, I make two thread groups, one for the customers and one for the cabs. It can be found in add--> threads --> thread groups.
The next thing to do was to add the payload type of the HTTP request we would be sending. In my case, it was a json object and I added the same.A picture, to reduce my words:
Next, to reduce redundancy of our configurations, we add common info like server address, port number and other common variables in the test plan:
//Saving the post
 Next comes the customer thread group. First, I send a HTTP request to the server that I need a cab. For each customer thread that I run, I need to send a unique customer id in the object. Here I made a little script to generate sql INSERT files with serially ordered customer and cab ids and an extension to the same script to create a comma-separated-values file, popularly called csv.

To build a HTTP request, I need to make a JSON object with a value that I fetch from the csv file. For this, we use two things, a CSV data config to read from the csv files and a beanshell pre-processor to generate the JSON object which will be the payload. First, the CSV data config:
The variable names is where we write the name which we will later use in the beanshell pre-processor. In my case, I chose the name custid which is only one var per line. If there are more than one, we need to write them all separated by commas(obviously,it is a csv).Next, we set the delimited as',' without the quotes and the sharing mode as all threads. What is really smart with jmeter is, we never told jmeter about iteration, the thread group takes care of it!! Viola! this simple GUI handles loading different user IDs. Here is the pre-processor for the payload generation:
Do note above that the CSV data config and the beanshell pre-processor are children of the http request. In the beanshell pre-processor, we use the command vars.get("custid") to get the variable custid which we set in the csv config file. We use this and other variables which I have hardcoded for convenience. Once the JSON object has been generated, we need to put it back into the variables. We do it with the command : vars.put("custRequestJSON",toSend.toString()); where the variable name is the part in the double quotes. This variable will be sent with the HTTP request. //saving the post 2 Here is a screenshot of my HTTP request:
I use the var names we set in the test plan and we send a payload as a variable with no name and the value as ${custRequestJSON} which was set in the pre-processor. Now, we are done with sending the request. We follow this with parsing the reply. The reply, in my case has a tripId which I use to query the server to ask whether the trip is scheduled. First the post-processor, to get the tripId:
Next comes polling the server with the trip id which has been put into the variable tripId. For polling, I have used a while controller which keeps running the request till it gets an object where the value for state of the trip is scheduled. I also use a constant timer to space requests so that I do not just keep polling non-stop. I would prefer a near-real scenario wherein I poll somewhere between ~3-5 seconds. Below is the while controller, where I check the value of a variable 'confirmed' and run if not 1( which I set as 0 in the post processor).
Inside this while controller, is another HTTP request, this time a HTTP GET to check the state of the trip and a post-processor to process the state of the trip. Below is the beanshell post-processor part to check the state of the resulting payload.
So, that is half the story. A similar thread group for the cabs was made, where each thread uses a HTTP GET to check for new requests, use a post-processor to randomly accept one of the results and then sends a HTTP PUT with that request id. This is accomplished by an if controller which checks the post-processor. Do let me know if I can help with any queries.

Wednesday, July 18, 2012

Dudhsagar


Packed my bags again within a month, this time off towards Dudhsagar falls, I will fill in the specifics by the weekend,
Borrowing a bag from Shivangi/Piyush's place as I did not want to carry two, I re-packed my stuff into the huge backpack and was off to the Kachiguda station to ensure my arrival before the train leaves unlike before. A quick dinner later, I was waiting on the right platform and soon found co-trip people and was delighted to know that all the tickets were booked together. Boarding on the train, I found Mr.Munni who delighted me with this interesting job profile before we called it a day. The next morning was a looong one with the train barely chugging away but the fresh and green view outside flanked by foggy hills played an ideal part in keeping the moods alive. A little burst of droplets through the window cheered us up as everyone(21?) finally pushed into a single coupe for a round of introductions before we got down finally. Some tea and group photographs later, off we went on our way, right behind the train from castlerock to stop not till we saw the falls which could be loosely translated as an ocean of milk. Wary of approaching trains from both directions on the single track, specially after out organizers Srini and Jamila warned us of hugging the tunnel walls to prevent accidents when trains pass, we kept our pace on slowly enjoying the scenery but wary of gravel and the 'unclean' areas. The tunnels kept coming, one 400 meters long, with a blind turn ensured complete darkness in the day if not for our torch lights. Light drizzles kept the temperature in control with the rising levels of humidity. It seemed like forever although we had alighted at 1:15 pm and it would have been about 3:30 when we decided to freshen up at a small stream of water followed up by Muni garu's extra lunch which fueled all three of us(Srini was the third) for the rest of the trek along the rails. As we reached the last leg, the scenery finally began to open up with trees widening enough to clear the view. Walking between a rail track and a good long drop, with no thick vegetation, occasional monkeys and amazing greenery the walk slowly started getting more and more fun. Little bits of gossip gathered by us about more than 300 people trying to stay back at Dudhsagar made us keep our fingers crossed when we finally reached the station we were to come to. Around 6pm, we crossed the Dudhsagar station arriving to a loud noise which felt like a very heavy train moving and taking forever to go ahead. Walking ahead and there was the magical display of milky water flowing in streams from above with generous force and going on with a display certain to leave the viewer spellbound. Finding one of the sheds empty, we made ourselves at home outside leaving the dirty interiors and deciding to camp in the open for the night. A while later the rest of the crew arrived flanked by a visibly angry Jamila who appeared to have a hard time controlling the ecstatic photographers from stopping to click everywhere. All set up and a great packed lunch experience thanks to everyone who got something, we got ready for a long night of little or no sleep for many. I managed an hour or two after which I finally gave up on sleep and walked out of the tarp to stare in the darkness to the unending deafening sound which resembled the sound from a television when you lose cable connection. An amazing bath in the icy cold water later we trekked up another kilometer for an amazing top to toe view of the Dudhsagar beauty after which we were back near the dudhsagar station waiting to get down at Loonda for the next train to take us back to our non-linearly noisy workplaces. I, for one, carried back enough white noise in my ears to last for a long time and amazing company which would hopefully cross ways another time soon.

Tuesday, June 26, 2012

Launar Crater


Here it came the long drawn opportunity to catch a glimpse of a world not seen daily, of scenes that do not gel in with the day, of sounds and spirit that humble one down while also showing one of the limitless possibilities, which accompany dogged pursuits. The location was not planned to be the selling product for me, but it did not disappoint. Curiosity makes novelty a precious resource of entertainment. Feats of inhuman accomplishments of achievements when seen, belittle our lifestyles, plans and our little dreams. Do visit Ellora and get a guide while you go around to ponder about the feats in an educated way. I will try to elaborate before the weekend or before I forget. So, off we went from Piyush and Shivangi's place to the station to meet new people and to a new place. The journey started with Uday and a leg-pulling extended prank and ended with a long idea evaluation pre-sleep session with Piyush. Met Aniruddh, the funny guy, and Niranjan who were carrying tents and were experienced with long treks. As expected?, the train reached late, well over and hour and a half late where the two Tavera drivers where fretting and fuming. Off we went in our A/C vehicles, sad that there was no hint of rain, looking up and looking long, playing travel games and hoping for a beautiful place. Reaching at the MTDC guest house a Lonar, where we had a 10 bed? dorm booked for the day, we freshened up and had a quick brunch-y meal before we began our trek downwards from the guest house which was uphill. The First stop was at the Daitya Sudan temple, the only temple on the top of the hill, the rest were around the lake shore and in the dense forest area. This temple denotes the victory of Lord Vishnu over the asura Launasura. Structured with seven levels of carvings and pillars adorned with intricate human figures, this neglected temple was a sight to behold. Next stop was atop the hill, near a small path which lead to a medium to steep descent of some depth. This path would lead us closer to the picturesque Lonar crater lake which was created as a result of an asteroid impact 50,000 years ago. The trek down was not long, and soon we were at the base of this huge 1.2 kilometer diameter lake with alkaline water(pH 10.7). We walked along the inner circumference edging through the camouflage and slowly inching towards the starting point, covering a series of temples on the way and wound back to the beginning eventually to have a evening lunch followed by a mango feast courtesy mango lovers group(Piyush and me). Taking off for the next location, we inched away towards the Aurangabad for the night's stay after a small feast at a Dhaba on the way. The organizers found a hotel for the night's stay and moments later, most of the guys were already snoring, well not before a short discussion on books and movies with Vijay and Aniruddh. A quick run through the morning ablutions and some misal pav later, we were back on the road. This time towards Dualatabad fort. An hour's drive? perhaps and we were already there for a quick walk to the top and back when we noticed the rest of the folks attempting adventurous routes to the top and doing it quite well too. The Daulatabad fort must have been well noted for it's high security and if security in those ages had a rating, this would surely be z+. Starting with the moat, the next series of narrow swirling path of stairs when climbed up by the enemies, would eventually find a bowl full of boiling oil to be hurled onto them. Another surprising element was the presence of a Bharath Mata temple at the fort. Another short dhaba stop for lunch later, we were at Ellora waiting for Uday who was left back when the taveras took away. Bringing him back, the best part of the journey started with Kiran getting a guide for information about the series of caves. The first few caves were built by buddhist monks and had buddha in various poses with a series of small chambers for meditation and sleeping. The USP of ellora would unmistakeably be temple no.16, the Kailashnatha temple, carved-out from the rock is a magnificent example of Indian supremacy in the earlier ages. The only thing I would regret after Ellora would be not visiting Ajantha. The visit back included a small stop for really sweet corns and then off we went for packing our bags for one last time before we set off from Jalna back to towards a day full of sedentary work.

Wednesday, June 13, 2012


I am a blue bird. No you are red fish. Bird, look I can fly. Try the water. Look you can swim. Actually, you can't breathe outside it. OMG, it's true. I think I should go into the water. I am a red fish.

Tuesday, June 05, 2012

Running the CUDA toolkit


Got it running quick thanks to the inter webs guys who worked and shared. here are resources I found useful for setup. http://www.youtube.com/watch?v=qYYnTdX6EwI http://developer.nvidia.com/cuda-downloads

Saturday, May 05, 2012

Planning


Planning, an integral part of life, wanted or unwanted, it exists some times in a short term schema and sometimes in longer ones. The question I pose is how far away from this moment should one attempt to see? The glasses turn hazy very quickly when going into the future. But, is it just me? Is everyone else just living in the moment and perhaps at times planning for a little tomorrow? The external forces that control the future seem to be hidden away preventing a change in gears. Hurtling towards something desired, how possible is it when you cannot see the throttle? You are like the audience in the stands waiting for the ball to be hit into the net. Although, it is you who is clearly the winner in your perspective, you cannot wish the ball to go in. The wait is very taxing at times as the mind wanders away and to control the mind, is not an easy feat.

Monday, April 23, 2012

The microwave


My professor at IIIT had called me up for a little chat and dinner after a long time. Hurrying through homework as much as I could, I ran off mid way towards the bus stop and was off to college. There was something about the lab I had spent a long time in. It had become cold, almost inhuman. I remember the fun we had. Looks like it is gone, even for the others. Discussing about IT, robotics, alumni and friends, we had an entertaining dinner following which, professor dropped me back to college. With the help of Manav, I moved the microwave till the gate as I waited for a rickshawaala. After some discussion and a short wait, a sharing auto walla stopped by and I sat in. Being the only passenger, I tried a lame attempt at trivial conversation when the whiff of alcohol and a diagloue, "I know you, don't be scared", left me a little shaken. Nagati babu called a friend of his and asked if he was interested in another drink, all the while assuring me that this was normal and drunk driving was not such an issue. He eventually asked me if I knew telugu, when I wondered what language were we talking in. and then it struck me. Here was a guy, who could speak good english and was by some misfortune, left to drive an auto. He unrolled his copies of certificates, a bachelor in arts from khammam and proceeded to talk about lady who said she would try to help him out. Nagati Babu, I hope that people get more opportunities in a country/world that is burying most people who do not fit into a scheme of things planned by a few or perhaps just chance. Good Luck dear sir, while I walk back in deep thought over the petty issues that scare the wits out of me while people fight for survival. I leave my social life unattended, not because I do not want to, but because I cannot afford to. I am able to see light and I wish to follow it.

Thursday, April 19, 2012

What cannot be undone


by sheer force of will, change it is said, can be achieved. The clay that can be moulded by will, however is not everything. At least not from where I perceive. An intense feeling of disbelief sets in when the mind attempts to reject it's own hypothesis of reality. I understand, I am but one of the people who feel the limits of life. There would be people who would give away anything to stretch the limit. And then come the ashes. The uncut edges from a node pulled away from the graph. These edges keep dangling and dangling edges, still lend support to the unrealistic broken mind. Akin to slow poison, slow numbing of thoughts also set in. The realisation of how big the world is, how small one's existence remains and how fast we hurtle into a different time. There are the obvious questions that one would ask, trying to put oneself in another's boots, trying to imagine. Imagine and believe, that imagination can be a way of believing and believing a way of living. I fight with myself everyday, fight away precious moments, dismissing them from my presence in the attempt to nab an elusive species of success whose identity I do not recollect. Yet, I persist. Amid the debris, I search for the building. One is never convinced of the limits of his powers. Willing to imagine but wanting to not. This powerful instrument of thought is what sets us apart, but I fear it often becomes the one to cause what cannot be told. I wish to look through the eyes of free men(as kwisatz says), look through their lives and through them I look back at me and see myself for what I am, for once without a preconceived notion.

Wednesday, February 22, 2012

Grace Hopper, conceptualized COBOL http://en.wikipedia.org/wiki/Grace_Hopper John Backus at IBM, was the guy behind FORTRAN. Do look up Ada Lovelace and Charles Babbage too!! Thanks David Evans

Monday, February 13, 2012

bombay blues

Trotting towards the school bus, basket in hand and a rain coat covering some of the body, while I use my yellow 'robot' umbrella, I splash water with every step, having to stop regularly and empty my gum boots. As the bus honks away asking people to hurry, I get in and take my favorite seat. The seat above the rear tyres. Keeping the window open and letting some drops come in as the bus moves, I had to keep cleaning my glasses from time to time until my kerchief was too wet. Off went the bus up towards the hilltop, winding ways going on and on. Rainy days meant prayers in class. The class rooms were damp, dark and extremely moist. The tubelights were needed the whole day. The left corner of the room was reserved to hang the raincoats and the umbrellas. That is where my robot umbrella stood shining among sober ones. I remember the P.T. An activity every little kid with spectacles would dread. Sometimes they break, sometimes they are made to break and now they do not want it. However, the PT Sir, is bound to have other plans for you. I loved football, except when the ball started flying towards my head. So, I would just slink away and move towards the edge of the ground where we had torn the fence. Freedom. I could walk in and out of school. I would catch those shiny little pink crabs and make them fight each other. At times, I would gather a zoo of different species just to see which one hated which one and even try aquatic fights by putting them into a polythene cover. Staring at the thousands of dragon flies, I would catch one of them with some help. Tying a string around them and around the goal post, I would see the helpless insect fighting it's way and I would think I am going through the same. Post-school, I used to have a lot of outdoor time. The then famous, hide-n-seek and it's variants with some roughness involved. Trying to find a place to hide, I hid behind a mound of bricks and to my surprise I found a kitten, perhaps a week old and injured struggling to move. I believe it was because it was dirty. Stalling the game, I took it back to my apartment and gave it a luxurious bath, perhaps making it worse. I would go to Anoop's place where we would play board games. He was the only other kid who I knew who would travel in my bus. I remember the days where we would fight for our friends, but then, sometimes fight with them too. This was the place I struggled initially. My mother helped me through by learning hindi and then teaching me so that I can manage easily. That was 1995. I am now older by seventeen years. The memories hit back when they find time to. And they did now. Those little moments, the adventure, the innocence, all in all, it was fun.

Tuesday, January 31, 2012

Another temp tech post

github AFPlayer? make sure you export PATH=$NDK:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH and also android update project -t 1/2/3 -p . -s

Friday, January 27, 2012

Unfinished blog on youtube gdata API usage/android media framework

text and experience go here on Jan 27th. ------------------------------------------- What is OpenCore?(https://github.com/android/platform_external_opencore) is it used now? no What is StageFright?(http://freepine.blogspot.com/2010/01/overview-of-stagefrighter-player.html) What is OpenMax? :O 3 layers : Application, integration and development H/W video codec or S/W video codec? http://omxil.sourceforge.net/index.html elinux.org/images/5/52/Elc2011_garcia.pdf Streaming vs Progressive Downloading/Streaming http://www.streamingmedia.com/Articles/ReadArticle.aspx?ArticleID=64573&PageNum=1 http://en.wikipedia.org/wiki/Streaming_media http://en.wikipedia.org/wiki/Progressive_download http://vipingupta.blog.com/2011/05/13/youtube-videos-streaming-or-progressive/

Sunday, January 15, 2012

Time for change : old memories

A gateway to an ("to-be-" no more)engineer's / to be postgrad's misadventures and daily encounters written down in the worst possible, dry, unformatted form and kept away from the sight of people, known and unknown. EDIT As reality hits in the face, still reeling from the blow, living a life that excludes defeat and disappointment as an inherent attribute seems like a distant voice which is, but virtual.