oncall-engine/dev/scripts/generate-fake-data
Joey Orlando 7c4b40a046
upgrade to Python 3.12 (#3456)
# What this PR does

Upgrade to Python 3.12 + fix several invalid test assertions that lead
to test failures in the latest version of `pytest`:
```
AttributeError: 'called_once_with' is not a valid assertion. Use a spec for the mock if 'called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?
```

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-30 13:47:41 +00:00
..
main.py fake-data generation script + fixes for django-silk and django-debug-toolbar (#1128) 2023-01-20 09:19:41 +01:00
README.md upgrade to Python 3.12 (#3456) 2023-11-30 13:47:41 +00:00
requirements.txt Bump aiohttp from 3.8.6 to 3.9.0 in /dev/scripts/generate-fake-data (#3436) 2023-11-28 06:56:46 -05:00

Fake Data Generator Script

This script can be used to easily populate fake data into your local Grafana/OnCall setup. Currently the script is capable of generating the following objects:

  • teams
  • users
  • schedules
  • schedule on call shifts

Prerequisites

  1. Create/active a Python 3.12 virtual environment
  2. pip install -r requirements.txt
  3. Must have a local version of Grafana and OnCall up and running
  4. Generate an API key inside of Grafana OnCall

How to run

Note: The below flag values assume you are running a grafana container locally via the docker-compose setup. The reason why there is a few separate steps involved is that we need to first create teams and users in the Grafana instance. Later on, in order to create OnCall schedules/oncall-shifts, we need the OnCall user ID to do so. There is currently no way to trigger a Grafana -> OnCall data sync via the public API, hence the manual step in the middle to have data synced between Grafana and OnCall.

  1. Create teams and users in Grafana. The teams and users flags represent the number of teams and users you would like to create respectively:

    # by default this will generate 10 teams and 1000 users
    python main.py generate_teams_and_users
    

    See python main.py generate_teams_and_users -h for more information on how to run the command.

  2. Head to your OnCall setup, and trigger a Grafana -> OnCall data sync by visiting the plugin page.

  3. Create schedules and on call shifts in OnCall. The schedules flag represents the number of OnCall schedules you would like to generate. Note that one on call shift is created for each schedule:

    # by default this will generate 100 schedules
    python main.py generate_schedules_and_oncall_shifts --oncall-api-token=<oncall-api-key>
    

    See python main.py generate_schedules_and_oncall_shifts -h for more information on how to run the command.