ml-gradle icon indicating copy to clipboard operation
ml-gradle copied to clipboard

Test Connection

Open jamesagardner opened this issue 6 years ago • 6 comments

As a developer who is adding new connection details to an existing ml-gradle project. I want to be able to test the connection settings to a given MarkLogic cluster without making changes to the cluster. This cluster is of high value and is used by other people, but I'd like to eventually start managing this environment using ml-gradle. I want to be confident I can use ml-gradle from a given machine, using a set of connection settings, when I'm ready to make changes to the environment.

After testing the connection I expect mlLoadModules and mlDeploy tasks to work using these connection settings.

It may be useful to take advantage of https://github.com/marklogic/java-client-api/issues/636 for testing the connection.

jamesagardner avatar Nov 12 '19 21:11 jamesagardner

@jamesagardner Just to confirm, you're expecting a new task here, right? Something like "mlCheckConnection"?

I'm tossing this into 4.0 as part of a plan to bump ml-gradle et al to 4.x once they depend on Java Client 5, which entails depending on Java 9+.

rjrudin avatar Dec 19 '19 13:12 rjrudin

@rjrudin a new task would be fine. Unless there is already some other diagnostic level task it makes sense to add on to.

jamesagardner avatar Dec 19 '19 14:12 jamesagardner

@jamesagardner I'm realizing now there are multiple connections to check. At a minimum, I think we'd want to ping 8002 to verify that the Manage API connection is good. Then there's the question of which REST API connections are known about and can thus be tested. I think ml-gradle would just test mlRestPort, but in DHF, that property isn't used - mlStagingPort, mlJobPort, and mlFinalPort are there, pointing to 3 different app servers.

Which connections did you have in mind for this?

rjrudin avatar Feb 07 '20 22:02 rjrudin

Proposal:

gradle mlPing [-PmlAppServicesPort] [-PmlRestPort]

By default, test connections to both app services and (if configured) the REST port. Allow overriding to test just the specified port. I would think DHF would override this task and add options for staging, job, and final ports. ml-gradle would want to use properties like mlAuthentication, mlUsername, ml*Password, etc.

dmcassel avatar Mar 10 '20 15:03 dmcassel

Moving this for now, as 4.1 is going to be focused on updating a bunch of third party dependencies.

rjrudin avatar Sep 14 '20 19:09 rjrudin

I think this could go a little further than just checking connection. As per OP it should give confidence a subsequent deploy should work, so it would be good if it would check all relevant user settings for sufficient privs, as far as ootb deploys go of course..

grtjn avatar Apr 21 '21 12:04 grtjn

Thinking of testing the following:

  1. It's almost certain that ml-gradle needs to talk to the Manage App Server, so do a ping call on that and print the results.
  2. As long as mlAppServicesPort is not 0, do a ping call on that and print the results.

The problem with testing mlRestPort is that for an initial deploy, that App Server won't exist yet. Also, that port will only be used for loading REST extensions; modules/schemas/data are loaded via mlAppServicesPort.

rjrudin avatar Aug 09 '23 19:08 rjrudin

Thinking that if ml-gradle can connect to the Manage app server, it can check to see if there are app servers with ports of mlRestPort and mlTestRestPort. And if so, it can create a DatabaseClient for each and try checkConnection on each as well.

rjrudin avatar Aug 10 '23 19:08 rjrudin

Tracking internally via DEVEXP-545 .

rjrudin avatar Aug 10 '23 19:08 rjrudin

Realizing now there are at least two kinds of outputs here:

  1. An mlTestConnections task that prints out the results of testing each connection. Useful for ad hoc testing of connections and easily seeing the results.
  2. A new TestConnectionsCommand that would cause e.g. mlDeploy to fail if any connection fails.

The second one above is a little tricky because for an initial deploy, the restPort/testRestPort servers won't exist yet, so we can't test them.

For the scope of this, I'm going with the first item. And I'm thinking mlTestConnections should throw a GradleException - that would at least allow a user to do ./gradlew mlTestConnections mlDeploy, causing the latter task not to run if the former fails.

rjrudin avatar Aug 29 '23 14:08 rjrudin

See #667

rjrudin avatar Sep 01 '23 14:09 rjrudin