Skip to content

jp/fb-ruby-script

Repository files navigation

About

This is a set of ruby scripts to manipulate facebook test users > developers.facebook.com/docs/test_users/

How To

1 - Edit you app information

The scripts are made for a single app. The app credentials are stored in the file fb_secret.rb. Just edit APP_ID and APP_SECRET to make them match to what should be inside.

2 - Generate test users

Edit fb_account_generator.rb to set NB_USERS_TO_CREATE. Default if 500 : this is what facebook allowed me to create on my first (and last) try.

Note that RIG (Random Identity Generator) is used to generate the user names. Install with APT-GET or rig.sourceforge.net.

RIG is giving some nice generated identities which is much better than having user001 to user500.

Then run fb_account_generator.rb … and wait for a “Error code: 2900 (Too many test accounts)”

Each created account is stored in an SQLite database with a model defined in lib.rb.

3 - Randomize friendship

In the app I tested, I had to know if one user was a friend to another, in order to allow the access to some information. I also had to get the list of all the user’s friends who already have an account in the app

For each test user, the script randomize_friends.rb creates 10 to 100 connections with other test users.

4 - Save the output of read_db.rb in a CSV to use as an input for JMeter

./read_db.rb > fb_tokens.csv

5 - Refresh database after tokens expiration, regenerate CSV

The access_token is expiring like the login_url : regularly, after a badly documented delay (1 or 2 hours depending on the line of the fb doc).

We can anyway refresh the tokens using the listing of all the test users associated to the application. The refresh.rb script is there to do the job.

JMeter conf

Use the CSV file as an input in JMeter Launch one (or more) JMeter server in an EC2 or RS instance

Dig a tunnel between your network and the slaves network

On the client edit jmeter.properties and add:

remote_hosts=127.0.0.1:55501
client.rmi.localport=55512
mode=Batch
num_sample_threshold=250

On the server edit jmeter.properties and add:

remote_hosts=127.0.0.1:55501
client.rmi.localport=55512
mode=Batch
num_sample_threshold=250

Dig the SSH tunnel

ssh -L 55501:127.0.0.1:55501 -L 55511:127.0.0.1:55511 -R 55512:127.0.0.1:55512 user@hostname -N

Indicate internal and external IP went routing the inside out

server.rmi.localhostname=127.0.0.1
httpclient.localaddress=10.1.1.5

Warranty

This software suite come with the warranty that you have to read the code

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.

Author

JP - Julien Pellet - 2010

About

scripting for load testint FB apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages