Using tRESTRequest inside tRunJob for automated test purposes

Highlighted
Two Stars

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:

 

trunjob-jon.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


Accepted Solutions
Nine Stars JR
Nine Stars

Re: Using tRESTRequest inside tRunJob for automated test purposes

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.

Community Manager

Re: Using tRESTRequest inside tRunJob for automated test purposes

@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.


All Replies
Nine Stars JR
Nine Stars

Re: Using tRESTRequest inside tRunJob for automated test purposes

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.

Two Stars

Re: Using tRESTRequest inside tRunJob for automated test purposes

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

 

Community Manager

Re: Using tRESTRequest inside tRunJob for automated test purposes

@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.

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Talend Studio Improvements for API Services

Taken a look at the Talend Studio improvements for API Services

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Data Integration Success Stories

Take a look at some Data Integration success stories

Read