question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call service with optional fallback server

See original GitHub issue

When chaining service calls, whereby the input of a service is taken from the response of a previous service, any failed call could result in a failing scenario.

Examples:

  • the service is not implemented yet but there is mock data available
  • the service is unavailable (server is down, too much load)
  • the service data infrequently changes (refdata, codes, etc.)
  • the service is working but is either very slow intermittently timesout
  • the service is not critical for the whole senario

In some cases it would be very helpful if we could make requests with an option to fallback to another server (typically a mock server) if an error occurs

// very quick example

karate-config.js:

var fallbackEnabled = true // default is false
var fallbackServerUrlBase = 'http://localhost:3000'

var fallbackIfStatus = [ 5** ] // all server errors
var fallbackIfStatus = [ 500, 501, 502, 503, 504 ] // specific server errors

Test.senario:

When method post with fallback // uses config fallbackIfStatus 
When method post with fallback for [500] // override config fallbackIfStatus
When method post with fallback for fallbackIfStatus // fallbackIfStatus var

Reporting:

The step could be marked as a failure but allowed to continue and highlighted that it was a fallback response.

or marked as passed but highlighted that it was a fallback response.

I would be more than willing to implement this feature if it is desired and when the configurations and call specifics are finalized-

I understand that I could can accomplish the results with JavaScript. Just curious what you think about such a feature built in

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ptrthomascommented, Sep 27, 2017

Yes that’s it - Karate does clear the responseStatus !

Well, looks like you are doing some pretty advanced stuff with Karate. Let me know if something can be added to Karate to make things easier.

The solution here to me sounds like you should return the responseStatus from the target feature, actually it would be present by default in the JSON returned from the call. If you just grab and save it somewhere, won’t you be able to use it instead of doing karate.get() ? Something like this:

function() {
  var result = karate.call('target.feature');
  var status = result.responseStatus;
  // your logic here
}
0reactions
ptrthomascommented, Sep 28, 2017

closing due to inactivity - this is anyway a planned roadmap item - e.g. service virtualization.

you can achieve this in a custom way as of today by following the same approach as the karate-mock-servlet. the over-ridable method callback hands you the URL

Read more comments on GitHub >

github_iconTop Results From Across the Web

Call service with optional fallback server · Issue #152 - GitHub
When chaining service calls, whereby the input of a service is taken from the response of a previous service, any failed call could...
Read more >
fallback server when one service provider goes down
I have an RoR app running on Heroku and it was affected by the amazon outage and I want to figure out the...
Read more >
Cisco IOS Voice Command Reference - A through C - Cisco
Enabling the callfallbackcache timeout command sends a Service Assurance Agent (SAA) ... (Optional) Specific port number on the server.
Read more >
Fallback pattern · Microservices Architecture - Badia Kharroubi
Fail silent: In this case the fallback method simply returns a null value, which is useful if the data provided by the service...
Read more >
SIP Server Fallback TB5844.fm - Poly
This technical bulletin provides detailed information on how the SIP software has been enhanced to support SIP server fallback. Introduction. Server redundancy ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found