Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using tRESTRequest inside tRunJob for automated test purposes

Hi,

I'm trying to write a job in Talend Studio which starts an existing job using tRunJob to test it. The job under test is a rest endpoint using tRESTRequest parses json requests and saves to a db. However, the tRunJob does not run and instead the following modal popup error message is displayed:

 

0683p000009M6za.png

 

The tRunJob does work with the simpler scenarios outlined in the documentation, so it does seem to be something wrong with the tRESTRequest component in particular.

I am using Talend Studio 7.1.1.20190228-patch with Java 8 Update 151

 

Thanks

John

Labels (4)
1 Solution

Accepted Solutions
JR1
Creator III
Creator III

Hi John

I do not really get the scenario here. From what I understand, you are trying to start a job that is basically a REST service from within a data integration job in order to test the service. What do you expect the subjob to do? Even if it would start (which it does not), it would have nothing to do as the service may be listening but most likely only for a fraction of a second. If you want to test a service, you will have to start the service in a runtime, thus have it listen for requests and then run your tests against it. 

If anybody has a better idea, please feel free to add to this or to prove me wrong.

View solution in original post

3 Replies
JR1
Creator III
Creator III

Hi John

I do not really get the scenario here. From what I understand, you are trying to start a job that is basically a REST service from within a data integration job in order to test the service. What do you expect the subjob to do? Even if it would start (which it does not), it would have nothing to do as the service may be listening but most likely only for a fraction of a second. If you want to test a service, you will have to start the service in a runtime, thus have it listen for requests and then run your tests against it. 

If anybody has a better idea, please feel free to add to this or to prove me wrong.

Anonymous
Not applicable
Author

Hi,

 

Thanks for your response.

If I use the tRESTRequest component inside a job and run it within talend studio, it stays "open" listening for requests on the specified URL.

I wanted to write a "test" job which would not actually be deployed in anger, but just run from within Talend Studio. This job would:

1. Start the API job under test

2. Post some data to the endpoint

3. Assert that the data has been parsed into the database correctly

4. Stop the API job under test

That was my thinking, but I am new to Talend Studio and the problem space in general...

Thanks again,

John

 

Anonymous
Not applicable
Author

@JR is correct I believe.

 

You need to do this in a slightly different way. Leave your REST service exactly how it is in it's own job. Start it. Then call and test your REST service using another job. You can run multiple jobs in the Studio concurrently. 

 

What it sounds like you were doing was putting your REST service inside a job. This will not work. REST services do are not the same as jobs. A service is always on and listening. A job is batch. It has a start and and end. You can put a tRunjob (carrying out batch work) inside a service as the tRunJob will be run in a batch for every message sent to the service. But if you want to call a service you have written by a job, you need to have that service running in its own right outside of the job, then refer to it using a tRestClient or tRest component.