Skip to content

Commit

Permalink
mention S3 in testing docs, other cleanup #6783
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Nov 9, 2023
1 parent c55072c commit 5763b93
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions doc/sphinx-guides/source/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,42 +190,38 @@ Finally, run the script:
$ ./ec2-create-instance.sh -g jenkins.yml -l log_dir
Running the full API test suite using Docker
Running the Full API Test Suite Using Docker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To run the full suite of integration tests on your laptop, running Dataverse and its dependencies in Docker, as explained in the :doc:`/container/dev-usage` section of the Container Guide.
To run the full suite of integration tests on your laptop, we recommend running Dataverse and its dependencies in Docker, as explained in the :doc:`/container/dev-usage` section of the Container Guide. This environment provides additional services (such as S3) that are used in testing.

Alternatively, you can run tests against the app server running on your laptop by following the "getting set up" steps below.
Running the APIs Without Docker (Classic Dev Env)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Getting Set Up to Run REST Assured Tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While it is possible to run a good number of API tests without using Docker in our :doc:`classic-dev-env`, we are transitioning toward including additional services (such as S3) in our Dockerized development environment (:doc:`/container/dev-usage`), so you will probably find it more convenient to it instead.

Unit tests are run automatically on every build, but dev environments and servers require special setup to run REST Assured tests. In short, the Dataverse Software needs to be placed into an insecure mode that allows arbitrary users and datasets to be created and destroyed. This differs greatly from the out-of-the-box behavior of the Dataverse Software, which we strive to keep secure for sysadmins installing the software for their institutions in a production environment.

The :doc:`dev-environment` section currently refers developers here for advice on getting set up to run REST Assured tests, but we'd like to add some sort of "dev" flag to the installer to put the Dataverse Software in "insecure" mode, with lots of scary warnings that this dev mode should not be used in production.

The instructions below assume a relatively static dev environment on a Mac. There is a newer "all in one" Docker-based approach documented in the :doc:`/developers/containers` section under "Docker" that you may like to play with as well.
Unit tests are run automatically on every build, but dev environments and servers require special setup to run API (REST Assured) tests. In short, the Dataverse software needs to be placed into an insecure mode that allows arbitrary users and datasets to be created and destroyed (this is done automatically in the Dockerized environment, as well as the steps described below). This differs greatly from the out-of-the-box behavior of the Dataverse software, which we strive to keep secure for sysadmins installing the software for their institutions in a production environment.

The Burrito Key
^^^^^^^^^^^^^^^

For reasons that have been lost to the mists of time, the Dataverse Software really wants you to to have a burrito. Specifically, if you're trying to run REST Assured tests and see the error "Dataverse config issue: No API key defined for built in user management", you must run the following curl command (or make an equivalent change to your database):
For reasons that have been lost to the mists of time, the Dataverse software really wants you to to have a burrito. Specifically, if you're trying to run REST Assured tests and see the error "Dataverse config issue: No API key defined for built in user management", you must run the following curl command (or make an equivalent change to your database):

``curl -X PUT -d 'burrito' http://localhost:8080/api/admin/settings/BuiltinUsers.KEY``

Without this "burrito" key in place, REST Assured will not be able to create users. We create users to create objects we want to test, such as Dataverse collections, datasets, and files.
Without this "burrito" key in place, REST Assured will not be able to create users. We create users to create objects we want to test, such as collections, datasets, and files.

Root Dataverse Collection Permissions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Root Collection Permissions
^^^^^^^^^^^^^^^^^^^^^^^^^^^

In your browser, log in as dataverseAdmin (password: admin) and click the "Edit" button for your root Dataverse collection. Navigate to Permissions, then the Edit Access button. Under "Who can add to this Dataverse collection?" choose "Anyone with a Dataverse installation account can add sub Dataverse collections and datasets" if it isn't set to this already.
In your browser, log in as dataverseAdmin (password: admin) and click the "Edit" button for your root collection. Navigate to Permissions, then the Edit Access button. Under "Who can add to this collection?" choose "Anyone with a Dataverse installation account can add sub collections and datasets" if it isn't set to this already.

Alternatively, this same step can be done with this script: ``scripts/search/tests/grant-authusers-add-on-root``

Publish Root Dataverse Collection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Publish Root Collection
^^^^^^^^^^^^^^^^^^^^^^^

The root Dataverse collection must be published for some of the REST Assured tests to run.
The root collection must be published for some of the REST Assured tests to run.

dataverse.siteUrl
^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -274,15 +270,20 @@ Remember, it’s only a test (and it's not graded)! Some guidelines to bear in m
- Assert the conditions of success / return values for each operation
* A useful resource would be `HTTP status codes <https://www.restapitutorial.com/httpstatuscodes.html>`_
- Let the code do the labor; automate everything that happens when you run your test file.
- If you need to test an optional service (S3, etc.), add it to our docker compose file. See :doc:`/container/dev-usage`.
- Just as with any development, if you’re stuck: ask for help!

To execute existing integration tests on your local Dataverse installation, a helpful command line tool to use is `Maven <https://maven.apache.org/ref/3.1.0/maven-embedder/cli.html>`_. You should have Maven installed as per the `Development Environment <https://guides.dataverse.org/en/latest/developers/dev-environment.html>`_ guide, but if not it’s easily done via Homebrew: ``brew install maven``.

Once installed, you may run commands with ``mvn [options] [<goal(s)>] [<phase(s)>]``.

+ If you want to run just one particular API test, it’s as easy as you think:
+ If you want to run just one particular API test class:

``mvn test -Dtest=UsersIT``

+ If you want to run just one particular API test method,

``mvn test -Dtest=FileRecordJobIT``
``mvn test -Dtest=UsersIT#testMergeAccounts``

+ To run more than one test at a time, separate by commas:

Expand Down

0 comments on commit 5763b93

Please sign in to comment.