ahart
11 years agoOccasional Contributor
[Resolved] How can I modularize/do this better?
I have a bunch of web service operations that follow a similar pattern. A request is made to one operation to initiate an asynchronous extract. It returns immediately with a "requestId" assigned. Every operation, regardless of the data it is extracting, follows this same pattern, returns the same status info.
Then, we call another operation using that requestId as a parameter. We also can include a "chunkNumber" parameter, which is to identify which "chunk" of the results is to be returned. For example, if we have a total of 95 records extracted, and the chunkSize is 10, then there would be 10 "chunks" available for download, 1 through 10, with the last chunk containing only 5 records.
If we pass in a chunkNumber that is 0, then we do not return any of the results extracted, we simply return the status metadata about the request: whether it is pending, completed, inprogress, etc., the number of rows extracted if it is completed, the number of chunks available, the chunkSize, etc.
So, to setup a SoapUi test suite for one of these operations, I have the following test steps:
(1) RequestData
(2) Xfr Requestid from (1) to steps (3) and (8)
(3) GetData for chunk 0 for the request.
(4) Delay
(5) Conditional: Repeat until NOT PENDING or INPROGRESS (check the status returned in 3, go back to 3 if it is not completed or in error)
(6) Groovy Script: dumps out the status info and does a goto step (10) if there are no results
(7) "initChunkNumber" Properties Step: define "chunkNumber" property set to 1
(8) GetData for chunk ${"initChunkNumber#chunkNumber}
(9) Groovy Script: gets the chunkRequested in (8) and if < chunkCount increment the chunkNumber, update the property in (7), GOTO (8)
(10) Print out a "Finished Message"
So, I'm pretty sure that all of this could be condensed into a single Groovy Script test step. I would like to know how to do that, but I am having problems with how to iterate a test step varying some request parameter, all in script. Seems like it should be a common use case, so if someone can point me at an example, I'd appreciate it.
Ideally, instead of having to do this for every pair of request/get operations, I would like to be able to modularize this so that I could pass in a requestId, maybe pass in either a test step, or the operation to perform, and have this same functionality of hitting it until it is done, then iterating through all of the chunks to be retrieved.
Is that possible?
Then, we call another operation using that requestId as a parameter. We also can include a "chunkNumber" parameter, which is to identify which "chunk" of the results is to be returned. For example, if we have a total of 95 records extracted, and the chunkSize is 10, then there would be 10 "chunks" available for download, 1 through 10, with the last chunk containing only 5 records.
If we pass in a chunkNumber that is 0, then we do not return any of the results extracted, we simply return the status metadata about the request: whether it is pending, completed, inprogress, etc., the number of rows extracted if it is completed, the number of chunks available, the chunkSize, etc.
So, to setup a SoapUi test suite for one of these operations, I have the following test steps:
(1) RequestData
(2) Xfr Requestid from (1) to steps (3) and (8)
(3) GetData for chunk 0 for the request.
(4) Delay
(5) Conditional: Repeat until NOT PENDING or INPROGRESS (check the status returned in 3, go back to 3 if it is not completed or in error)
(6) Groovy Script: dumps out the status info and does a goto step (10) if there are no results
(7) "initChunkNumber" Properties Step: define "chunkNumber" property set to 1
(8) GetData for chunk ${"initChunkNumber#chunkNumber}
(9) Groovy Script: gets the chunkRequested in (8) and if < chunkCount increment the chunkNumber, update the property in (7), GOTO (8)
(10) Print out a "Finished Message"
So, I'm pretty sure that all of this could be condensed into a single Groovy Script test step. I would like to know how to do that, but I am having problems with how to iterate a test step varying some request parameter, all in script. Seems like it should be a common use case, so if someone can point me at an example, I'd appreciate it.
Ideally, instead of having to do this for every pair of request/get operations, I would like to be able to modularize this so that I could pass in a requestId, maybe pass in either a test step, or the operation to perform, and have this same functionality of hitting it until it is done, then iterating through all of the chunks to be retrieved.
Is that possible?