Random and Named Routes


{warning} You have tried to save a test that uses random numbers or strings, but does not name all of it's test requests.

This is quick and easy to solve so do not worry. The reason for the error you received is the following:

  1. You have "import random" or "from random" in your test, meaning you are including a random element.
  2. You don't have a name variable attached to your GET and POST requests, meaning you could get millions of single logs

Simple Fix

For example, you may have a request that looks like this:

self.client.get("/api/user/" + str(random.randint(0,100000)))

There is no problem with this, you want to test your User API with a random user ID between 0 and 100,000. However, these will then report as 100,000 different URLs you tested. Thats not what you want, but also, will cause the test to be too large for our storage allowances. By changing it to the following you will get them reported as a single clean result, and have no problems:

self.client.get("/api/user/" + str(random.randint(0,100000)), name="User API")

{info} Note that every single self.client.get and self.client.post must have a name if you import random, even those without random strings!


Other examples

Here are some other examples of named requests for you to use if you need:

response = self.client.post(
    "/graphql",
    name="GraphQL",            
    json={"query": query }
)

self.client.get("/", name="Index Page")    

If you are not actually using any random numbers or strings you can remove the "import random" from the top of your test script. Contact us at hello@loadforge.com if you believe the matching is incorrect or for any questions :)


Disable checking

Alternatively, if you are certain you know what you are doing and can limit the output of your log to under 40mb you can add a comment to your file like so:

#disable_random_checks

That will allow you to save your script. You will know you have a problem if you get errors trying to read your results!