📖What you will learn
- How to randomize URLs in your load tests
You’ve run your baseline load tests and you’ve tracked what you think is regular user behavior with browsing, shopping carts, checkout and the like. But as experienced developers, we know one thing: there’s no such thing as "regular user behavior.” So when you’re ready to take your load testing to the next level, try this script showing you exactly how to randomize URLs in your load tests.
Your random URL testing process looks like this:
- Create a list of URLs you want tested
- Create your Load Impact script to randomly select URLs from that list
- Run your load tests with that script
- Evaluate, adjust, and repeat
Step 1: Create a list of URLs to test
It would be unwise and impractical to hit every possible URL permutation on your site. (There are other tools for URL testing.) Instead, create a list of URLs you want tested. You may know this offhand - if so, great. Perhaps your site is small enough you can test all of the possible pages easily.
Another option: check your Google Analytics data for all URLs visited during a particular period (you choose based on the number of URLs - maybe the past month, quarter or even year). You can export the "pages visited” report.
To use this list of URLs in your test, you’ll need to first create a CSV, then upload it to Load Impact’s data store feature. Here’s how.
Your CSV is simple: it’s just a list of the URLs you want visited with each URL on a separate line. Then, upload that CSV to a Load Impact Data Store. (Complete details are in this support article). In short, you’ll upload a Data Store, approve its format, and then simply make sure you’ve made note of the data store name - you’ll need it for the script in the next step.
Step 2: Create your Load Impact script
The following script example is pretty straightforward, but we’ll add a few notes after the code:
Note that in line 5, you’ll replace the "URL data store” with the name of your Data Store you uploaded in Step 1. In line 10, of course, you can choose more than 5 URLs to test in the script, but given browser limits and usual behavior, 5 is a good number to start with.
The script is also available in this support article)
Step 3: Run your Load Tests
Since you’re an experienced Load Impact user, you already know the basics - you’ll just create a new test, then add your new random URL script user scenario. Then run your tests.
Step 4: Evaluate, adjust, and repeat
As with every test, we recommend you run it continuously and consistently. You may want to include some of your random URL tests in your regular deployment pipeline. You may also want to run a deeper test at regular intervals. No matter which you choose, have fun with the random URL script, and, as always, happy testing!