DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Simulating Events in Ansible EDA: A Practical Use Case of ansible.eda.generic
  • Deploying Databricks Asset Bundles
  • Resource Management in Kubernetes
  • Implementing EKS Multi-Tenancy Using Capsule (Part 4)

Trending

  • Scalability 101: How to Build, Measure, and Improve It
  • Stateless vs Stateful Stream Processing With Kafka Streams and Apache Flink
  • Immutable Secrets Management: A Zero-Trust Approach to Sensitive Data in Containers
  • Scalable System Design: Core Concepts for Building Reliable Software
  1. DZone
  2. Coding
  3. Languages
  4. The New JSON/YAML Plugin: Using YAML in JMeter

The New JSON/YAML Plugin: Using YAML in JMeter

Let's take a look at a tutorial that explains how the JSON/YAML plugin works by generating a simple test plan.

By 
Artem Fedorov user avatar
Artem Fedorov
·
Updated Nov. 01, 18 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
18.1K Views

Join the DZone community and get the full member experience.

Join For Free

The JSON Plugin was deprecated in Apache JMeter™version 4, following the donation of the JSON Assertion component from jmeter-plugins.org to core JMeter. Now, I have updated this plugin to support new features and abilities. In this new version, the two plugin components, the JSON Path Extractor, and the JSON Path Assertion have a new input format — YAML. So, users can choose between JSON and YAML input formats when running JMeter load tests. This provides more options and flexibility for performance testers — everything that was done before in JSON can now also be done in YAML.

Let's see how the JSON/YAML plugin works by generating a simple test plan. This test plan will take random values from two arrays (lists) in YAML and use them in a POST request as body parameters. The two arrays will be received from another request.

Let's get started.

1. Add the JSON/YAML plugin to your JMeter with the JMeter plugins manager.

2. Add a Thread Group to your Test Plan.

3. Add an HTTP Request and configure the URL parameters. (In my example, I will use a Dummy Sampler because I want to show the response in a YAML format).

For this example, my server will return the following response in YAML. The data from this will be used to simulate the response from submitting a form on the BlazeDemo website.

tickets:
  departure:
    cities:
      - Buenos Aires
      - Rome
      - London
      - Berlin
  destination: 
    cities:
      - Boston
      - Milan
      - Paris
      - Moskow

4. Add JSON/YAML Path Assertions

I added two assertions, that will check that my paths exist in the response. Each assertion has its own path:

  • $.tickets.departure.cities
  • $.tickets.destination.cities

5. Select the YAML Input Format in the assertion.

6. Add JSON/YAML Path Extractors

I added two extractors that will extract two arrays to variables. Each extractor has its own path:

  • $.tickets.departure.cities[*] will extract to the variable 'from'
  • $.tickets.destination.cities[*] will extract to the variable 'to'

7. Select the YAML Input Format in the extractor.

8. Let's look at the extractor's results. We can use the Debug Sampler and the View Results Tree listener.

As you can see, the 'from' and 'to' variables show the full array from the YAML file. We also got the variables from_matchNr and to_matchNr that contain the size of each array. Finally, we see the set of variables from_* and to_* that contains each element from the arrays.

Now, let's see how we can get a random value from these YAML arrays (in the results) and use it in a POST request as parameters.

9. Create an HTTP Request, fill in the body parameters (server, protocol, etc.), and set the parameters values according to the function you need. In this case:

  • Use random function ${__Random(1,${from_matchNr})}
  • Use __V function to evaluate nested variable references.
  • ${__V(from_${__Random(1,${from_matchNr})})}
  • Change the same for 'to' variable: ${__V(to_${__Random(1,${to_matchNr})})}

10. Now I can run my test script and look at the request bodies. You can see it has random values:

That's it! You can now use YAML inputs in JMeter just like with JSON. Then, after creating your JMeter script, you can run it in BlazeMeter from multiple geo-locations, integrate with CI tools, and get advanced reports. Start testing now: put your URL in the box below and your test will start in minutes.

YAML

Published at DZone with permission of Artem Fedorov, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Simulating Events in Ansible EDA: A Practical Use Case of ansible.eda.generic
  • Deploying Databricks Asset Bundles
  • Resource Management in Kubernetes
  • Implementing EKS Multi-Tenancy Using Capsule (Part 4)

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: