Python API Test files

Bernhard Buhl affd6102b6 logreader bug fixes and updats 5 years ago
dist affd6102b6 logreader bug fixes and updats 5 years ago
old 7a1eb985b7 postgres gone 5 years ago
.gitignore 4cf666b73f Changed .gitignore and added other csvs 5 years ago
API_Calls.py b2e6f102e5 added user_stats-API 5 years ago
__init__.py c93614772e Initial commit 5 years ago
_mysql.sh 8a2ba5ada7 Linux +x + Paths 5 years ago
_mysql_recycle.sh 4900728123 new CSV for mysql 5 years ago
_mysql_short.sh 1fb5508bb0 +x for sh-files 5 years ago
_mysql_short_recycle.sh 4900728123 new CSV for mysql 5 years ago
copy_from_server.cmd affd6102b6 logreader bug fixes and updats 5 years ago
init.ini 5f1a9418a7 cleaning up a bit 5 years ago
log_reporter.py affd6102b6 logreader bug fixes and updats 5 years ago
make.cmd c93614772e Initial commit 5 years ago
readme.md b15e1962b4 readme.md 5 years ago
scanapp_master_data.sql edffeda58b SQL-File to execute after a fresh DB-Install) 5 years ago
test.jpg f2690b0bcc INI-File, Standard-Products and many other changes 5 years ago
test2.jpg f2690b0bcc INI-File, Standard-Products and many other changes 5 years ago

readme.md

API-Tester for Earthsquad Drops APP

General functions:

  • Create random users and products
  • Simulate daily behaviour of existing users

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).

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)