Gatling Step by Step Masterclass | Part 2

Поділитися
Вставка
  • Опубліковано 10 чер 2024
  • 00:00 Intro
    00:14 Topics
    00:48 Gatling Project Setup
    01:49 Prerequisites
    03:35 How to setup Maven
    08:12 IDE IntelliJ Idea Setup
    More on IntelliJ Idea: • IntelliJ IDEA
    14:05 2 Options for project creation
    14:15 Option 1 - Create a new Project using Maven
    22:33 Option 2 - Clone existing Gatling Project
    23:58 Clone project on IDE IntelliJ
    31:01 Record & Run tests from Project
    37:24 Gatling Script Preparation
    37:47 Demo example for script preparation
    46:13 Gatling Script Execution
    47:49 Gatling Recorder UI Explanation
    48:36 Follow Redirects:
    50:14 Infer HTML Resources:
    51:44 Automatic Referrers:
    52:38 Remove Cache Headers:
    54:04 Save and Check Response Bodies:
    55:00 Summary and next steps
    ---
    Prerequisites
    JDK
    javac -version
    Scala
    scala -version
    (can skip if the IDE has option to add scala plugin)
    Maven
    mvn -v
    IDE
    any IDE that supports Scala programming
    Eclipse, IntelliJ, Netbeans etc
    Project Setup
    Step 1 - Check JDK and Scala are installed on the system
    javac -version
    scala -version (optional)
    Step 2 - Open IntelliJ and add Scala plugin
    Step 3 - Create a Gatling Project
    Option 1 - Create a new Project using Maven
    Option 2 - Clone existing Project
    Option 1 - Create a new Project using Maven
    1. Create a folder > Open CMD > navigate to folder > run command mvn archetype:generate
    2. Provide archetype gatling
    3. Choose latest version
    4. Define a groupId e.g. com.gatling.tests
    5. Provide an artifactId e.g. GatlingProject
    6. Open/Import project in IDE (IntelliJ IDEA)
    Option 2 - Clone existing Project
    Search for Gatling maven project github (check the latest projects)
    Java - github.com/gatling/gatling-ma...
    Scala - github.com/gatling/gatling-ma...
    Clone or download
    Open/Import project in IDE (IntelliJ IDEA)
    In IDE like IntelliJ we can directly clone project from VCS - File > New > Project from Version Control
    For Scala project:
    scala -version (not needed if scala plugin added on IntelliJ IDE)
    check scala plugin is added in the IDE (File - Settings - Plugins)
    can add scala in Project Libraries (File - Project Structure - Global Libraries - Scala)
    In case the scala and resources folder not already marked
    Rt click on scala folder > Mark Directory as > Test Sources root
    Rt click on resources folder > Mark Directory as > Test Resources root
    Record & Run tests from Project
    Gatling - Record Test
    Step 1 - Demo of the scenario to test
    Step 2 - On Chrome browser - More Tools > Developer Tools - Goto Network tab
    Step 3 - Clear any earlier logs, check Preserve log, start Recording network logs
    Step 4 - Record the scenario
    Step 5 - Save or Export HAR file
    Step 6 - Goto Gatling Project > Recorder class > Rt click > Run Recorder
    Recorder window opens
    Change recorder mode to HAR Convertor
    Browser and add HAR file
    Provide package and class name
    Click No Static Resources Start
    Step 7 - Check the script in IDE
    Gatling Script Preparation
    Step 1 - Open Gatling script in IDE
    Step 2 - Remove Header Maps if any and their references in script
    Step 3 - Update request names > Save
    Step 4 - Understand Gatling Script
    Protocol Setup
    Scenario Definition
    Load Simulation Design
    Gatling Script Execution
    Step 1 - Goto Engine Class > Rt click > Run Engine
    Step 2 - Provide options as needed on the console
    Step 3 - Check the report
    Gatling Recorder
    Gatling Recorder Checkboxes
    Follow Redirects:
    Checked: Gatling Recorder will automatically follow HTTP redirects (e.g., 301, 302, 307) during recording
    Infer HTML Resources:
    Checked: the recorder analyzes recorded responses and automatically adds requests for necessary HTML resources (CSS, JavaScript, images) embedded within the main page.
    This helps build a more complete simulation mimicking realistic browser behavior
    Automatic Referrers:
    Checked: Gatling Recorder will automatically set the Referer header in requests based on the previous request’s URL.
    Useful for simulating realistic user behavior where subsequent requests refer back to the previous page
    Remove Cache Headers:
    Checked: Gatling Recorder will automatically remove cache-related headers (e.g., If-Modified-Since, If-None-Match) from requests.
    This ensures requests always fetch fresh data from the server, avoiding potential caching issues during testing
    Save and Check Response Bodies:
    Checked: the recorder stores the response body content for each captured request.
    Allows for validating responses using checks (e.g., verifying specific content, status codes, etc.).
    Document link - tinyurl.com/GatlingDoc1-Ragha...
    ---
    If my work has helped consider helping an animal near you in any way you can
    Never Stop Learning
    Raghav Pal
    AutomationStepByStep.com/
    ▬▬▬

КОМЕНТАРІ • 29

  • @xXMrThomasXx
    @xXMrThomasXx 13 днів тому

    Thanks for part 2 :) Tommorow I will start part3 ;)

    • @RaghavPal
      @RaghavPal  12 днів тому

      Great.. Have fun learning.. let me know if you face any issues

  • @NaveenKumar-gb8ug
    @NaveenKumar-gb8ug 3 місяці тому

    Hi sir,
    I need your help with some tasks at work.
    I have two quick questions about JMeter:
    Should I test performance using page URLs or APIs? Which one gives real-time results?
    How do I run multiple HTTP requests together? And in the listener, I just want to see the method name.

    • @RaghavPal
      @RaghavPal  3 місяці тому +1

      Naveen
      Let's address your questions about JMeter:
      1. Performance Testing: Page URLs vs. APIs:
      - Page URLs: If you want to test the performance of a web application as a whole, including rendering time, CSS, JavaScript, and other assets, then testing using page URLs (endpoints representing web pages) is appropriate. This approach simulates real user interactions.
      - APIs: If your focus is on testing the performance of specific API endpoints, such as RESTful APIs or SOAP services, then testing APIs directly is more relevant. API testing bypasses the rendering layer and focuses solely on the backend functionality.
      - Real-Time Results: Both approaches can provide real-time results. However, API testing tends to be more efficient because it eliminates the overhead of rendering and loading assets associated with web pages.
      2. Running Multiple HTTP Requests Together:
      - In JMeter, you can execute multiple HTTP requests together by organizing them within a Thread Group. Here's how:
      1. Create a Thread Group:
      - Add a Thread Group to your test plan (Right-click on the test plan > Add > Threads (Users) > Thread Group).
      - Configure the number of threads (simulated users) and loop count (iterations).
      2. Add HTTP Requests:
      - Within the Thread Group, add HTTP Request samplers (Right-click on the Thread Group > Add > Sampler > HTTP Request).
      - Configure each sampler with the necessary details (URL, method, parameters, headers, etc.).
      3. View Method Names in Listener:
      - To see only the method names (HTTP verbs) in the listener, use the View Results Tree or View Results in Table listener.
      - In the listener, select the "Sampler result" column to view the method names (GET, POST, PUT, etc.).
      Example:
      - Suppose you have two HTTP requests: one for login (POST) and another for fetching user data (GET).
      - Create a Thread Group, add these two HTTP requests, and configure their details.
      - Run the test, and in the listener, you'll see the method names (POST and GET) alongside other relevant information.
      Remember to adjust the configuration (such as ramp-up time, think time, and other settings) based on your specific testing requirements.
      .

    • @NaveenKumar-gb8ug
      @NaveenKumar-gb8ug 3 місяці тому

      @@RaghavPal thankyou for sharing this ,sir

  • @sairam9956
    @sairam9956 2 місяці тому

    If we have Scala Plugin installed in IntelliJ, is it not required to add Scala sdk in Global libraries ? Because for me if I do not add Scala sdk, a message is being shown to add a sdk.

    • @RaghavPal
      @RaghavPal  2 місяці тому

      Sai
      you can add and try.. i did not have scala sdk and just added the scala plugin and it worked..

    • @sairam9956
      @sairam9956 2 місяці тому

      @@RaghavPal Yeah, I noticed that there is a scala plugin in the pom.xml file in the gatling-scala demo project. When I checked about that plugin, I came to know that we can use that plugin to compile/test/run/document Scala code in Maven. With this plugin, there is no need to install scala and also no need to download scala SDK in global library.
      Plugin:
      ArtifactID: scala-maven-plugin
      GroupID: net alchim31.maven
      It is available in Maven Repository

    • @RaghavPal
      @RaghavPal  2 місяці тому +1

      Yes.. thanks for posting

  • @dhinesh207
    @dhinesh207 2 місяці тому

    I see many job openings with still Jmeter requirement. My question is, learning Jmeter shd be first priority before learning any of the other tools like Galting or Locust?
    Raghav pls shed some light and others who is working in industry also pour your thoughts and comments. Which will help for a new learner to gain job in performance testing roles quickly !!

    • @RaghavPal
      @RaghavPal  2 місяці тому +1

      Dhinesh
      Choosing the right performance testing tool can significantly impact your career prospects. Let's explore the options and shed some light on JMeter, Gatling, and Locust:
      1. JMeter:
      - Pros:
      - Mature and Established: JMeter has been around for almost 20 years and is widely used in the industry.
      - Versatility: Originally designed for web and FTP applications, JMeter now supports testing various protocols and applications.
      - Large Community: A vast community provides support, plugins, and resources.
      - Java-Based: If you're comfortable with Java, JMeter is a good fit.
      - Cons:
      - Resource-Intensive: JMeter can be resource-intensive, especially for large-scale tests.
      - Learning Curve: The learning curve can be steep for beginners.
      - GUI-Centric: The GUI-based interface might not suit everyone.
      2. Gatling:
      - Pros:
      - Scala-Based: Gatling uses Scala, which is gaining popularity. If you're interested in Scala, this could be a plus.
      - Asynchronous and Event-Driven: Gatling's design is efficient for handling many users simultaneously.
      - Fast and Scalable: It's known for its effective simulation engine.
      - Cons:
      - Less Mature: Gatling is relatively newer compared to JMeter.
      - Smaller Community: While growing, the community is smaller than JMeter's.
      - Scala Learning Curve: If you're new to Scala, there's a learning curve.
      3. Locust:
      - Pros:
      - Python-Based: If you're comfortable with Python, Locust is a great choice.
      - “Test as Code”: Write performance scripts in pure Python.
      - Event-Based Implementation: Highly scalable due to its event-based approach.
      - Growing Community: A fast-growing community prefers Locust.
      - Cons:
      - Less Established: Locust is still emerging compared to JMeter.
      - Limited Protocol Support: While it's versatile, it may not cover all protocols like JMeter does.
      4. Choosing the Right Tool:
      - Prioritize Based on Your Goals:
      - If you want to quickly learn and get a job, consider JMeter due to its widespread use.
      - If you're comfortable with Scala or Python, explore Gatling or Locust.
      - Learn the Basics First:
      - Regardless of the tool, focus on understanding performance testing concepts, load models, and analysis.
      - Once you grasp the fundamentals, transitioning between tools becomes easier.
      - Job Market Trends:
      - While JMeter is still in demand, keep an eye on industry trends. Gatling and Locust are gaining traction.
      - Some job postings may mention specific tools, but employers often value adaptability and understanding of core principles.
      5. Final Thoughts:
      - Start with JMeter: Given its maturity and job market demand, JMeter is a solid starting point.
      - Explore Others: As you gain experience, explore Gatling or Locust to diversify your skill set.
      - Stay Curious: Keep learning, stay updated, and adapt to industry changes.
      Remember, the right tool depends on your goals, preferences, and the specific job market.

    • @dhinesh207
      @dhinesh207 Місяць тому

      @@RaghavPal Thank you so much, for some reason your reply is not shown as notifciation and completely missed to thank you.

  • @rajujawalkar9653
    @rajujawalkar9653 3 місяці тому +2

    sir please make one video that will compare two pdf files properly and highlight the difference in result.pdf file, please sir please make this video in java....

    • @RaghavPal
      @RaghavPal  3 місяці тому

      Raju
      Can check this ua-cam.com/video/koMegSvZEVE/v-deo.htmlsi=KQuPoEy4n0fNJp4t

    • @rajujawalkar9653
      @rajujawalkar9653 3 місяці тому +1

      @@RaghavPal sir, this one i checked, but its highlighting the pdf1 and pdf2 in different colors(Red, green).
      But if we have same content in different pages also its showing color, and its not checking the images.
      sir i am requesting you please make one video, that code compares the pdf by text and images also........
      please.....

    • @RaghavPal
      @RaghavPal  3 місяці тому +1

      ok.. I will check

    • @rajujawalkar9653
      @rajujawalkar9653 3 місяці тому

      @@RaghavPal please sir.

    • @RaghavPal
      @RaghavPal  3 місяці тому +1

      For now, here are a couple of options to achieve this:
      Comparing PDF files in Java with analyzing both the textual content and images.
      If you are looking for free options, consider exploring open-source libraries such as:
      Apache PDFBox:
      Apache PDFBox is a Java library for working with PDF files. While it doesn’t provide direct comparison features out of the box, you can use it to extract text and images from PDFs. You can then write custom logic to compare the extracted content.
      It’s free and open-source under the Apache License 2.0.
      iText:
      iText is another popular Java library for PDF manipulation. It allows you to extract text, images, and other elements from PDFs. You can use it to build your own comparison logic.
      It has both open-source and commercial versions. The open-source version (iText 7 Community) is free under the AGPL license.
      Below, both GroupDocs.Comparison for Java and PDFUtil are not free options
      1. GroupDocs.Comparison for Java:
      - GroupDocs.Comparison for Java API empowers your Java applications with powerful features for comparing PDF files, including text and image comparisons.
      - Here's how you can use it:
      1. Load the first PDF document using the `Comparer` class.
      2. Add the second file to the `Comparer` using the `add` method.
      3. Call the `compare` method to get a summary of changes, including differences within paragraphs, words, characters, shapes, and text styles.
      4. You can even merge the changes and export them to a final document
      2. Custom Solution: PDFUtil:
      - If you prefer a custom solution, consider using PDFUtil, a Java library I created for comparing PDF documents. It offers the following features:
      - Text and Image Comparison: It compares given PDF documents in both text and image modes.
      - Highlight Differences: It highlights the differences between the documents.
      - Extract Images: You can extract images from the PDF files.
      - Save PDF Pages as Images: Convert PDF pages to image format.
      - You can find more details and download the JAR from my blog post
      Remember to choose the approach that best fits your requirements. Whether you opt for an existing library or create your own utility, these tools will help you compare PDF files effectively
      ..

  • @arvindatmuri5604
    @arvindatmuri5604 3 місяці тому

    I would say locust is easy than any other load testing tool. I would prefer locust over any load testing tool

    • @RaghavPal
      @RaghavPal  3 місяці тому

      Sure Arvind... Gatling is also script based and easy to use and powerful.. I will try to add Locust soon

    • @arvindatmuri5604
      @arvindatmuri5604 3 місяці тому

      @@RaghavPal Hi Raghav, I am a big fan of you and your work. I have used gatling and locust as well. I was able to achieve a lot with Locust with limited coding I was able to onboard it just with few steps, and few lines of code and generated pretty heavy loads by scaling it to more machines and was pretty happy using it. Not only API, I was able to integrate with selenium and load test by launching application on browsers and surprisingly results were pretty good. Looking forward for your course on Locust as well 😊

    • @RaghavPal
      @RaghavPal  3 місяці тому

      Thanks for sharing this Arvind.. I will plan to create Locust lectures..

  • @raghuchebolu7913
    @raghuchebolu7913 3 місяці тому +1

    Sound is very Low... please improve sound settings

  • @smrutichandrasekaran4090
    @smrutichandrasekaran4090 3 місяці тому

    Sir i have a doubt

    • @RaghavPal
      @RaghavPal  3 місяці тому

      Yes, pls tell me..