JMeter and How to Debug Test Scripts with Naeem Akram Malik

By Test Guild
  • Share:
Join the Guild for FREE
Naeem Akram MalikTestGuild PerformanceFeature

About this Episode:

Debugging JMeter scripts can be tricky. Where do you start? In this episode, Naeem Malik, an experienced test engineer and Udemy instructor, shares his approach to debugging JMeter tests. Discover different ways that you can debug JMeter scripts, including the debug sampler, debug post-processor, and JSR223 sampler.

TestGuild Performance Exclusive Sponsor

SmartBear is committed to helping you release high-quality software, faster, so they created LoadNinja to make performance testing effortless. Save time by eliminating correlations with automated, browser-based performance testing that ensures your application performs reliably when it’s needed most. Try it free today.

About Naeem Akram Malik

Naeem Akram Malik

Naeem is an experienced test engineer, a Udemy Instructor, and a technical writer. He has hands-on experience in automated web testing with Selenium and API testing in C# and Java as well as performance testing JMeter. And make sure to check out the show notes of this episode to learn how you can work with Naeem if your company is looking for remote assistance with QA automation & performance.

Connect with Naeem Akram Malik

 

Rate and Review TestGuild Performance Podcast

Thanks again for listening to the show. If it has helped you in any way, shape or form, please share it using the social media buttons you see on the page. Additionally, reviews for the podcast on iTunes are extremely helpful and greatly appreciated! They do matter in the rankings of the show and I read each and every one of them.

[00:00:05] Get ready to discover some of the most actionable performance engineering, testing in the Site Reliability advice with some of the world's smartest engineers. Hey, I'm Joe Colantonio host of the Test Guild and SRE podcast, and my goal is to help you succeed in creating application performance awesomeness. [00:00:21][16.2]

[00:00:21] Joe Colantonio: Hey, it's Joe, and welcome to another episode of the Test Guild Performance and Site Reliability podcast. And today we'll be talking with Naeem all about Jmeter and How to Debug Test Scripts. If you don't know, Naeem is an experienced test engineer, a very prolific Udemy instructor, and technical writer. I think he has over five courses on Udemy like TCP-IP-Socket-Programming with C-Sharp .Net Appium Win App Driver, UI Automation testing, Windows UDP socket programming I think for distributed computers, Windows Service programming, debugging as you're a DevOps building, pipelines. He has a ton of experience, a ton of students, and I think he has almost five-star ratings all these courses. I've been wanting to get on the show for a while. And so I recently saw a blog post he wrote for Blaze Meter, and I thought it'd be a great opportunity to get him on. He also has a lot of hands-on experience in automation web testing with Selenium, API testing with C-sharp and Java, as well as performance testing with Jmeter. And also make sure to check out the show notes at the end of the episode to learn how you can actually work with Naeem directly. If your company is looking for a remote association or remote assistance with QA automation or performance. So you don't miss this episode. Check it out. [00:01:40][78.6]

[00:01:42] This episode is brought to you by the awesome folks at SmartBear. Listen, we know load testing is tough but necessary. So investing in the right tools to automate tests, and identify bottlenecks to resolve issues fast, saves your organization both time and money. And that's why SmartBear created a LoadNinja, a sas load testing tool to help teams get full visible performance so you can release quality software faster than ever, make testing effortless and give it a shot. It's free and easy to try. Head it over to loadninja.com and learn more. [00:01:42][0.0]
[00:02:14] Joe Colantonio: Hey Naeem, welcome to the Guild. [00:02:15][0.8]

[00:02:17] Naeem Akram Malik: Hi, Joe. I'm very happy to be here today. Thank you for inviting me. [00:02:20][3.4]

[00:02:21] Joe Colantonio: Awesome to have you. You have a lot of experience, but is there anything that I missed in your bio that you want the guild to know more about? [00:02:26][5.3]

[00:02:27] Naeem Akram Malik: Well, no, you actually did a great job. I mean, I got a lot of stuff on my hands and it's all over the place. But yeah, a lot of stuff is going on. The technical writing, the test automation, the Udemy courses, the YouTube channel, a whole bunch of stuff. And that was a nice intro. Thank you very much. [00:02:43][16.1]

[00:02:44] Joe Colantonio: Awesome. So I guess, how come there's no course on Jmeter yet or performance testing? [00:02:48][4.6]
[00:02:49] Naeem Akram Malik: Well, honestly speaking, just a few months ago until a few months ago, I never used it for professional purposes. I was mainly focused on UI test automation with Selenium and before that it was coded UI a long time ago. I know you know the name, but I'm quite a dinosaur. [00:03:06][17.4]

[00:03:09] Joe Colantonio: Same. [00:03:09][0.0]
[00:03:11] Naeem Akram Malik: So I got a chance to work on Jmeter just a few months ago, and that's when I actually fell in love with the technology. It is really wonderful. So on my day job, I got the chance to explore Jmeter because I had to do some work-related stuff. So I got introduced to Jmeter and then I started learning about it. And ever since I've been working on it and I've been thinking about how to prepare a course about Jmeter. I have drafted an outline and I'm working on it. I would like to publish one course before the Black Friday. I'm working on it and I hope I will be able to do it alongside the blog writing because I have been writing a bunch of blogs lately, so that's actually a new thing. I have been blogging since 2009, but the paid blogging gigs or the pro blogging gigs have came a lot lately and I'm happy about that. But yeah, the course is also in the making and you could expect it in a couple of months. [00:04:11][59.6]
[00:04:11] Joe Colantonio: How exciting. I will promote it once it goes live, so just let me know. That is awesome news. [00:04:16][4.4]
[00:04:16] Naeem Akram Malik: Oh my God, that would be great. [00:04:17][1.1]
[00:04:18] Joe Colantonio: What I love is, what's even better is you said you're kind of new to Jmeter. So how did you learn Jmeter then? How did you get up to speed? Because it wasn't an awesome class like you're about to create. How did you struggle and how did you learn on your own? [00:04:31][12.3]
[00:04:31] Naeem Akram Malik: Yeah, basically there are a whole bunch of classes. So first of all, like before this last February last year, I forced a class, I had a Pluralsight subscription, I learn teaching courses myself, but I learned a lot of courses. I don't teach as many courses. I learn a lot of courses. So I've watched a bunch of courses from Pluralsight and then I got a training from a colleague at our company. He was also experienced in Jmeter and after that I didn't get a chance to use the stuff which I had to learn and I had to put it on ice for a few months. So first of all, for the Pluralsight course, then an in-house training, and then I came to this new place where I had to use Jmeter for all practical purposes. And I thought, Oh my God, what should I do now? So I ran around and I found another course online. I think it was on LinkedIn Learning. Yes, I found a course on LinkedIn Learning, I worked it. But still there were a lot of unanswered questions. And then I went to Jmeter's very own documentation for like finding answers related to the things which I needed to do. And then there are this Blazemeter blog, which is also a very nice resource. You can check it out. There are a lot of topics. They are covering them very nicely. So these was not one source. It was like Pluralsight, LinkedIn Learning, YouTube Blazemeter blog and I don't know what else. Yeah, a lot of things. So it took me a while to understand it and luckily I had the time. My employer gave me the time to explore and to come up with a solution to learn. And so I was like learning on one side and then implementing it practically on the other hand. And that's how I got into the groove. [00:06:13][101.6]
[00:06:14] Joe Colantonio: All right. So, you mentioned how you had to learn Jmeter for your job. Did you also have to learn performance testing at the same time, or did you already know about performance testing? And it was just a matter of learning Jmeter? [00:06:24][10.4]
[00:06:24] Naeem Akram Malik: I knew a thing or two about performance testing and I had to learn about it as well alongside Jmeter. And in fact, I think that I'm not like an expert in performance testing. I know a thing or two, but I'm still learning. [00:06:37][12.8]
[00:06:38] Joe Colantonio: Cool. So it seems like based on Udemy courses and I could be wrong. Is you're more of a C-sharp programmer, I don't know if that's correct or not. But if it is, why would you choose Jmeter? Are there anything that works with C-sharp that would have been a better choice for performance testing? [00:06:52][14.7]
[00:06:53] Naeem Akram Malik: Yeah, I have a lot of experience in Jmeter, but last year I changed my technology stack to Java. So I have been working in Java since February of this year, February 2022. I've been working with Java completely. I had past experience of Java as well, so it was not a problem. Switching the text type was not a problem. So checked my text stack like earlier this year. So that is one thing about my experience. I got a lot of C-sharp experience and I also got a lot of Java experience now. And the both languages are similar. There are a lot of similarities. So trust and easy transition, that's one thing. And about picking the Jmeter basically, there is nothing else like Jmeter out there when it comes to the .Net platform. There is postman for repeated testing, but it cannot be used for performance test. So there is no tool available which works only based on C-sharp. So that is why I crossed over to Java and then I picked up Jmeter because I believe it's the best free and open-source tool out there for performance testing. [00:07:57][63.6]
[00:07:57] Joe Colantonio: Perfect. So I thought we start working through like talk to basically your latest blog post that you actually did write for Blazemeter, I believe, on how to debug Jmeter test scripts. And so I guess the first part was you have a section on how can teams debug Jmeter test scripts? Why did you focus on debugging Jmeter test scripts? Is that something you found as something that was difficult part of Jmeter? [00:08:19][21.8]
[00:08:20] Naeem Akram Malik: Yeah, that is a very important thing, that debugging is a very important part of programming, any programming exercise, and software development. Debugging is very important because we always make mistakes. People make mistakes intentional, unintentional, for whatever reason. So debugging the Jmeter scripts can be tricky because it is a little different from your common scripts that you write. So it is a tricky thing and I believe a lot of people need help in this regard because I myself faced some problems related to debugging where I was scratching my head while executing my performance scripts and I didn't know what was going on, so I had to learn about debugging. And then I figured out that, okay, this is how it should be done. And then came up the opportunity to write about this Blazemeter asked me if I could write about this and I jumped on the opportunity. So that's why I wrote it. I really believe that it's an important topic. [00:09:17][57.5]
[00:09:18] Joe Colantonio: Nice. I'm used to performance testing using LoadRunner and I actually never really use Jmeter. There are some things in here I'm learning myself. And the first one was samplers. So I guess what's a sampler? Because it always seems like everything has a sampler and you have a section on Jmeter debugging sampler. So debugging is really important. So what did you find challenging about debugging in Jmeter that you thought, well, I need to write about it? [00:09:41][22.9]
[00:09:41] Naeem Akram Malik: Yeah. So first of all, if you are writing code using C-sharp in visual studio or in intelliJ idea we can simply put a breakpoint anywhere in or script and as soon as a breakpoint gets hit, we can see the values of various variables, other important things like hovering the mouse and so in case of Jmeter, that does not happen. When we are creating Jmeter scripts, we make a mistake. We don't get the luxury of the breakpoints. The breakpoints are not an option for Jmeter. So I had to condition myself and I had to learn that how I have to live without the breakpoints. So the breakpoints come in very handy when I was working on Selenium like in C-sharp and Java. So that was the main difference for which I thought that, okay, this is an important topic and I should write about it. [00:10:37][55.9]
[00:10:38] Joe Colantonio: Absolutely. So is that where the Jmeter debugger sampler came into play? Like what is the Jmeter debug sampler? [00:10:45][6.8]
[00:10:45] Naeem Akram Malik: Yeah. So the Jmeter debugger sampler is like the core of the debugging functionality which is provided by Jmeter. So that is where the Jmeter debugging sampler comes into play. It allows us to see the values of different variables which are used inside of performance testing scripts. On that run time, we can run our script and see what different values at different times. So that is how to debug sampler is helpful and it can be compared to the breakpoint, but it is somehow relevant to the breakpoint when we are like using visual studio or Java. So we have really breakpoints in intelliJ and visual studio. We don't have breakpoints in Jmeter. So the debug sampler is kind of an equivalent, it allows us to see the different variable values in our performance testing scripts. So that is basically the debug sampler comes into play. [00:11:41][55.6]
[00:11:42] Joe Colantonio: How does that work because it's like a print statement or does it like at the end you have a log file and it just prints out like I did this, this was the value I sent. Here's what I got back. [00:11:50][8.2]
[00:11:51] Naeem Akram Malik: Yeah, it looks like a print screen, essentially. So you wouldn't have, I believe, a skip on my screen. I can share my screen to show it to you as well if need be. So it looks like an all inclusive print screen, which is going to print all the variables which are being used inside of performance testing scripts at any given time wherever you place it. [00:12:13][22.2]
[00:12:14] Joe Colantonio: So is that where you use the Jmeter debug post processor? Does that help you read that after the fact then? [00:12:19][5.1]
[00:12:19] Naeem Akram Malik: Yeah. So the Jmeter debug post processor has got a different scope of operation. A post processor is essentially placed inside another samplers. So in Jmeter we have different samplers. A lot of things are organized in the samplers. So that debug sampler and that debug post processor have a main difference that a sampler is like a standalone thing and the post processor is like it comes underneath and the other sampler, like it comes underneath an http sampler. For example, if you have http sampler or tcp sampler. We want to see the very well information which is specific to that sampler. In that case, we should use the debug post-processor. So we can say that the debug sampler has got like a very wide scope and the debug post processor has got a narrower scope. [00:13:11][51.9]
[00:13:12] Joe Colantonio: So I guess then the next question that you cover is what's the scope of the JR223 sampler? [00:13:17][5.1]
[00:13:18] Naeem Akram Malik: Yeah. So that is like an additional thing. So it is the scope of JR223 sampler is seem like the debug post processor but it is not created for debugging purposes. Then I wrote about it in my blog, I was essentially reusing it for my own purposes. So the jsr223 can be used to write a script in multiple languages, like in JavaScript, in Java that is growing with support. So the simplest use for debugging could be that if you want to print only one variable in the log, if you want to print only one variable in the Jmeter log, then we can use the JSR223. I hope I'm not botching the number is like tricky 223 or 232 but there is code execution controller, code execution sampler in Jmeter which allows us to run a lot of my programming script, so I repurposed it for debugging. [00:14:12][54.2]
[00:14:14] Joe Colantonio: Cool. So how did you come up with that idea? You were just messing around with samplers. It's like, Oh, I can reuse this to help me with debugging. Or did you find that tip somewhere else? [00:14:20][6.8]
[00:14:21] Naeem Akram Malik: Yeah. All have a story. So I have been like doing coding. I have been writing code for such a long time. I have been like using print screen and test or debug all those statements to print stuff freely. Like whenever I would want, I would just throw it to a bunch of like print lines out there and the text would show up in the logs, in test automation logs, in the Selenium logs. But now here I was in a situation where I couldn't just like really put anything out there. So I thought, what could I do? And this was the idea that came to my mind, okay, let's do it. [00:14:58][36.2]
[00:14:58] Joe Colantonio: My cool. Awesome. So how does Jmeter work? I know, like I said, I have experience with LoadRunner and it's like an enterprise solution that has analysis and reports. You can monitor things. Jmeter to me sounds like just something that does the load, but like how do you does it have a reporting feature and how do you analyze different meters like CPU and memory usage using it? [00:15:18][20.2]
[00:15:18] Naeem Akram Malik: Yeah. So like Jmeter is basically an open-source tool, so it has got a lot of plugins around it. LoadRunner UFT LoadRunner it is a great tool definitely and it is a premium tool. So Jmeter is basically trying to bring all of this together using a plugin. So we have like a lot of plug-ins and we have a lot of like built-in support as well for reports, for example, first of all, for generating a report. If you want to see the test report, the Jmeter is going to generate a performance test report which can show us the Apdex index. Apdex is basically a metric which are used to track the performance of various API and web pages. So the Jmeter by default has got the support to generate the Apdex index in an html file so we can configure to generate an html report, which shows us the latency of different requests, which are just the average time of like different operations http get and http post and all those. It also shows us if there are any errors in there and then we can configure it. We can configure Jmeter to work with other tools like perfmon, for example, on remote servers. And there are the like sequel monitoring tools as well, which can be configured to work with Jmeter and using these we can easily create a report that suits our purpose. So basically Jmeter uses the plug-ins and other things around it, like Lego pieces pieced together everything you need. [00:16:52][94.2]
[00:16:53] Joe Colantonio: How do you find them though? Is there like a library or somewhere you go that list out everything? I guess like I said, Jmeter does have good documentation we're able to find all these is just a matter of doing Google searches to find all the different ways you can do that? [00:17:04][10.9]
[00:17:04] Naeem Akram Malik: Yeah, Jmeter has got a plug-in search functionality built-in, so there is a Jmeter plugin manager so we can use the Jmeter plugin manager. It does not come installed with Jmeter out of the box, but the solution is very simple. We just need to download Jmeter copy of it. So once we have the plugin manager, we can use it for setting any plugins and there is a plugin directory online as well where we can find the plugins which are available and we can download the plugins as well. Although if we're like checking up new machines then it would be like our own responsibility to take care of the plugins. Otherwise, the scripts could break. They don't always break, but they could break. So that's how plugins work in Jmeter. [00:17:46][41.6]
[00:17:47] Joe Colantonio: So this was posted on Blazemeter. So I guess what is Blazemeter? Did you use Blazemeter? Does Blazemeter make using Jmeter easier? Like maybe a little bit more info about what is Blazemeter if you even use it at all. You just blog in there. [00:17:59][12.2]
[00:18:00] Naeem Akram Malik: Yeah. I have done a little bit research about Blazemeter. I have not used it in my personal project so far, so I just told them a blog post about Jmeter. But as far as I know, Blazemeter at first used to be all about creating Jmeter scripts easily and running them. Blazemeter provides a recorder which can be used to create Jmeter scripts very easily through your browser. This functionality does not come built-in with Jmeter, so Blazemeter they innovated in this way that they provided a recorder which you could use through your browser to create jmx, jmx are the Jmeter files. So that is one innovation by Blazemeter. But they have been like out there for more than a decade, I believe now, and they now have rebranded themselves as Continuous Integration Platform, a full-blown CI/CD platform. So they started from Jmeter, but now Blazemeter has like grown into a lot of things, but I haven't used all of them, so I can't really give you the marketing before marketing. [00:19:02][62.1]
[00:19:04] Joe Colantonio: So what were you testing? Are you testing APIs as we originally said, but this project was about? [00:19:08][4.4]
[00:19:09] Naeem Akram Malik: Yeah, well, that's the interesting part about Jmeter. The general concept about Jmeter is that it is used for API testing, but it can be used for website testing as well. So when I got to this new job, it's a small software house, a small software shop, it's called Gray Mat. So when I got to Gray Mat, what happened was that they were testing the performance website which they are creating for a client actually ready with the application in .Net. So they were opening the different pages of this website multiple times, four or five or ten times. People would sit open the pages and then note down the time from the network monitoring tab in the Chrome browser, and then they would put it in an Excel sheet. And then based on that, they would calculate the averages and other things. So when I got there, I saw an opportunity. I did this activity a couple of times, but then I saw an opportunity that we could do this for Jmeter. So I started working on that and told them that I believe we can do this. And they told me, Yes, you think we can do this? Go ahead, let's do it. So there are good people, innovative people. So they gave me the space to innovate. So I went ahead and I started automating all of this process using Jmeter. And along the way came many challenges, which I was luckily successful to resolve. So that is how it started. I am testing a website using Jmeter. The performance of our website. [00:20:32][83.8]
[00:20:33] Joe Colantonio: What are some of the challenges then that you ran into? [00:20:35][2.1]
[00:20:35] Naeem Akram Malik: Yeah, yeah. First of all, the challenge was how could I extract the cookies so first of all what to do about the cookies? And then I came to know that, okay, it is easy to extract the cookies. So I found an article about it on I think it was a StackOverflow post. So I found about it and I use what I found in there. I put it together and repurposed it for like my own thing, so I got to use it. And then there was another challenge when I was creating a new item using this website, a unique id was generated and I didn't know how to extract it. I had read about the redex extractors, the redex postprocessors in Jmeter, but I had never used them in practice. So I like first of all, I figured out like I should use the redex post processor and then again I got stuck with the redex and then was the post about the regular expressions. And then I took a day or so. And then what I got very good at it eventually because I have some background with the redex. So these were a few challenges which came my way. And then generating the report was also a challenge because I wanted to have something which I could send to the stakeholders. I couldn't send them the screenshots of the Jmeter everyday that took this much time was taken by this call, etc. etc.. So what I did was that next thing I figured out how to generate reports using Jmeter through the command line. And Jmeter allows us to generate reports through the command line and they are in html format. It's an html directly which we can use, which we can easily send to our stakeholders, which you can put on like a CI/CD server so that everybody can see it. So these were a few challenges and there were many more I would be. I'm here to talk all night. No problem. [00:22:25][110.0]
[00:22:28] Joe Colantonio: Cool. Okay, Naeem, before we go, is there one piece of actionable advice you can give to someone to help them with their Jmeter performance testing efforts? And what's the best way to find or contact you? [00:22:37][9.5]
[00:22:38] Naeem Akram Malik: Yeah, well, the advice I would like to give anybody that, first of all. So the advice I would give someone who's starting freshly with Jmeter is that they take it easy. Don't worry, there are a lot of resources out there. It is only a matter of time then you will be able to find them and then you'll be able to put together your own solution so you can start with good courses. There are many good courses out there already, like go to a site on LinkedIn learning that are very good courses already available. If you can like buy some then I highly recommend like investing in yourself. So that's one thing. And then we can easily, slowly and gradually. The more important thing is that if you are starting on like a greenfield project we call it. If you are a greenfield project, then you are going to piece together things slowly and gradually. So I highly recommend that you start learning from an online course and then you start consulting the documentation provided by Jmeter. And then there is this Blazemeter blog. They also have a lot of useful things. You should go step by step and build your performance testing steps slowly and gradually. And like once you have something which is useful, then you can refine it further. So take your time, stay patient and build it piece by piece. And ultimately you'll get there. [00:23:57][79.7]
[00:23:58] Joe Colantonio: Awesome. And the best way to find or contact your name. [00:24:00][1.3]
[00:24:00] Naeem Akram Malik: Yeah. So best way to find or contact me is first of all my LinkedIn page. Please share the link. I can link out to my LinkedIn profile. You can drop me a message over there. You can also contact me through my email or I have this website testautomation.com. It is going to take you to my test automation course for now, but you can find all of my social links from there too. There's my LinkedIn profile, there is my email, and then there is also my blog. My blog here aprogrammersday.blogspot.com. If you go there, you will find contact me form and you can send me an email through there as well. I've been writing there since 2009, so and that's how I discovered that. I have a knack for teaching, a knack for like showing off my book. Yeah. So these are few ways that you can contact me. [00:24:51][51.5]
[00:24:52] Thanks again for your performance testing awesomeness. For the links of everything we value we covered in this episode. Head on over to testguildcom.kinsta.cloud/p97 and while you're there make sure to click on the tri them both today link under the exclusive sponsor's section to learn all about Smartbear's too awesome performance test tools solutions Load Ninja and Load UI Pro. And if the show has helped you in any way, why not rate and review it in iTunes? Reviews really do matter in the rankings of the show, and I read each and every one of them. So that's it for this episode of the Test Guild Performance and Site Reliability Podcast. I'm Joe. My mission is to help you succeed in creating end-to-end full-stack performance testing awesomeness. As always, test everything and keep the good. Cheers. [00:24:52][0.0]
[00:25:37] Hey, thanks again for listening. If you're not already part of our awesome community of 27,000 of the smartest testers, DevOps, and automation professionals in the world, we'd love to have you join the FAM at Testguild.com and if you're in the DevOps automation software testing space or you're a test tool provider and want to offer real-world value that can improve the skills or solve a problem for the Guild community. I love to hear from you head on over to testguild.info And let's make it happen. [00:25:37][0.0]
[1416.8]

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Brian Vallelunga TestGuild DevOps Toolchain

Centralized Secrets Management Without the Chaos with Brian Vallelunga

Posted on 09/25/2024

About this DevOps Toolchain Episode: Today, we're speaking with Brian Vallelunga, the founder ...

A person is speaking into a microphone on the "TestGuild News Show" with topics including weekly DevOps, automation, performance, and security testing. "Breaking News" is highlighted at the bottom.

Testing Castlevania, Playwright to Selenium Migration and More TGNS136

Posted on 09/23/2024

About This Episode: What game can teach testers to find edge cases and ...

Boris Arapovic TestGuild Automation Feature

Why Security Testing is an important skill for a QEs with Boris Arapovic

Posted on 09/22/2024

About This Episode: In this episode, we discuss what QE should know about ...