Skip to content

Instantly share code, notes, and snippets.

View allankp's full-sized avatar

Allan Kilpatrick allankp

  • Edinburgh, Scotland
View GitHub Profile
import json
import os
from botocore.vendored import requests
from botocore.vendored.requests.auth import HTTPBasicAuth
import statistics
SONAR_CLOUD_API = "https://sonarcloud.io/api"
ORG_KEY = os.getenv("ORG_KEY") # SonarCloud organisation key
from locust import Locust, task, TaskSet
class SimpleSendTask(TaskSet):
@task
def send_request(self):
payload = {"sample_key": "sample_value"}
self.client.send("send_endpoint", "POST", payload, "send_endpoint_task_name")
class SimpleSendRequest(Locust):
def __init__ (self, *args, **kwargs):
import boto3
import json
from locust import events
import time
class BotoClient:
def __init__(self):
self.client = boto3.client("apigateway" , region_name="eu-west-2")
self.api_resource_ids = get_resource_ids("your-api-name")
import boto3
CLIENT = boto3.client("apigateway" , region_name="eu-west-2")
def get_api_resource_ids(api_gateway_id: str) -> dict:
resource_ids = {}
for resource in CLIENT.get_resources(restApiId=api_gateway_id)["items"]:
try:
resource_ids[resource["pathPart"]] = resource["id"]
except KeyError:
@allankp
allankp / locust_boto3_custom_client.py
Last active January 11, 2022 18:37
locust_boto3_custom_client
import boto3
import json
from locust import events, Locust, task, TaskSet
import time
class SimpleSentTask(TaskSet):
@task
def send_request(self):
payload = {"sample_key": "sample_value"}