User:DKinzler (WMF)/RESTbase development setup

'Daniel’s field nodes on running RESTbase for development. YMMV.'

Installation:
See https://www.mediawiki.org/wiki/RESTBase/Installation

Daniel’s config: https://phabricator.wikimedia.org/P49564

In config.yaml, adjust the domain part of the path specs to match any domain (around line 45 and 67):

Under x-sub-request-filters and for apiUriTemplate as well as parsoidHost change the domain to be the address of mediawiki as seen from inside the container. That’s probably the host’s IP. Try :

To only have one worker to deal with (useful for attaching a debugger):

I also changed this in this logging section at the bottom, for sanity:

Run in plain node container
NOTE: we tell the node debugger to listen on port 9229, but we also  publish port 9230. That’s because restbase uses ServiceRunner, which (depending on setup) starts worker processes for restbase, which will then use the next ports, starting at 9230.

Setting  will make everything run in a single process, so RESTbase will use debug port 9229.

The output should look something like this:

Should show something like:

Verify that RESTbase is up and running:
check that the port is exposed:. Shows

returns. Yay!

NOTE:  must be the hostname used in  ! If  contains a port number, the “:” must be encoded, e.g.

Call Parsoid endpoint
^-- this should do something in restbase, even if it fails to connect to mediawiki to actually get the html.

NOTE: use  to only see the response header

Run Mocha Tests
If a RESTbase container is already running

To start a container for running the tests:

Then, inside the container, run:

If you want to debug the tests, add.

NOTE: Mocha tests use their own config, config.yaml is ignored! Mocha tests will hit the beta cluster!

If Mocha tests for parsoid transformations are failing, you may have to adjust the parsoid host URL:

In config.fullstack.test.yaml, change the parsoid host URL so it uses HTTPS:

Not that RESTbase will connect to this host but it will send  in the headers.

If you are getting TLS errors, you may have to set.

WebStorm Setup
In WebStorm, create a new run configuration of the type “Attach to Node.js/Chrome”.

Set the port to the appropriate number (9229 or 9230, depending on setup).

Set up path mappings to match the volume mount point in the docker container, e.g. map the project directory to.

Using Blubber
In .pipeline/blubber.yaml:

add this for the development and test variants:

Reason: sqlite needs to be able to write to ./db.sqlite3

To enable debugging, modify the entrypoint of the development and test variants:

Run RESTbase from the image blubber defined:
NOTE: looks like the dockerfile generated by blubber doesn’t have an EXPOSE directive. Why?...

HOW can I expose ports in blubber?

DOH: wasted an hour because I put the parameters after the image name, instead of before…

WebStorm setup
In WebStorm, create a new run configuration of the type “Attach to Node.js/Chrome” [TBD]