How would one create an integration test that tests services and handlers? Is it recommended to use Coderunner on a CI or is there a better way? If Coderunner is the recommended way, is there an example somewhere that shows how to do it? Since the process doesn’t exit, how would you figure out when to start running the tests?
Hi,
you can try to clone an existing app, deploy handlers to the production mode, and so that the tests communicate with the “test” copy of the application. A cloned app would be nice for tests didn’t affect production backend.
Unfortunately, we have no examples of such testing. But perhaps in the near future it will appear.
Regards,
Stanislaw
Is it possible to programmatically empty the cloned application to run tests every time on a fresh environment? There is also the restriction on size of server code - how can we test our server code if it’s getting blocked with “Your application has exceeded a limit of the Business Logic deployment size on the current plan. All API calls will be blocked within 48 hours after the limit is exceeded.”?
You can use the Reset App
REST API which is used by Backendless Console (see the “Reset App” button on the main dashboard). Your code would need to login as a Backendless developer, get the auth-token
and then send the reset app call using the token.
As for the Business Logic limit (or any other limit for that matter) if the application is blocked, it will start rejecting all calls. Consider reducing the NPM dependencies by installing only modules you need. See this for more details: https://backendless.com/docs/bl-js/bl_node_modules.html
Regards,
Mark
Thanks Mark. This seems to be the biggest blocker - it seems like there isn’t a way for me to get my dependencies down to that size. The other issue is that creating a sandbox project to run integration tests has the same issue. I’m happy to pay once the app is in production but I can’t even develop my app to make it production-ready with these blockers.
If the app is reset and then cloud code is deployed, will the block be lifted? That could work for the sandbox app.
There is an NPM package for working with Backendless Console’s API https://github.com/Backendless/Console-SDK, it’s not documented but I believe you will figure out how it works
In theory you can setup your own environment which may work by the following scenario
- login as developer with ConsoleSDK (using your login/password for Console)
- create/clone a new Backendless App
- deploy BL into the app
- do some tests
- remove the test app
Regards, Vlad
Before going through your undocumented API to write a basic test, how does this get past the size limit?
Hi @Garrett_Gottlieb, with the current state of the system you would not be able to get past the size limit. There are two things which should happen:
- We need to add the ability to allow adding more than one instance of the function pack which increases the limit
- Your codebase or specifically the number of dependencies would need to shrink some.
What (1) means is it will cost more. How much more and how long it would take us to make the change is something we’re investigating. What would help us is if you could share a list of the top-level dependencies you have so we can see how common they are.
Regards,
Mark
It sounds like the only solution is to pay for your highest tier for a custom solution just to test my app. You can check the code, but one module I need is AWS.
there are already installed two npm modules globally
- aws-sdk@2.516.0
- lodash@4.17.15
So, if the version of aws is acceptable for you, just completely exclude that module in coderunner.json file.
Btw, this module takes approximately 40mb when executable code takes only ~2mb
how to exclude modules/files you can find in this answer Increase size limit for server code - #9 by vladimir-upirov
Or you can install the latest version of aws-sdk and exclude all the unnecessary directories/files, on the images below you can see how I’ve reduce the deployment size, but I believe there are a lot of files which can be excluded as well.
one more tip, before uploading your code you can check a size of the archive
npm run deploy -- --zip-size-confirmation --keep-zip
Regards, Vlad