This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |