Creating Virtual Services from Recorded Traffic

Welcome back. In our last video, we set up a Parasoft proxy to intercept the calls between our application and our back-end system.

Now, what we want to do is use that interception and capture the traffic from the application to the dependency and use that to create a virtual service. I.

In this video, we will cover the following topics. Recording traffic, Creating a virtual asset from that traffic, Update the data in the repository, and Redirect the proxy to the virtual service.

To start the recording process, we want to head back to Virtualize and look at the Virtualize's perspective. We can find that in the top right-hand corner and click on Parasoft Virtualize. And just like monitoring, we can start the recording from here or we can right-click and start recording. As soon as we select, you will see the icon changes with the little red light. Additionally, you'll see information in your console indicating that you started recording and where your traffic file is going to go. Now that we are recording, we can simply exercise the application.

Let's pull that backup. Click on here again. Log back in. Once you log back in, you're going to go ahead and go to Request Loan. I'm going to do a couple of different loans here because we want to get a lot of data into the system.

So, we're going to start with the first one of $1,000, with a $10 down payment. Click Apply now. I'm going to go to request another loan. This time, we're going to do $1,000,000, with a $1 down payment, and apply. And you can see we got an error on this one. And then I'm going to go to Request Loan again. And just so we have some extra data, I'm going to do a $2,222 loan with a $22 down payment. Now, usually at this point, I would run a large portion of my UI tests, regression tests, and API test anything I could to capture more traffic. The more traffic I have, the better my virtual service will be. I think this is sufficient for now, so I'm going to head back to Virtualize. I'm going to stop the recording, which I can do by clicking here. Again, I can also do it by clicking here. I will then see if I look at my console that all those requests and responses, which is six messages. So this means that there were three requests and three responses. And the traffic file is called LoanProcessor.txt. This is something that Virtualize automatically created. So now I can take that traffic and create my first virtual asset from the traffic. To do that, I'm going to go into my virtual asset explorer. I'm going to right-click. I'm going to click Add New virtual asset. Now I want to name this the same as the back-end service that I'm simulating. So, we're going to call this Loan Processor.

Then we're going to click Next and we're actually going to do this based off of a traffic file. So, I'm going to click Choose Parameterized Messages. And this will store the data into my data repository. So now I'm going to choose a traffic file. So when I go to the Workspace, I'm going to look for the traffic file that I just got. So we're going to take this one here and click Okay. This is where a Virtualize is going to do the majority of the heavy lifting.

So what I'm going to do is tell it to use the Embedded Server storage area, top to down to Embedded Server that is called a repository. I'm going to call this Loan Processor Demo and I'm going to do a quick validation to make sure that there's not a thing.

So, validation succeeded. And then click Next. In this case, it realizes that it is XML and the details for putting the request together will be held in the request body. So that's correct. And click Next. Instead of all six messages, three of them were paired together and the operation type was request loan. So that's here. It's going to auto-configure my services for it. I'm going to let it do the auto-configure, but I'm going to uncheck this so I can see exactly what it's doing.

So here we can see the request correlation section which is basically saying it's going to look at any time I did a loan and down payment, it's also going to look at my available funds. But since I didn't modify my available funds, I'm going to go ahead and remove that from the decision-making criteria. We'll talk more about this in a subsequent video.

Finally, I'm going to feed the Parabank WSDL to my virtual service. So we're going to click on Service Definitions and you can find the Parabank WSDL at localhost:8080/parabank/services/LoanProcessor?wsdl. Click Next.

Having a service definition file will always make your virtual services much better because it will have all the scheme information that you need. Now go ahead and click Finish and we're going to go through the traffic file and it'll create the virtual service for me. 

After it's created the virtual service, we can see it here LoanProcessor.pva turn to go ahead and open that up. If we click on request loan, we can see the response and we can see that that response is coming from the data sources and the data to repository named request loan.

So, we can quickly take a look at the data source request loan by opening the table. And we see pretty much the same information that we entered when we did our request. If this, then this is the response.

All right, let's go ahead and change something about our request. Then we'll exercise our virtual service. Let's look at, say, $1,000 request. And if we open up the response here and we can look at the loan provider and I'm simply going to change this to Virtualize.

Now we need to redirect our incoming requests toward our virtual service. To do that, we need to know the endpoint of the virtual service, and we need to redirect the proxy to point to the virtual service. And all of that can be accomplished here in the server view. Let's go ahead and open our virtual assets. And here we see our first virtual asset, which is Loan Processor. So, let's go ahead and double-click.

I'm going to take a look at that endpoint. So from the traffic, it read that proxy because that is where we recorded it from. What we should do here is change our path to say virtual. Because we don't want our proxy in our virtual asset to have the same endpoint. Then what we need to do is feed back into our proxy. So, let's just grab this endpoint. Make sure you save it.

Once we have this open, we're going to double-click here, and this is going to actually open up our proxy. So instead of going to the real servers, which is what we've been doing to record the traffic, now we're going to let it go to the virtual service.

There's no need to change our target application, and we know that it's going to continue to go to the proxy that's here. Now when we say okay and save, we will be directing our application through the proxy. To point at the virtual service. Now the final step we need to do is enable our virtual service and we are good to go. So to do that, we go over here to the virtual service for Loan Processor and we click on Enable.

So what's happening now is the application is connecting through the proxy to the virtual service. We can test our connection to the application. And to do this, we can apply again for $1,000. So, we're going to open the Parabank. Apply for a $1,000. $10 down. And now when we click Submit, we can see that this traffic went through the virtual service as opposed to going through the real service.

Now that we've shown how to create virtual services from recorded traffic.

Stay tuned for our next video for Creating a Virtual Service from a Service Definition. 

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Pen