readme.md 3.5 KB

API-Tester for Earthsquad Drops APP

General functions:

  • Create random users and products
  • Simulate daily behaviour of existing users
  • Load-Test nginx-Server

Call Parameters and INI-File

In the ini-file (if none is given, system looks for init.ini) all parameters can be preset. If a specific ini-file shall be used use command line parameter --ini_file=.

All other command line parameters overwrite the settings in the INI-file. Let's assume you have users=10000 in the ini_file and you start the program using command line parameter --users=10, then the 10 from the command line will overwrite the 10000 from the INI-File. Same goes for all other parameters.

Most important parameters (server, users, products) are also defaulted in the program, so you could theoretically also run it with an emtpy init.ini (not sure why you would do that, but it should be possible)

Command line parameters are printed on every start of the program. If you want to just see the available parameters, call the program with an invalid option e.g. --invalid

A log is written for each start of the program. The log also shows while running, which API-Calls take how long (Average, min, max, last). The statistics is printed at the end of the written Log aswell. LogLevel 1, 2, 4 can be used to influence contents of logs written. Log on Stdout is always 2.

Create random users and products

Timestamp of the first call of the program is used to randomly create a base-number, that will be used for all usernames and EAN-Codes. The base-number is then concatenated with range(1000../) to form each individual EAN-Code and User-ID. (e.g. 2341231000...2341231999 for usernames and EAN-Codes).

The program flow in this mode (mode=allnew = default mode)

  • Create users: Method api_users.create_users()
  • Create Product: Function: f_full_recycle()
    • Create EAN
    • Create Product
    • Create BOM or not (depending on wheter a standard product was randomly chosen)
    • Upload picture (whether or not and which picture can be set in INI-File or via command line)
    • Recycle this product (so that each product has at least 1 entry in recycling)
  • Recycle random number of products (out of the previously created products) for each user. In the Logs: "Mass-Recycling of user"
  • Do some bulk-recycling activities

Simulate daily behaviour of existing users

Prerequisit: Download result of select email from auth_users as CSV-File into the path.

Mode for this call: --mode=recycling or mode=recycling in the INI-File

CSV-File + path (if not current dir) must be given as commandline parameter --csv, otherwise it won't work.

Will behave like a regular user of the App, flow as follows:

  • Recycle a random product
  • Do some bulk recycling

The random products are found by brute-forcing /products/{id} with random numbers until the count of --products= from command line was found. In case there are too many 404-messages, the system assumes an endless loop and quits. (better use smaller numbers of --products, e.g. 10 or so on a smaller database).

Load-Test nginx-Server

Requesting files from Server given by --server (or ini_file) and writing statistics about duration.

Other contents of the Repo

  • Make.cmd --> Create EXE-File for distribution to Windows-PCs without Python installed
  • The images test.jpg (3.2 MB) and test2.jpg (80kB)
  • Default *.sh-Files for Linux
  • DIST-Folder including *.CMD-Files for Windows (call to api_calls.exe instead of python API_calls.py in the *.SH-Files)