Skip to content

Commit

Permalink
update developer and create resource docs (#1711)
Browse files Browse the repository at this point in the history
* docs (updateKnoraDocs) edit docs of create resource

* docs (buildDocs) Build and Run documentation updated!

* docs (knoraDoc) remove redundent parts in bazel.md

* docs (knoraDocs) add explanation of make stak-up-fast

* docs(build): Fix typo.

Co-authored-by: Benjamin Geer <benjaminlewis.geer@unibas.ch>
  • Loading branch information
SepidehAlassi and Benjamin Geer committed Sep 22, 2020
1 parent f359c8e commit 73a9e9c
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 144 deletions.
3 changes: 1 addition & 2 deletions docs/03-apis/api-v2/editing-resources.md
Expand Up @@ -28,8 +28,7 @@ HTTP POST to http://host/v2/resources
```

The body of the request is a JSON-LD document in the
[complex API schema](introduction.md#api-schema), specifying the resource's IRI, type,
and `rdfs:label`, along with its Knora resource properties and their values. The representation of the
[complex API schema](introduction.md#api-schema), specifying the type,`rdfs:label`, and its Knora resource properties and their values. The representation of the
resource is the same as when it is returned in a `GET` request, except that its `knora-api:attachedToUser` is not given,
and the resource IRI and those of its values can be optionally specified. The format of the values submitted
is described in [Editing Values](editing-values.md). If there are multiple values for a property,
Expand Down
28 changes: 0 additions & 28 deletions docs/05-internals/development/bazel.md
Expand Up @@ -57,7 +57,6 @@ section in the Bazel documentation.
1. Click on `File -> Import Bazel Project` and select twice `next`.
1. Uncomment the `Scala` language and click `Finish`.


1. Run single spec:
```bash
$ bazel test //webapi/src/test/scala/org/knora/webapi/e2e/v1:SearchV1R2RSpec
Expand All @@ -68,34 +67,7 @@ section in the Bazel documentation.
$ bazel test //webapi/src/test/scala/org/knora/webapi/e2e/v1:SearchV1R2RSpec --test_arg=-z --test_arg="gaga"
```

1. Optimized development workflow

The first time:

1. `make docker-build` # run at least once so that you have all Docker images
2. `make init-db-test` # stops webapi, deletes and runs only the DB container, creates the repository and loads the data
3. `make stack-up-fast` # starts the whole stack and only rebuilds the `knora-api` Docker container if necessary

After you made some changes to webapi:

1. `make init-db-test` # stops, webapi, deletes and runs only the DB container, creates the repository and loads the data
2. `make stack-up-fast` # starts the whole stack and only rebuilds the `knora-api` Docker container if necessary

1. Start Scala REPL
```bash
$ bazel run //webapi:main_library_repl
```

1. xxx

```bash
$
```

```bash
$
```

```bash
$
```
103 changes: 0 additions & 103 deletions docs/05-internals/development/build-process.md

This file was deleted.

141 changes: 132 additions & 9 deletions docs/05-internals/development/building-and-running.md
Expand Up @@ -22,40 +22,163 @@ License along with Knora. If not, see <http://www.gnu.org/licenses/>.

## Running the stack

With [Docker](https://www.docker.com/) installed, run the following:
With [Docker](https://www.docker.com/) installed,

1. Run the following:

```
$ make init-db-test
```

to create the knora-test repository and initialize it with loading some test data into the triplestore (Fuseki).

1. Start the entire knora-stack (fuseki (db), sipi, redis, api, salsah1) with the following command:

```
$ make stack-up
```

Then try opening [http://localhost:3333/v1/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a](http://localhost:3333/v1/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a) in a web browser. You should see a response in JSON describing a book.

**_Note_**: To delete the existing containers and for a clean start, before creating the knora-test repository explained
in the first step above, run the following:

```
$ make stack-up
$ make stack-down-delete-volumes
```

Then to create a test repository and load some test data into the triplestore:
This stops the knora-stack and deletes any created volumes (deletes the database!).

To only shut down the Knora-Stack without deleting the containers:

```
$ make init-db-test
$ make stack-down
```

Then we need to restart knora-api after loading the data:
To restart the knora-api use the following command:

```
$ make stack-restart-api
```

Then try opening [http://localhost:3333/v1/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a](http://localhost:3333/v1/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a) in a web browser. You should see a response in JSON describing a book.
If a change is made to knora-api code, only its image needs to be rebuilt. In that case, use

```
$ make stack-up-fast
```

which starts the knora-stack by skipping rebuilding most of the images (only api image is rebuilt).

## Managing Containers in Docker Dashboard

To shut down the Knora-Stack:
The Docker Desktop is installed on your computer during the installation of docker, it enables easy management of docker
containers and access to Docker Hub. To manage your docker containers, docker desktop provides a dashbord.

![screenshot 'Docker Desktop'](figures/dockerDesktop.png)

In docker dashboard, you can see all the running containers, stop, start, restart, or completely delete them. For example, when
you start the knora-stack as explained above, in the docker dashboard you will see following:

![screenshot 'Docker Dashboard'](figures/dockerDashboard.png)

### Access the logs
To read information logged out of any container (db, api, etc.), click on the container in the dashboard and choose
`logs`. The example, below shows the logs of the database (db) container that includes the last SPARQL query sent to the
triplestore.

![screenshot 'Docker Logs'](figures/DockerLog.png)

Note that, you can also print out the log information directly from the command line. For example, the same logs of the
database container can be printed out using the following command:

```
$ make stack-down
$ make stack-logs-db
```
Similarly, the logs of the other containers can be printed out by running make with `stack-logs-api`, `stack-logs-sipi`,
or `stack-logs-redis`. These commands print out and follow the logs, to only print the logs out without following, use
`-no-follow` version of the commands for example:

```
$ make stack-logs-db-no-follow
```

Lastly, to print out the entire logs of the running knora-stack, use

```
$ make stack-logs
```

## Running the automated tests

Run the automated tests from terminal:
To run all test targets, use the following in the command line:

```
$ make test
```

To run only the dsp-api integration tests, use

```
$ make test-it
```
To run only the dsp-api unit tests, use

```
$ make test-unit
```

Lastly, to run all dsp-api test, use

```
$ make test-webapi
```

As explained in the [bazel document](bazel.md), to run a single test from the command line, for example `SearchV1R2RSpec`,
run the following:

```bash
$ bazel test //webapi/src/test/scala/org/knora/webapi/e2e/v1:SearchV1R2RSpec
```

_**Note:** to run tests, the api container must be stopped first!_

## Build and Publish Documentation
First, you need to install the requirements through:

```
$ make docs-install-requirements
```

Then, to build docs into the local `site` folder, run the following command:

```
$ make docs-build
```
At this point, you can serve the docs to view them locally using

```
$ make docs-serve
```

Lastly, to build and publish docs to Github Pages, use

```
$ make docs-publish
```

## Build and Publish Docker Images

To build and publish all Docker images locally

```
$ make docker-build
```
To publish all Docker images to Dockerhub

```
$ make docker-publish
```

## Load Testing on Mac OS X

To test Knora with many concurrent connections on Mac OS
Expand Down
1 change: 0 additions & 1 deletion docs/05-internals/development/index.md
Expand Up @@ -22,7 +22,6 @@ License along with Knora. If not, see <http://www.gnu.org/licenses/>.
- [Overview](overview.md)
- [Starting GraphDB](graphdb.md)
- [Build and Running](building-and-running.md)
- [Build Process](build-process.md)
- [Setup IntelliJ for development of Knora](intellij-config.md)
- [Testing](testing.md)
- [Docker Cheat Sheet](docker-cheat-sheet.md)
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Expand Up @@ -99,7 +99,6 @@ nav:
- Index: 05-internals/development/index.md
- Overview: 05-internals/development/overview.md
- Build and Running: 05-internals/development/building-and-running.md
- Build Process: 05-internals/development/build-process.md
- Setup IntelliJ for development of Knora: 05-internals/development/intellij-config.md
- Bazel Notes: 05-internals/development/bazel.md
- Testing: 05-internals/development/testing.md
Expand Down

0 comments on commit 73a9e9c

Please sign in to comment.