debuggable

 
Contact Us
 
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20

Quickly generate tons of test data

Posted on 23/1/09 by Felix Geisendörfer

I am lazy. I think it's because I was raised a programmer and grew up imagining a world where computers would do all the work for me.

Unfortunately however, our binary offspring is still asking for a great amount of our attention and time before we can retire and hand the work over to our fabulous creations.

But that doesn't mean we can't make the kids clean our dishes, wash our clothes or generate our test data! So at a point earlier last year I was working on my own test data generator, but it turns out it is quite a ton of work to aggregate good data from various places and create a nice generator based upon it.

No worries, the story has a happy end. The universe is kind to the lazy and hearing my cry of need created a whole array of products and web services to address the problem!

Hello generatetestdata.com

From the solutions I tried to far, generatedata.com made by the friendly folks at Black Sheep Web Software has worked the best for me.

However, it took me a little time to streamline my workflow when using it, so here are a few tips you should definitely know about when using the service:

Tip 1: Generate UUID's

If you are using UUIDs in your application and you want to generate random UUIDs there is currently no option for that at generatetestdata.com. However, selecting the type "Alpha-Numeric" and leaving the drop down at "Please select", you can enter your own pattern for the string to be created. Here is the one I came up with for UUIDs:

lxlxlxlx-lxlx-lxlx-lxlx-lxlxlxlxlxlx

Tip 2: Generate custom strings

If you need even more customized strings, you can use the placeholders provided by the service. As you can see I simplified UUID generation above by simply combining random lowercase letters with random numbers - not even close to perfect UUIDs, but very kick-ass for test data ; ).

L	An uppercase Letter.
l	A lowercase letter.
D	A letter (upper or lower).
C	An uppercase Consonant.
c	A lowercase consonant.
E	A consonant (upper or lower).
V	An uppercase Vowel.
v	A lowercase vowel.
F	A vowel (upper or lower).
x	Any number, 0-9.
X	Any number, 1-9.

Tip 3: Connect to foreign keys

The whole generator is kind of nice and all, but if the table you are generating data for has foreign keys that point to different tables you need those links to work, right? After all what do you need test data for if not to see the parts of your app working together ; ).

Anyway, it turns out this is not a particular difficult problem either. From the data type drop down select "Custom List" and again leave the "Please select"option in the second drop down where it is. Now you can provide your own list of strings separated by the "|" (pipe character) to be used for this field.

How do you get a good list that matches your foreign keys? Easy. Let's say you have a key "user_id" in your table and you need a good list for that, simply run this MySql query:

SELECT GROUP_CONCAT(id SEPARATOR '|') FROM users;

This will return an already perfectly formatted list ready to be copy & pasted into the list field! And as you can see you can get very fancy at this point by providing conditions and other things to get the data you want! This can also be handy if you already have a set of data (like path's to uploaded images <- sry, you'll still have to do this manually) that you want to re-use.

Tip 4: Quickly getting the records into your table

For me the quickest way to get the records in the table so far has been to select "Sql" as the result type on top, enter my table name at the bottom and disable the "create table" option. Then after hitting generate I hit Command+A to select all items and paste the whole thing into my MySql terminal (you can also use a guy client like phpMyAdmin for that).

If you are on OSX you can also pipe your clipboard into mysql directly like this:

pbpaste > mysql my_db

Start using big sets of test data now

There is no point in always testing a sophisticated app with a set of < 10 records you entered by hand. Especially if those are full of profanity and can't be handed of to a client anyway ; ).

For example I currently am working on a very nice dashboard for our client to help analyze some click data we are tracking. I started out with just a handful of clicks I generated manually, but realized I needed 1000++ records to see if my Sql records are good enough and to see the charts become all pretty. Needless to say, I caught several issues that only became apparent through the amount of data.

So if you develop a system, and even if it's very small - generate some good test data for it today. Nothing is a worse productivity killer then not being able to test something properly due to the lack of data.

-- Felix Geisendörfer aka the_undefined

PS: If you are re-doing an existing system or otherwise have the chance to use "actual" data to test with, spend some time on getting that going. Real records are always better (read worse but in a good way) to test your application.

 

Berlin CakePHP Meetup, Next Friday (Jan 30)

Posted on 22/1/09 by Felix Geisendörfer

Hey folks,

Tim and I are hosting a little CakePHP get-together next week Friday. The event will start at 6pm and last until ... well whenever we run out of beer ; ).

The exact location (somewhere in the center of Berlin) will depend on the amount of people who want to join us. So if you are fairly certain that you want to try to make it, please leave a comment on the post so we can do the planning.

No matter if you are a kitchen assistant or a five star chef right now, everybody is welcome. That means even if you are just curious about CakePHP and more in the PHP/JS/Ruby/Python/*web world, please join us.

If enough people are interested we can make this a monthly thing!

-- Felix Geisendörfer aka the_undefined

PS: If you have any questions or need assistance in making travel arrangements, let me know!

 

Git Tip: Auto update working tree via post-receive hook

Posted on 26/12/08 by Felix Geisendörfer

Oh, this one took me a while to figure out. Lets say you want to setup a git repository on your server that whenever you push into it updates its working tree. Why? Well, because this can be a very convenient workflow for a small project where you want to be able to quickly push changes out without any fancy deploy mechanism.

My first attempt was to do this on the server:

chmod +x .git/hooks/post-receive

And then put this into the post-receive hook file itself:

#!/bin/sh
cd ..
git reset --hard

However, this would always give me an error like this when trying to push:

$ git push
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 372 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To machine:/repo/path
   122a0cc..747f3d8  master -> master
fatal: Not a git repository: '.'
error: hooks/post-receive exited with error code 128

The solution? It turns out the post-receive hook starts out with the GIT_DIR environment variable set to the repo/.git folder, so no matter what path you 'cd' into it will always try to run any following git commands there. Fixing this is simply a matter of unsetting the GIT_DIR (thanks to Ulrich Petri for the elegant env -i solution):

#!/bin/sh
cd ..
env -i git reset --hard

Voila, a quick and dirty-git repository that updates its own working tree upon push!

-- Felix Geisendörfer aka the_undefined

Another issue you might want to watch out for: Depending on the user doing the push and the permission / ownership settings on the working tree you may have to become a little more tricky using a sudo -u command and an entry in your sudoers file.

 

Extra Hot: CakePHP 1.2 Stable is finally released!

Posted on 26/12/08 by Tim Koschützki

Hey folks,

tonight is an amazing one! Not only do we get to play with our hopefully awesome gifts, but we are also able to enjoy the final 1.2 version release of our favorite PHP framework CakePHP!

The Final Release of CakePHP has come along way, with four release candidates altogether. I guess this is the time to thank everybody on the team for their hard work as well as our great community that's been supporting us with ticket submissions, suggestions and often times very usable patches and tests! It's been amazing to be a part of the community! It's not only fun developing CakePHP and with CakePHP, but also communicating with fellow bakers.

CakePHP has grown a lot from the 1.1 release which was exactly two years ago. A lot of cool features went into the framework. However, the most important thing is really that we got all components well-tested with a pretty high test coverage. To learn about the other dramatic changes since version 1.1, hop on over and read Garrett's release announcement.

You guys are probably wondering now in which direction the development of CakePHP is going from now on. Well, this is currently being discussed on the dev team, but rest assured that we are looking at enhancement tickets as well. So, if you happen to have a good idea about a feature or enhancement that should go into Cake 1.3, now would be a good time to voice your opinion.

Come on hop on irc, the google group or simply add a comment to this blogpost and we will discuss it. If you decide to add a ticket instead, please make sure there is no related ticket already as there are well over two hundred already.

I hope you are as excited as we are. :) If you haven't yet used CakePHP, give this final 1.2 release a try - it's well worth a shot!

-- Tim Koschuetzki aka DarkAngelBGE

 

Merry Christmas and Positive Lookahead

Posted on 24/12/08 by Felix Geisendörfer

Hey folks,

this is Tim and Felix wishing you a Merry Christmas and a Happy New Year! We hope you had a great year and got as much excellent baking done as possible.

2008 has certainly been a very exciting year here at Debuggable. We traveled the world and met up with bakers in Singapore, Argentina and the US. We worked with a lot of amazing companies and individuals, creating an insane amount of applications and products. We also had the opportunity to host a 2 day CakePHP workshop in Raleigh (home of the famous NOSLOW) using the facilities provided by credit risk management. It was a huge success.

The future however, is even brighter! We developed a new technology that will put the R back into revolution. But I really don't want to talk about it too much yet. We are also going to relaunch our blog and change the overall concept of debuggable.com. Don't worry, we will continue to write about CakePHP, but you are going to see much more video. Coincidentally, the new technology will also play a role in that. Follow me on twitter if you are curious.

-- Felix Geisendörfer aka the_undefined

 
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20