goldb.org home

AS OF MAY 2008, THIS BLOG IS NO LONGER BEING UPDATED.
Visit the new blog at: http://coreygoldberg.blogspot.com



 Monday, April 14, 2008

Pylot 1.1 - New Release With Test Case Recorder

New Pylot 1.1 release is available
Visit: www.pylot.org/download.html

It contains some minor code cleanup and a new test case recorder contributed by David Solomon. The recorder works with Windows and IE only.

It is a script that launches your web browser and records HTTP requests as you navigate. While it records, it prints Pylot's XML test cases. The test cases are printed to STDOUT, so just redirect it to a file and you will have a valid testcases.xml file to use as Pylot input.

The pylot_recorder script is included in the lib directory of Pylot 1.1.

View the recorder's source code from the SVN trunk:
http://code.google.com/p/pylt/source/browse/trunk/lib/pylot_recorder.py

(It can't handle some complex scenarios, but is useful for recording simple GET and POST requests from web applications)

#    Comments [4] |
 Thursday, April 10, 2008

Split A List Into Roughly Equal Sized Pieces

The Python Cookbook has a recipe for splitting a list into roughly equal-sized pieces:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425397

In the comments, there are several alterate implementations. Sebastian Hempel has an interesting take on it using slicing for the calculation of the list lengths. It basically looks like this:

def split_seq(seq, num_pieces):
    start = 0
    for i in xrange(num_pieces):
        stop = start + len(seq[i::num_pieces])
        yield seq[start:stop]
        start = stop

This version of the function distributes the remaindered items evenly over the first few splits.

Example Usage:

seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

for seq in split_seq(seq, 3):
    print seq
#    Comments [2] |
 Wednesday, April 09, 2008

Python - Host/Device Ping Utility for Windows

This script uses your system's ping utility to send an ICMP ECHO_REQUEST to a list of hosts or devices. It uses a separate thread to ping each host/device. This can be useful for measuring network latency and verifying hosts are alive.

Check out more info here: http://www.goldb.org/python_pinger.html


#!/usr/bin/env python

import re
from subprocess import Popen, PIPE
from threading import Thread


class Pinger(object):
    def __init__(self, hosts):
        for host in hosts:
            pa = PingAgent(host)
            pa.start()
        
class PingAgent(Thread):
    def __init__(self, host):
        Thread.__init__(self)        
        self.host = host

    def run(self):
        p = Popen('ping -n 1 ' + self.host, stdout=PIPE)
        m = re.search('Average = (.*)ms', p.stdout.read())
        if m: print 'Round Trip Time: %s ms -' % m.group(1), self.host
        else: print 'Error: Invalid Response -', self.host
              
                             
if __name__ == '__main__':
    hosts = [
        'www.pylot.org',
        'www.goldb.org',
        'www.google.com',
        'www.this_one_wont_work.com'
       ]
    Pinger(hosts)

Output:

Round Trip Time: 14 ms - www.yahoo.com
Round Trip Time: 17 ms - www.goldb.org
Round Trip Time: 30 ms - www.google.com
Round Trip Time: 82 ms - www.pylot.org
Error: Invalid Response - www.this_one_wont_work.com

Note: I only tested this on Windows. To run on other systems, it would only require a one-line change.

#    Comments [3] |
 Thursday, April 03, 2008

Python - Script - Which Webserver Does That Site Run?

You can use this little Python function to see what type of web server a site is running.  All it does is send an HTTP request to the host and reads the 'server' header in the response.


import httplib

def get_server_type(host):
    conn = httplib.HTTPConnection(host)
    conn.request('GET', '/')
    resp = conn.getresponse()
    return resp.getheader('server')


print get_server_type('www.pylot.org')
print get_server_type('www.techcrunch.com')

Output:

lighttpd/1.4.19
Apache/2.0.52


Note: This doesn't work for all sites

#    Comments [7] |
 Monday, March 31, 2008

Automated Test Tool Vendors Continue To Get Gobbled Up

Over the last several years, we have seen many big software players like IBM, HP, and Borland, acquire most of the larger automation tool vendors (Rational, Mercury, Segue, respectively).

Oracle just followed suit with their announcement to buy acquire the e-TEST suite products from Empirix:

http://www.oracle.com/empirix/index.html

I guess it was just a matter of time.  It will be interesting to see where all of this is going.

#    Comments [0] |
 Friday, March 28, 2008

Can I Test My Application With This Performance Tool?

In the various testing forums and mailing lists I frequent, I see lots of questions asked about automated test tools.  A certain question about performance/load testing tools is asked over and over.  I would like to answer it here.

The question goes something like:
"Can I test my application with this performance tool?".

If you are asking this question, you really don't understand the nature of these tools and how they work.

There are many performance/load testing tools in the proprietary and open source worlds (LoadRunner, SilkPerformer, QALoad, JMeter, OpenSTA, etc).  Conceptually, they all work the same way.  Performance tools do not work by driving a GUI like many functional test tools do.  Instead, they are used to generate load against servers by simulating concurrent client requests at the protocol level.

So the key question you should be asking is: "Which protocols do the client and server use to communicate, and does the tool support these protocols?"  HTTP?  ODBC?  DCOM?  JMS?  So next time you want to ask: "Will the tool be able to test my AJAX/ASP.NET/JSP/PHP/etc application?"; the real question should go something like: "My application uses <protocol x>, does the tool support that protocol?".

Since you are working at the protocol level, the language/platform your system uses has no relevance. All of the technologies I just mentioned use HTTP for transport (layer 7), so any tool that supports HTTP can be used to test that system.




Interested in Web performance testing?
Check out my open source tool: Pylot

#    Comments [4] |
 Tuesday, March 25, 2008

Titus Brown Testing Article - Death Spiral

Nice testing article from Titus Brown.  He makes some good points about automated tests:

The (Lack of) Testing Death Spiral

"So, automated tests are important for maintenance, and they are critical for making sure that your old code still works while you focus on new code. Without automated tests, you will be doomed to releasing increasingly buggy software as your body of code increases and the average level of testing decreases."
#    Comments [0] |
 Thursday, March 20, 2008

Transitioning To Python From Java or C#

"compared to Java code, XML is agile and flexible. Compared to Python code, XML is a boat anchor, a ball and chain."
    - Phillip J. Eby

If you are new to Python and coming from Java (or C#, or other similar statically typed OO language), these classic articles from PJE and Ryan Tomayko are necessary reading:

#    Comments [0] |
 Wednesday, March 19, 2008

Pylot Dev Update - Web Performance - Release 1.0

Finally did the version 1.0 release! visit www.pylot.org to download.

Pylot is still lacking some features I want to add for it to become a serious performance/load testing tool, but the current release delivers very usable functionality.

Current Features:

  • multi-threaded load generator
  • HTTP and HTTPS (SSL) support
  • response verification with regular expressions
  • execution/monitoring console
  • real-time stats
  • results reports with graphs
  • GUI mode
  • shell/console mode
  • cross-platform

Aside from the GUI, there is also a new shell/console interface mode with real-time output for quickly profiling performance your application/service under test from the command line. In this mode, Pylot can run cross-platform. (tested on Windows XP, Vista, Cygwin, Ubuntu, MacOS)

Note: Extra special thanks to Vasil Vangelovski for implementing the original console output and C++ extension


Screenshots of the GUI and new shell/console UI output:





#    Comments [0] |
 Monday, March 17, 2008

Gnuplot - Generating Graph Images From The Command Line

Gnuplot is a free cross-platform program for scientific plotting, but is also useful for generating all sorts of other graphs.

There are lots of tutorials showing how to use Gnuplot in interactive mode.  However, Gnuplot can also be scripted from the command line for generating static images of graphs/plots.  I usually need to graph performance data, consisting of X,Y data points.  Gnuplot allows me to do this easily by passing a config file to the Gnuplot program in non-interactive mode.

Here is a sample data file (plot.data) containing x, y coordinates:

0 2
3 11
5 1
9 10
14 11
20 18
30 9

Here is a sample Gnuplot config file (plot.cfg)

set term png 
set output "plot.png"
set size 0.8,0.5
set yrange [0:]
set xlabel "Elapsed Time"
set ylabel "Throughput (requests/sec)"
plot "plot.data" using 1:2 title "" w lines

From the command line, you can run it like:

Windows:

> wgnuplot.exe plot.cfg

Unix/Linux:

$ gnuplot plot.cfg

This will create an image named "plot.png" containing the line graph:

Here is sample output of rendering a larger data set with an impulse graph and a line graph:

Now that you can run it from the CLI, it is easy to integrate with other scripts or programs.

#    Comments [3] |
 Sunday, March 16, 2008

Dynamic Languages Don't Live In The Scripting Language Ghetto

I love this sarcastic rant by Ryan Tomayko from March 2006.  In the article, he rubutts some of James Gosling's comments regarding Java vs. dynamic languages.  Ryan pokes some fun at comments about dynamic languages and why they should be taken seriously; rather than thrown into the "scripting language ghetto".

My favorite part:

"Dealing with questions on dynamic languages:

First, call anything not statically compiled a “scripting language”. Attempt to insinuate that all languages without an explicit compilation step are not to be taken seriously and that they are all equivalently shitty. Best results are achieved when you provide no further explanation of the pros and cons of static and dynamic compilation and/or typing and instead allow the reader to simply assume that there are a wealth of benefits and very few, if any, disadvantages to static compilation. While the benefits of dynamic languages–first realized millions of years ago in LISP and Smalltalk–are well understood in academia, IT managers and Sun certified developers are perfectly accepting of our static = professional / dynamic = amateurish labeling scheme.

This technique is also known to result in dynamic language advocates going absolute bat-shit crazy and making complete fools of themselves. There have been no fewer than three head explosions recorded as a result of this technique.

Also, avoid the term “dynamic language” at all cost. It’s important that the reader not be exposed to the concepts separating scripting languages like bash, MS-DOS batch, and perl-in-the-eighties from general purpose dynamic languages like Ruby, Python, Smalltalk, and Perl present day."

#    Comments [0] |
 Thursday, March 13, 2008

New Copyright Notice For Unlicensed Code

When I release and publish code, I typically make it Free Software by copyrighting it and applying a license (usually GNU GPL).  In cases of smaller code bases or scripts I write, I don't bother to license them.  They are generally used as small tools or code snippets.

One choice is to release it as Public Domain.  Being in the public domain is not a license.  It means the material is not copyrighted and no license is needed. However, I want to retain copyrights but allow others the freedom to do anything.  This is based on trust of the author, not a license or an any official law speak.

To make the point clear that I don't care, I adapted Woody Guthrie's Copyright notice to apply to my software.

My new Copyright Notice for unlicensed code:



Copyright (c) 2008, Corey Goldberg (corey@goldb.org)

"This code is Copyrighted, and anybody caught usin' it without my permission, will be mighty good friends of mine, cause I don't give a dern.  Run it.  Study it.  Modify it.  Improve it.  Distribute it.  Yodel it.  I wrote it, that's all I wanted to do."



Feel free to use this notice on any software you publish, cause I don't give a dern.

#    Comments [1] |

Blog Subscribers, Come To Me

Since I started this blog, my subscriber count keeps slowly increasing.  I'm still only at 231 subscribers, but the blog is also syndicated via Planet Python and testingReflections.

... I need more subscribers.  Go ahead and subscribe now!

#    Comments [2] |
 Wednesday, March 05, 2008

Pylot - Web Performance Tool - 0.2 Beta Release

I just quietly did a release of Pylot (my open source web performance tool).  You can grab it here.

#    Comments [2] |

New Boston Skatepark - Beyond Psyched

The Charles River Skatepark is going to be built right down the street from my apartment.  I will definitely be a regular.

How insane is this setup?!

#    Comments [1] |
 Tuesday, March 04, 2008

Just Ordered an Asus Eee PC

I just ordered an Asus Eee PC, the tiny portable 7" laptop.  I got the Black 4G Surf model.  I am psyched to get an ultraportable that runs Debian (Xandros) Linux!

I will blog about it if I do anything cool with it.  It comes with Python installed ;)

#    Comments [0] |

Bill Gates Disses Google's GTalk

via Valleywag:

Quote from Bill Gates about Google:

"The Google tools that have tried to do productivity type things, they really don't have the richness, the responsiveness. Most of these Google products, to be frank, the day they announce them is their best day. I remember there was one called G Talk. I can barely remember the name but it was, you know, going to change the world."

Pretty funny comment since I use GTalk all day long and am slowly seeing my contacts fill up with other GTalk users.  I have never used MSN Messenger and never plan to.

#    Comments [3] |

Python - Bytes Received and Transmitted for Windows

This script will output bytes received and transmitted for a local Windows machine since the last reboot:


import re
from subprocess import Popen, PIPE

p = Popen('net statistics workstation', stdout=PIPE)
for line in p.stdout:
    m = re.search('Bytes received\W+(.*)', line)
    if m: print 'Bytes received: %s' % (m.group(1))
    m = re.search('Bytes transmitted\W+(.*)', line)
    if m: print 'Bytes transmitted: %s' % (m.group(1))
#    Comments [0] |

Python - Get Last Windows Reboot Date/Time

This script will output the last reboot date/time for a local Windows machine:


import re
from subprocess import Popen, PIPE

p = Popen('net statistics workstation', stdout=PIPE)
m = re.search('(\d+/\d+/\d{4}.*[A|P]M)', p.stdout.read())
if m: print 'Last Reboot: %s' % (m.group(1)) 

Output:

>> Last Reboot: 3/1/2008 1:51:41 PM





* updated the original script thanks to Ian's comment below

#    Comments [2] |
 Monday, March 03, 2008

Python - Padding Single Digits In Dates

Here is how to zero-pad single digit days or months in a date string:


date = '3/2/2008'
padded_date = time.strftime('%m/%d/%Y', time.strptime(date,'%m/%d/%Y'))
print padded_date
>> 03/02/2008
#    Comments [2] |
 Sunday, March 02, 2008

Python - Palindrome Checker

A palindrome is a sequence that reads the same in either direction.

Here is function I wrote to check if a phrase is a palindrome:


import re

def is_palindrome(txt):
    txt = re.sub('\W+', '', txt).lower()
    return txt == txt[::-1]



phrase = "Go hang a salami, I'm a lasagna hog"
print is_palindrome(phrase)

>> True
#    Comments [4] |
 Monday, February 25, 2008

Geolocation Mashup To Visualize My Blog Visitors

I just did a Geolocation mashup to visualize where my blog readers are coming from on a particular day. Below is a visualization of my US/Canada visitors from February 14, 2008.

All of the data is based off of IP addresses from my referrer logs.

To see how to do this, check out: http://www.goldb.org/geo_maps

#    Comments [0] |
 Thursday, February 21, 2008

Novell == Suckers?

I bet that interoperability deal doesn't sound so great now.
#    Comments [0] |
 Tuesday, February 19, 2008

Etymology of "Foo"

"Foo" is my favorite word. I use it all over the place. When programming, it is the name of my quick junk files... it is a temporary variable name while i figure out code. We programmers love our foo.

For those that want the origins and etymology, there is a great RFC about it:

http://www.ietf.org/rfc/rfc3092.txt


#    Comments [0] |