1. Create Ubuntu VM

    Untitled

    Untitled

  2. Install an xRDP Server on your Ubuntu VM

    sudo apt install xrdp
    
    sudo systemctl status xrdp
     
    #Output:
     
    ● xrdp.service - xrdp daemon
         Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
         Active: active (running) since (...)
    
  3. xRDP uses the SSL key in /etc/ssl/private/ssl-cert-snakeoil.key  which is only readable by members of the 'ssl-cert' group. We need to add the 'xrdp' user to the group. We then need to restart the xRDP server.

    sudo adduser xrdp ssl-cert 
    sudo systemctl restart xrdp
    
  4. Finally, you need to make sure port 3389 (used by the RDP protocol) is accessible from wherever you want to use the RDP client on, you can specify an IP range, or simply allow everyone (in which case they would also need a user/password to be able to enter). This is done by configuring the Ubuntu FW.

    #specify IP range that can access port 3389
    sudo ufw allow from 192.168.33.0/24 to any port 3389
     
    #OR allow everyone
    sudo ufw allow 3389
    
  5. xRDP is now installed!

  6. Use Microsoft remote desktop to connect to the instance 35.201.190.131

  7. Add user to Ubuntu

    adduser claire123
    pw claire123
    
  8. Install and Setup Apache JMeter on your Ubuntu VM!

    1. We now have every prerequisite taken care of: an Ubuntu VM that will host our traffic generator (and, in our case, the API server as well), an xRDP server running that will let us use Apache JMeter's GUI, and an API server that is publicly accessible.
    2. Step 1. Install homebrew on your Ubuntu VM
    3. Let's install Apache JMeter! We will use homebrew to do this as it makes everything easier, but you can just go to Apache JMeter's website and download the binaries from there.
    4. In order to install homebrew just follow the instructions found here: https://brew.sh/, but generally you can install it by using the following command and executing it on your Ubuntu VM: /bin/bash  -c "$(curl -fsSL [<https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)](<https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>))" It can take a while. Please be patient. Go get your own real homebrew setup in the meantime, If you don't have one, here's a kit on Amazon to get you started: https://www.amazon.co.uk/Beer-Making-Kit-Lager-5-Litre/dp/B00P17OFI0/ref=sr_1_1_sspa?crid=2KTPITOZ3LPNW&keywords=homebrew+kit&qid=1662034799&sprefix=homebrew+kit%2Caps%2C103&sr=8-1-spons&psc=1
    5. Install Jmeter ``brew install jmeter`
    6. Again, this can take a while, it will hang in some phases and you will doubt that it's working and enter a slight phase of despair after all of the work you've done until now, but it will install, trust me. Use this time to think about how you want to bottle your homebrews. I like swing top beer bottles as they are reusable: https://www.amazon.co.uk/Glass-Swing-Top-Beer-Bottles/dp/B08PL6MC7G/ref=sr_1_5?keywords=flip+top+beer+bottles&qid=1662035069&sprefix=flip+top+bee%2Caps%2C113&sr=8-5
  9. Once Apache JMeter has completed its installation you have to open its GUI. You do this by executing the JMeter's binary file. In Linux deployments Homebrew will install it under /home/linuxbrew/.linuxbrew/Cellar/jmeter/5.5/bin/jmeter: cd into the 'bin' directory and run JMeter.

    1. Log in via the Microsoft desktop

      1. User claire123
      2. pw claire123
    2. Open terminal

      cd /home/linuxbrew/.linuxbrew/Cellar/jmeter/5.5/bin
      ./jmeter
      
  10. Add a new thread group

    Untitled

    Untitled

    now add customization properties to our HTTP Request object. Right-click 'HTTP Request' and add the following objects:

  11. Let's start by giving a JMeter a way to know which API endpoints to call. We are going to perform GET requests as we only need to hear a 200 OK HTTP status code back from Cloudflare. We do this by setting up our 'CSV Data Set Config' object to pull data from a .csv file with a list of endpoints that JMeter will append to the URL of each request. We need to check the Petstore API for all GET endpoints and list those. This is in /home/claire123/Documents/api-get.csv

    Untitled

    Write down the variable name you will use. This is will represent an addressable global variable that you can refer to when setting up your HTTP request settings. In my case I used the name 'random_path_petstore'.

  12. Now click on your 'HTTP Header Manager' settings. This is where we will provide JMeter with both our session identifier and accept headers.

    1. The session identifier is a variable required by API Discovery. This is how API Discovery is able to differentiate your API users. It's also how API Discovery filters the API calls that it should take into account. If this header is not in the API request, Discovery won't care for it.

    2. First, go to your API Shield settings in your Cloudflare dashboard and add a Session Identifier. Choose the header option. Give it whatever name you want! I have two APIs proxied through my setup which is why you see 2 different session identifiers on the following screenshot - 'session-identifier-mdias' and 'session-identifier-petstoreapi-mdias'. For the Petstore API I used the latter. You can absolutely use a single identifier for all of your APIs.

      Screenshot 2023-01-12 at 12.46.51 AM.png

  13. Finally, let's edit our 'HTTP Request' settings so that JMeter knows which API to call.

    1. Use 'https' as your Protocol and enter your API hostname under 'Server Name or IP'.

    2. Choose 'GET' as your HTTP request method. For the Path you have to make sure it's leading to Petstore V3 and that it's appending the headers you have supplied to your 'CSV Data Set Config' object. If you used the same variable name as me, your Path should value should be the following:

      Screenshot 2023-01-12 at 12.52.46 AM.png

  14. Set thread group

    Screenshot 2023-01-12 at 12.53.11 AM.png

    'Number of Threads (users)', a 'Ramp-up period' (time it takes to ramp-up the the threads list),

    In that example I have 5 Threads and 10 seconds of ramp-up. This means that for the first second, the generator will send out 1 API call with one value of session identifer, for the second second, the generator will send out 2 API calls with two values of session identifiers, and so on until the sixth second, where the generator will send out 5 API calls with 5 unique values of session identifiers.

  15. Config of jmx is saved. Do not forget to save your Apache JMeter setup somewhere! It will save your setup as a .jmx file that you will be able to load onto other instances of JMeter if you need.

    Screenshot 2023-01-12 at 12.53.28 AM.png

  16. View the result tree

    Screenshot 2023-01-12 at 12.54.10 AM.png

    make sure u are getting the logs on instant logs

    Screenshot 2023-01-12 at 12.55.03 AM.png