apiVersion: v1
kind: ConfigMap
metadata:
  name: locust-py
  namespace: default
data:
  locust: |
    import uuid

    from datetime import datetime
    from locust import HttpLocust, TaskSet, task


    class MetricsTaskSet(TaskSet):
        _deviceid = None

        def on_start(self):
            self._deviceid = str(uuid.uuid4())

        @task(1)
        def login(self):
            self.client.post(
                '/login', {"deviceid": self._deviceid})

        @task(999)
        def post_metrics(self):
            self.client.post(
                "/metrics", {"deviceid": self._deviceid, "timestamp": datetime.now()})


    class MetricsLocust(HttpLocust):
        wait_time = between(2, 5)
        task_set = MetricsTaskSet
