github.com/nginxinc/kubernetes-ingress@v1.12.5/perf-tests/suite/ap_request_perf.py (about)

     1  import yaml, os
     2  from locust import TaskSet, HttpUser, task
     3  
     4  host = ""
     5  class TestAPResponse(HttpUser):
     6      # locust class to be invoked
     7      def on_start(self):
     8          # get host from appprotect-ingress yaml before each test
     9          ap_yaml = os.path.join(os.path.dirname(__file__), "../data/appprotect-ingress.yaml")
    10          with open(ap_yaml) as f:
    11              docs = yaml.safe_load_all(f)
    12              for dep in docs:
    13                  self.host = dep['spec']['rules'][0]['host']
    14          print("Setup finished")
    15  
    16      @task
    17      def send_block_request(self):
    18      # Send invalid request while dataguard alarm policy is active
    19          response = self.client.get(
    20              url="/<script>", 
    21              headers={"host": self.host},
    22              verify=False)
    23          print(response.text)
    24      
    25      @task
    26      def send_allow_request(self):
    27      # Send valid request while dataguard alarm policy is active
    28          response = self.client.get(
    29              url="", 
    30              headers={"host": self.host},
    31              verify=False)
    32          print(response.text)
    33      
    34      min_wait = 400
    35      max_wait = 1400
    36  
    37