Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Command line unit test (ml local test) fails with 404 not found error #324

Closed
venuiyengar opened this issue Dec 18, 2014 · 7 comments
Closed
Assignees

Comments

@venuiyengar
Copy link

I had some issue while deploying module related to xcc connectivity and I was getting
Roxy::Http : request failure count: 1, exception: #<Errno::ECONNABORTED: An established connection was aborted by the software in your host machine.>

I tried to run unit test from command line after un-commenting test related attributes in build.properties. The unit test uses port 8042 and apparently you can run the test from the browser http://loccalhost:8042/test. However when you run "ml local test" it gives an error related to name space. I get the same 404 error while accessing http://marklogic.com/rest-api through the browser

C:\Users\viyengar\work\marklogic_massmutual\massmutual>ml local test
ERROR: 404 "Not Found"
ERROR: <rapi:error xmlns:rapi="http://marklogic.com/rest-api"><rapi:status-code>404</rapi:status-code><rapi:status>Not Found</rapi:stat
us><rapi:message-code/><rapi:message>/test/list</rapi:message></rapi:error>
@grtjn
Copy link
Contributor

grtjn commented Dec 19, 2014

Roxy Unit Testing depends on a particular set of files that need to be uploaded to the modules database. Unfortunately, when creating a new Roxy project with app-type 'rest', those files are left out.

You need to copy all files within https://github.com/marklogic/roxy/tree/master/src/test, either by cloning Roxy manually elsewhere, or by creating another Roxy project with app-type 'hybrid' or 'mvc', and copying the folder src/test/ over. Follow with a deploy modules.

That will at least allow you to run http://localhost:8042/test/, but ml local test will still fail. That is because it is expecting the Roxy MVC/Hybrid rewriter, and that is not installed for the REST type projects..

Alternatively, you could re-create your Roxy project, but then with app-type hybrid. That might be easiest for the time being..

@grtjn
Copy link
Contributor

grtjn commented Dec 19, 2014

Dave goes through a bunch of these details, also for REST type, in this tutorial video on Roxy Unit Testing:

https://www.youtube.com/watch?v=PDiGN2ZYmQQ

@grtjn
Copy link
Contributor

grtjn commented Dec 19, 2014

@dmcassel / @paxtonhare: I do think this needs some attention. Running ml local test could detect its missing src/test/, and it could help download and deploy that code. Also, we need to make a different call (e.g. not to /test/run) to make ml local test actually work.

I had the impression it should be something like /test/default.xqy?func=run. That seems to get you further, but then you come across the tests that are included by default, and those seem to depend on other modules, like /roxy/lib/cpf.xqy. It stopped running after not finding that?

@dmcassel
Copy link
Collaborator

I did change testing a while ago so that it should work with app-type=rest, but it does still require manually copying over. Also yes, the provided tests are testing the MVC code, which isn't normally there. When using unit testing with an app-type=rest, the provided tests should be looked at as examples only.

Maybe as part of "ml new", we should prompt for whether unit testing is desired and copy the appropriate files over. Alternatively, when you run "ml {env} test", we could see that the directory pointed to by "xquery-test.dir" is empty/non-existent and offer to initialize it. That would require pulling down some code from GitHub, but would be the most flexible option.

I'll write up a wiki to describe the current state of things.

@dmcassel
Copy link
Collaborator

Just wrote up a wiki on unit testing REST applications. Reviews welcome.

With that written up, I propose closing this ticket. @venuiyengar, has your question been answered?

@venuiyengar
Copy link
Author

Sounds good to get the unit tests on demand depending upon the user's preference. However, the existing command line option should be removed or will it work once the files are copied over? In my case the tests did work by running through the url http://localhost:8042/test

Please clarify - Thanks

dmcassel added a commit to dmcassel/roxy that referenced this issue Dec 19, 2014
paxtonhare added a commit that referenced this issue Dec 19, 2014
#324 fixing command-line test so that it doesn't depend on the mvc/hybri...
@dmcassel dmcassel added the bug label Dec 19, 2014
@dmcassel dmcassel self-assigned this Dec 19, 2014
@dmcassel
Copy link
Collaborator

@venuiyengar, the dev branch was just updated with a fix such that "ml {env} test" will work with REST applications.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants