From 71c772f64f3108250abe37d756ecc93453396c3f Mon Sep 17 00:00:00 2001 From: irinaschubert Date: Fri, 2 Sep 2022 11:50:19 +0200 Subject: [PATCH] chore: Improve GitHub actions (DEV-1112) (#2182) --- .github/actions/cleanup/action.yml | 14 - .github/actions/preparation/action.yml | 8 +- .github/pull_request_template.md | 20 +- .github/workflows/build-and-test.yml | 67 ++++ .github/workflows/create-release.yml | 30 ++ .github/workflows/dependency-graph.yml | 2 +- .github/workflows/main.yml | 296 ------------------ .github/workflows/publish-release.yml | 63 ++++ .github/workflows/scala-steward.yml | 2 +- Makefile | 16 +- README.md | 101 ++---- docker-compose.yml | 1 - .../04-publishing-deployment/configuration.md | 77 +++-- .../getting-started.md | 12 - docs/04-publishing-deployment/publishing.md | 8 +- .../dsp/user/domain/UserDomainSpec.scala | 2 +- vars.mk | 19 -- .../scala/org/knora/webapi/CoreSpec.scala | 4 +- .../test/scala/org/knora/webapi/E2ESpec.scala | 6 +- .../org/knora/webapi/ITKnoraLiveSpec.scala | 18 ++ .../test/scala/org/knora/webapi/R2RSpec.scala | 4 +- .../v2/StandoffRouteV2ITSpec.scala} | 8 +- 22 files changed, 266 insertions(+), 512 deletions(-) delete mode 100644 .github/actions/cleanup/action.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/create-release.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/publish-release.yml rename webapi/src/test/scala/org/knora/webapi/{e2e/v2/StandoffRouteV2E2ESpec.scala => it/v2/StandoffRouteV2ITSpec.scala} (98%) diff --git a/.github/actions/cleanup/action.yml b/.github/actions/cleanup/action.yml deleted file mode 100644 index ce5e09d573..0000000000 --- a/.github/actions/cleanup/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: "Clean up" -description: "Cleans up the cache" - -runs: - using: "composite" - steps: - - name: Cleanup cache - shell: bash - run: | - rm -rf "$HOME/.ivy2/local" || true - find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true - find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.github/actions/preparation/action.yml b/.github/actions/preparation/action.yml index 27462334de..5ed4d84404 100644 --- a/.github/actions/preparation/action.yml +++ b/.github/actions/preparation/action.yml @@ -6,15 +6,9 @@ runs: steps: - name: Checkout source uses: actions/checkout@v3 - with: - fetch-depth: 50 - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: "temurin" java-version: "17" - - name: Install requirements (apt) - run: sudo apt-get install ca-certificates-java expect unzip - shell: bash - - name: Coursier cache - uses: coursier/cache-action@v6 + cache: sbt diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c97152db10..a28ba83a58 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,18 +1,20 @@ -## PR Checklist +Issue Number: DEV- + +## Pull Request Checklist + +### Basic Requirements Please check if your PR fulfills the following requirements: - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) -## PR Type +### PR Type What kind of change does this PR introduce? - - - [ ] Bugfix: represents bug fixes - [ ] Refactor: represents production code refactoring - [ ] Feature: represents a new feature @@ -22,18 +24,16 @@ What kind of change does this PR introduce? - [ ] Test: all about tests: adding, refactoring tests (no production code change) - [ ] Other... Please describe: -Issue Number: N/A +### Does this PR introduce a breaking change? -## Does this PR introduce a breaking change? + - [ ] Yes - [ ] No -## Does this PR change client-test-data? +### Does this PR change client-test-data? - [ ] Yes (don't forget to update the JS-LIB team about the change) - [ ] No - - -## Other information +### Other information diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000000..694ab25d9a --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,67 @@ +name: CI + +on: + push: + +jobs: + build-and-test: + name: Build and test + runs-on: ubuntu-latest + steps: + - name: Run preparatory steps + uses: dasch-swiss/dsp-api/.github/actions/preparation@main + - name: Run all tests + run: make test + - name: Upload coverage data to codacy + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: ./target/scala-2.13/coverage-report/cobertura.xml + - name: Upload coverage data to codecov + uses: codecov/codecov-action@v3 + with: + files: ./target/scala-2.13/coverage-report/cobertura.xml + + test-client-test-data: + name: Test client-test-data + runs-on: ubuntu-latest + steps: + - name: Run preparatory steps + uses: dasch-swiss/dsp-api/.github/actions/preparation@main + - name: Create client-test-data + run: make client-test-data + + test-repository-upgrade: + name: Test repository upgrade + runs-on: ubuntu-latest + steps: + - name: Run preparatory steps + uses: dasch-swiss/dsp-api/.github/actions/preparation@main + - name: Test repository upgrade + run: make test-repository-upgrade + - name: Dump docker logs + uses: jwalton/gh-docker-logs@v1 + + test-docs-build: + name: Test docs + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v3 + - name: Install requirements (pip, npm, apt) + run: | + python -m pip install --upgrade pip + pip install -r docs/requirements.txt + npm install --global typedoc + sudo apt-get install graphviz + - name: Build docs + run: make docs-build + + check-formatting: + name: Check formatting + runs-on: ubuntu-latest + steps: + - name: Run preparatory steps + uses: dasch-swiss/dsp-api/.github/actions/preparation@main + - name: Check formatting + run: make check diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000000..f1deb72fc8 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,30 @@ +name: Release + +on: + pull_request: + types: + - closed + +jobs: + create-release: + name: Create release PR + runs-on: ubuntu-latest + # Automate releases with Conventional Commit Messages as Pull Requests are merged into "main" branch + if: github.event.pull_request.merged == true + steps: + - name: Run release please action + uses: GoogleCloudPlatform/release-please-action@v2 + with: + token: ${{ secrets.GH_TOKEN }} + release-type: simple + package-name: dsp-api + changelog-types: '[ + {"type": "feat", "section": "Enhancements", "hidden": false }, + {"type": "fix", "section": "Bug Fixes", "hidden": false }, + {"type": "build", "section": "Maintenance", "hidden": false }, + {"type": "chore", "section": "Maintenance", "hidden": false }, + {"type": "test", "section": "Maintenance", "hidden": false }, + {"type": "style", "section": "Maintenance", "hidden": false }, + {"type": "refactor", "section": "Maintenance", "hidden": false }, + {"type": "docs", "section": "Documentation", "hidden": false } + ]' diff --git a/.github/workflows/dependency-graph.yml b/.github/workflows/dependency-graph.yml index 0d853bedff..fefb420aaf 100644 --- a/.github/workflows/dependency-graph.yml +++ b/.github/workflows/dependency-graph.yml @@ -1,4 +1,4 @@ -name: Update Dependency Graph +name: Dependencies on: push: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index ffa6239b44..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,296 +0,0 @@ -name: CI - -on: - schedule: - # run every midnight (on main) so that the first compile of the day from main is cached - - cron: "0 0 * * *" - push: - release: - types: [published] - -jobs: - compile: - name: Build and Test - runs-on: ubuntu-latest - steps: - - name: checkout source - uses: actions/checkout@v1 - with: - fetch-depth: 15 - - name: get current time - uses: josStorer/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DD - utcOffset: "+02:00" - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: add docker compose v2 - run: | - mkdir -p ~/.docker/cli-plugins/ - curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x ~/.docker/cli-plugins/docker-compose - - name: install requirements - run: sudo apt-get install ca-certificates-java expect - - name: Coursier cache - uses: coursier/cache-action@v6 - - name: Build and Test - run: make test - - name: Upload coverage data to codacy - uses: codacy/codacy-coverage-reporter-action@v1 - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: ./target/scala-2.13/coverage-report/cobertura.xml - - name: Upload coverage data to codecov - uses: codecov/codecov-action@v3 - with: - files: ./target/scala-2.13/coverage-report/cobertura.xml - - name: Cleanup before cache - shell: bash - run: | - rm -rf "$HOME/.ivy2/local" || true - find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true - find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.sbt -name "*.lock" -delete || true - - # ------------------------------------------ - # ------------------------------------------ - client-test-data-tests: - name: Run client-test-data - runs-on: ubuntu-latest - steps: - - name: checkout source - uses: actions/checkout@v1 - with: - fetch-depth: 15 - - name: get current time - uses: josStorer/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DD - utcOffset: "+02:00" - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: add docker compose v2 - run: | - mkdir -p ~/.docker/cli-plugins/ - curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x ~/.docker/cli-plugins/docker-compose - - name: install requirements - run: sudo apt-get install ca-certificates-java expect unzip - - name: Coursier cache - uses: coursier/cache-action@v6 - - name: generate api-client-test-data - run: make client-test-data - - name: upload client-test-data - uses: actions/upload-artifact@v3 - with: - name: client-test-data-zip - path: client-test-data.zip - retention-days: 1 - - name: cleanup before cache - shell: bash - run: | - rm -rf "$HOME/.ivy2/local" || true - find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true - find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.sbt -name "*.lock" -delete || true - - # ------------------------------------------ - # ------------------------------------------ - upgrade-integration-tests: - name: Upgrade Integration Tests - runs-on: ubuntu-latest - steps: - - name: checkout source - uses: actions/checkout@v1 - with: - fetch-depth: 15 - - name: get current time - uses: josStorer/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DD - utcOffset: "+02:00" - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: add docker compose v2 - run: | - mkdir -p ~/.docker/cli-plugins/ - curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x ~/.docker/cli-plugins/docker-compose - - name: install dependencies - run: | - sudo apt-get install ca-certificates-java expect - - name: Coursier cache - uses: coursier/cache-action@v6 - - name: test repository upgrade - run: make test-repository-upgrade - - name: dump docker logs on failure using different shell - # if: failure() - uses: jwalton/gh-docker-logs@v1 - with: - shell: "/bin/sh" - - name: cleanup before cache - shell: bash - run: | - rm -rf "$HOME/.ivy2/local" || true - find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true - find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.sbt -name "*.lock" -delete || true - - docs-build-test: - name: Build Docs Testrun - runs-on: ubuntu-latest - steps: - - name: checkout source - uses: actions/checkout@v1 - with: - fetch-depth: 1 - - name: add docker compose v2 - run: | - mkdir -p ~/.docker/cli-plugins/ - curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x ~/.docker/cli-plugins/docker-compose - - name: install dependencies - run: | - python -m pip install --upgrade pip - pip install -r docs/requirements.txt - npm install --global typedoc - sudo apt-get install graphviz - - name: run docs build - run: make docs-build - - release-please: - name: Prepare next release - runs-on: ubuntu-latest - # Automate releases with Conventional Commit Messages as Pull Requests are merged into "main" branch - if: github.ref == 'refs/heads/main' - steps: - - uses: GoogleCloudPlatform/release-please-action@v2 - with: - token: ${{ secrets.GH_TOKEN }} - release-type: simple - package-name: dsp-api - changelog-types: '[ - {"type": "feat", "section": "Enhancements", "hidden": false }, - {"type": "fix", "section": "Bug Fixes", "hidden": false }, - {"type": "build", "section": "Maintenance", "hidden": false }, - {"type": "chore", "section": "Maintenance", "hidden": false }, - {"type": "refactor", "section": "Maintenance", "hidden": false }, - {"type": "docs", "section": "Documentation", "hidden": false } - ]' - - # publish only on release - publish: - name: Publish (on release only) - needs: [compile] - runs-on: ubuntu-latest - if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') - steps: - - name: checkout source - uses: actions/checkout@v1 - with: - fetch-depth: 50 - - name: get current time - uses: josStorer/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DD - utcOffset: "+02:00" - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: add docker compose v2 - run: | - mkdir -p ~/.docker/cli-plugins/ - curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x ~/.docker/cli-plugins/docker-compose - - name: install requirements - run: sudo apt-get install ca-certificates-java expect unzip - - name: install dependencies - run: | - python -m pip install --upgrade pip - pip install -r docs/requirements.txt - npm install --global typedoc - sudo apt-get install graphviz - - name: download client-test-data - uses: actions/download-artifact@v3 - with: - name: client-test-data-zip - - name: add api-client-test-data to release assets - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GH_TOKEN }} - file: client-test-data.zip - tag: ${{ github.ref }} - overwrite: true - - name: build and publish all images to Dockerhub - run: | - echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin - make docker-publish - - # google chat notification about release - notification: - name: Google chat notification about release and published version - needs: [publish] - runs-on: ubuntu-latest - if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') - steps: - - name: send notification to google chat room "DSP releases" - uses: lakto/google-chat-action@main - with: - url: ${{ secrets.GOOGLE_CHAT_DSP_RELEASES_WEBHOOK_URL }} - - fmtcheck: - name: Check Formating - runs-on: ubuntu-latest - steps: - - name: checkout source - uses: actions/checkout@v1 - with: - fetch-depth: 15 - - name: get current time - uses: josStorer/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DD - utcOffset: "+02:00" - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: add docker compose v2 - run: | - mkdir -p ~/.docker/cli-plugins/ - curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x ~/.docker/cli-plugins/docker-compose - - name: install requirements - run: sudo apt-get install ca-certificates-java expect - - name: Coursier cache - uses: coursier/cache-action@v6 - - name: Run fmtcheck - run: make check - - name: Cleanup before cache - shell: bash - run: | - rm -rf "$HOME/.ivy2/local" || true - find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true - find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000000..ca17b36cb6 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,63 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + create-client-test-data: + name: Create and upload client-test-data + runs-on: ubuntu-latest + steps: + - name: Run preparatory steps + uses: dasch-swiss/dsp-api/.github/actions/preparation@main + - name: Create client-test-data + run: make client-test-data + - name: Upload client-test-data + uses: actions/upload-artifact@v3 + with: + name: client-test-data-zip + path: client-test-data.zip + retention-days: 1 + + publish-release: + name: Publish release + needs: [create-client-test-data] + runs-on: ubuntu-latest + if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') + steps: + - name: Run preparatory steps + uses: dasch-swiss/dsp-api/.github/actions/preparation@main + - name: Install requirements (apt, pip, npm) + run: | + sudo apt-get install graphviz + python -m pip install --upgrade pip + pip install -r docs/requirements.txt + npm install --global typedoc + - name: Download client-test-data + uses: actions/download-artifact@v3 + with: + name: client-test-data-zip + - name: Add client-test-data to release assets + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GH_TOKEN }} + file: client-test-data.zip + tag: ${{ github.ref }} + overwrite: true + - name: Build and publish all images to Dockerhub + run: | + echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin + make docker-publish + + send-chat-notification: + name: Send google chat notification + needs: [publish-release] + runs-on: ubuntu-latest + if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') + steps: + - name: Send notification to google chat room "DSP releases" + uses: lakto/google-chat-action@main + with: + url: ${{ secrets.GOOGLE_CHAT_DSP_RELEASES_WEBHOOK_URL }} + diff --git a/.github/workflows/scala-steward.yml b/.github/workflows/scala-steward.yml index 663a2daa1e..58e9eaa7f6 100644 --- a/.github/workflows/scala-steward.yml +++ b/.github/workflows/scala-steward.yml @@ -1,4 +1,4 @@ -name: Launch Scala Steward +name: Dependencies # This workflow will launch at 00:00 every Sunday on: diff --git a/Makefile b/Makefile index 535ba023dc..c2dcbd7c8b 100644 --- a/Makefile +++ b/Makefile @@ -183,7 +183,7 @@ stack-db-only: env-file ## starts only fuseki. .PHONY: client-test-data client-test-data: export KNORA_WEBAPI_COLLECT_CLIENT_TEST_DATA := true -client-test-data: build ## runs the dsp-api e2e tests and generates client test data. +client-test-data: build ## runs the dsp-api e2e and r2r tests and generates client-test-data. $(CURRENT_DIR)/webapi/scripts/zap-client-test-data.sh sbt -v "webapi/testOnly *E2ESpec *R2RSpec" $(CURRENT_DIR)/webapi/scripts/zip-client-test-data.sh @@ -203,13 +203,12 @@ test-repository-upgrade: build init-db-test-minimal ## runs DB upgrade integrati .PHONY: test test: build ## runs all tests + sbt -v coverage "webapi/test" sbt -v coverage "shared/test" - sbt -v coverage "sipi/test" sbt -v coverage "userCore/test" sbt -v coverage "userHandler/test" sbt -v coverage "userInterface/test" sbt -v coverage "userRepo/test" - sbt -v coverage "webapi/test" sbt coverageAggregate @@ -266,13 +265,13 @@ db_ls_test_server_dump.trig: init-db-test-from-test: db_test_dump.trig init-db-test-empty ## init local database with data from test @echo $@ @curl -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "admin:test" "http://localhost:3030/knora-test" - @curl -X POST -H "Content-Type: application/trig" --data-binary "@${CURRENT_DIR}/db_test_dump.trig" -u "admin:test" "http://localhost:3030/knora-test" + @curl -X POST -H "Content-Type: application/trig" -T "${CURRENT_DIR}/db_test_dump.trig" -u "admin:test" "http://localhost:3030/knora-test" .PHONY: init-db-test-from-staging init-db-test-from-staging: db_staging_dump.trig init-db-test-empty ## init local database with data from staging @echo $@ @curl -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "admin:test" "http://localhost:3030/knora-test" - @curl -X POST -H "Content-Type: application/trig" --data-binary "@${CURRENT_DIR}/db_staging_dump.trig" -u "admin:test" "http://localhost:3030/knora-test" + @curl -X POST -H "Content-Type: application/trig" -T "${CURRENT_DIR}/db_staging_dump.trig" -u "admin:test" "http://localhost:3030/knora-test" .PHONY: init-db-test-from-prod init-db-test-from-prod: db_prod_dump.trig init-db-test-empty ## init local database with data from production @@ -287,7 +286,7 @@ init-db-test-from-ls-test-server: db_ls_test_server_dump.trig init-db-test-from- init-db-test-from-ls-test-server-trig-file: init-db-test-empty ## init local database with data from a local ls-test-server dump @echo $@ @curl -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "admin:test" "http://localhost:3030/knora-test" - @curl -X POST -H "Content-Type: application/trig" --data-binary "@${CURRENT_DIR}/db_ls_test_server_dump.trig" -u "admin:test" "http://localhost:3030/knora-test" + @curl -X POST -H "Content-Type: application/trig" -T "${CURRENT_DIR}/db_ls_test_server_dump.trig" -u "admin:test" "http://localhost:3030/knora-test" ################################# ## Other @@ -324,11 +323,6 @@ clean-sipi-projects: ## deletes all files uploaded within a project @rm -rf sipi/images/[0-9A-F][0-9A-F][0-9A-F][0-9A-F] @rm -rf sipi/images/originals/[0-9A-F][0-9A-F][0-9A-F][0-9A-F] -.PHONY: info -info: ## print out all variables - @echo "BUILD_TAG: \t\t $(BUILD_TAG)" - @echo "GIT_EMAIL: \t\t $(GIT_EMAIL)" - .PHONY: check check: # Run code formating check @sbt "check" diff --git a/README.md b/README.md index 06c7f5ae66..2ff8ea613f 100644 --- a/README.md +++ b/README.md @@ -22,48 +22,35 @@ released under the [Apache License, Version 2.0](http://www.apache.org/licenses/ * Offers a generic HTTP-based API, implemented in [Scala](https://www.scala-lang.org/), for querying, annotating, and linking together heterogeneous data in a unified way. * Handles authentication and authorization. * Provides automatic versioning of data. -* Uses [Sipi](https://www.sipi.io), a high-performance media server implemented in C++. -* Designed to be be used with [DSP-APP](https://docs.dasch.swiss/user-guide/), a general-purpose, browser-based virtual research environment, +* Uses [Sipi](https://sipi.io), a high-performance media server implemented in C++. +* Designed to be be used with [DSP-APP](https://docs.dasch.swiss/latest/DSP-APP/), a general-purpose, browser-based virtual research environment, as well as with custom user interfaces. -## Status - -### Stable - -* [Knora Ontologies](https://docs.knora.org/02-knora-ontologies/) -* [Knora API v1](https://docs.knora.org/03-apis/api-v1/) - -### Beta stage - -* [Knora API v2](https://docs.knora.org/03-apis/api-v2/) -* [Knora Admin API](https://docs.knora.org/03-apis/api-admin/) -* Distribution packaging using [Docker](https://www.docker.com/) - ## Requirements -### For developing and testing the API server +### For developing and testing DSP-API Each developer machine should have the following prerequisites installed: -* Linux or macOS (with some caveats) -* Docker Desktop: https://www.docker.com/products/docker-desktop -* Homebrew (on macOS): https://brew.sh -* [OpenJDK](https://adoptopenjdk.net) 11 +* Linux or macOS +* [Docker Desktop](https://www.docker.com/products/docker-desktop) +* [Homebrew](https://brew.sh) (macOS) +* JDK [Temurin 17](https://adoptium.net/en-GB/temurin/) * [sbt](https://www.scala-sbt.org/) -#### Java Adoptopenjdk 11 +#### JDK Temurin 17 To install, follow these steps: ```shell -brew tap AdoptOpenJDK/openjdk -brew install AdoptOpenJDK/openjdk/adoptopenjdk11 --cask +brew tap homebrew/cask-versions +brew install --cask temurin17 ``` To pin the version of Java, please add this environment variable to you startup script (bashrc, etc.): ```shell -export JAVA_HOME=`/usr/libexec/java_home -v 11` +export JAVA_HOME=`/usr/libexec/java_home -v 17` ``` ### For building the documentation @@ -72,32 +59,32 @@ See [docs/Readme.md](docs/Readme.md). ## Try it out -### Run the Knora API server +### Run DSP-API -Run the following to create a test repository and load some test data into the triplestore: +Create a test repository and load some test data into the triplestore: ```shell make init-db-test ``` -Then we need to start knora-api after loading the data: +Start DSP-API after loading the data: ```shell make stack-up ``` -Then try opening [http://localhost:3333/v2/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a](http://localhost:3333/v2/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a) in a web browser. You should see a response in JSON-LD describing a book. +Open [http://localhost:3333/v2/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a](http://localhost:3333/v2/resources/http%3A%2F%2Frdfh.ch%2F0803%2Fc5058f3a) in a web browser. You should see a response in JSON-LD describing a book. On first installation, errors similar to the following can come up: ``` error decoding 'Volumes[0]': invalid spec: :/fuseki:delegated: empty section between colons ``` -To solve this you need to deactivate Docker Compose V2. This can be done in Docker Desktop either by unchecking the "Use Docker Compose V2"-flag under "Preferences/General" or by running +To solve this, you need to deactivate Docker Compose V2. This can be done in Docker Desktop either by unchecking the "Use Docker Compose V2" flag under "Preferences > General" or by running ``` docker-compose disable-v2 ``` -To shut down the Knora-Stack: +Shut down DSP-API: ```shell make stack-down @@ -105,59 +92,15 @@ make stack-down ### Run the automated tests -Run : +Run all tests: ```shell make test ``` -## How to Contribute - -You can help by testing Knora with your data, making bug reports, improving the -documentation, and adding features that you need. - -First, open an [issue](https://github.com/dasch-swiss/knora-api/issues) to -describe your problem or idea. We may ask you to submit a -[pull request](https://help.github.com/articles/about-pull-requests/) -implementing the desired functionality. - -### Coding conventions - -Use `camelCase` for names of classes, variables, and functions. Make names descriptive, and don't worry if they're long. - -Use [Scalafmt](https://scalameta.org/scalafmt/) in Visual Studio Code to format Scala code. - -Use whitespace to make your code easier to read. -Add lots of implementation comments describing what your code is doing, -how it works, and why it works that way. - -### Tests - -We write automated tests using [ScalaTest](https://www.scalatest.org). You can run them from the [SBT](https://www.scala-sbt.org) console. - -There are three sets of automated tests: - -* Unit tests, route-to-route tests, and end-to-end tests are under `webapi/src/test`. To run these, type `test` at the SBT console in the `webapi` project. To run a single test, use `testOnly *NameOfTestSpec`. -* Integration tests, which can involve [Sipi](https://github.com/daschswiss/sipi), are under `src/it`. To run these, first start Sipi, then type `it:test` at the SBT console in the `webapi` project. - -Whenever you add a new feature or fix a bug, you should add one or more tests -for the change you made. - -### Documentation - -A pull request should include tests and documentation for the changes that were -made. See the [documentation README](https://github.com/dasch-swiss/knora-api/blob/main/docs/Readme.md) -for information on writing Knora documentation. - -## Commit Message Schema - -When writing commit messages, we follow the [Conventional Commit messages](https://www.conventionalcommits.org/) rules. -Get more information in our official [DSP Contribution Documentation](https://docs.dasch.swiss/developers/dsp/contribution/#git-commit-guidelines) - ## Release Versioning Convention -The Knora project is following the Semantic Versioning convention for numbering the releases -as defined by [http://semver.org]: +The DSP-API release versioning follows the [Semantic Versioning](https://semver.org) convention: > Given a version number MAJOR.MINOR.PATCH, increment the: > @@ -166,8 +109,4 @@ as defined by [http://semver.org]: > * PATCH version when you make backwards-compatible bug fixes. Additionally, we will also increment the MAJOR version in the case when any kind of changes to existing -data would be necessary, e.g., any changes to the Knora-Base ontologies which are not backwards compatible. - -## Release Notes Generation - -A pull request usually resolves one issue or user story defined on [Jira](https://dasch.atlassian.net/browse/DEV). Since we started to use the [release-please-action](https://github.com/marketplace/actions/release-please-action) it's very important to set the PR title in the correct way, especially because all commits added within the pull request are squashed. Please read the official [DSP Contribution Documentation](https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-guidelines) carefully! +data would be necessary, e.g., any changes to the [knora-base ontology](https://docs.dasch.swiss/latest/DSP-API/02-knora-ontologies/knora-base/) which are not backwards compatible. diff --git a/docker-compose.yml b/docker-compose.yml index 8800c8fd1c..4449a40a5a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,7 +53,6 @@ services: - TZ=Europe/Zurich - KNORA_AKKA_LOGLEVEL=DEBUG - KNORA_AKKA_STDOUT_LOGLEVEL=DEBUG - - KNORA_WEBAPI_DB_CONNECTIONS=2 - KNORA_WEBAPI_TRIPLESTORE_HOST=db - KNORA_WEBAPI_TRIPLESTORE_DBTYPE=fuseki - KNORA_WEBAPI_SIPI_INTERNAL_HOST=sipi diff --git a/docs/04-publishing-deployment/configuration.md b/docs/04-publishing-deployment/configuration.md index db03da8f41..612287504e 100644 --- a/docs/04-publishing-deployment/configuration.md +++ b/docs/04-publishing-deployment/configuration.md @@ -21,45 +21,44 @@ The relevant sections for tuning are: A number of core settings is additionally configurable through system environment variables. These are: -| key in application.conf | environment variable | default value | -|-------------------------------------------------------------|-----------------------------------------------------------------|----------------------| -| akka.log-config-on-start | KNORA_AKKA_LOG_CONFIG_ON_START | off | -| akka.loglevel | KNORA_AKKA_LOGLEVEL | INFO | -| akka.actor.deployment.httpTriplestoreRouter.nr-of-instances | KNORA_WEBAPI_DB_CONNECTIONS | 2 | -| akka.stdout-loglevel | KNORA_AKKA_STDOUT_LOGLEVEL | INFO | -| app.print-extended-config | KNORA_WEBAPI_PRINT_EXTENDED_CONFIG | false | -| app.bcrypt-password-strength | KNORA_WEBAPI_BCRYPT_PASSWORD_STRENGTH | 12 | -| app.jwt-secret-key | KNORA_WEBAPI_JWT_SECRET_KEY | super-secret-key | -| app.jwt-longevity | KNORA_WEBAPI_JWT_LONGEVITY | 30 days | -| app.cookie-domain | KNORA_WEBAPI_COOKIE_DOMAIN | localhost | -| app.allow-reload-over-http | KNORA_WEBAPI_ALLOW_RELOAD_OVER_HTTP | false | -| app.ark.resolver | KNORA_WEBAPI_ARK_RESOLVER_URL | http://0.0.0.0:3336 | -| app.ark.assigned-number | KNORA_WEBAPI_ARK_NAAN | 72163 | -| app.knora-api.internal-host | KNORA_WEBAPI_KNORA_API_INTERNAL_HOST | 0.0.0.0 | -| app.knora-api.internal-port | KNORA_WEBAPI_KNORA_API_INTERNAL_PORT | 3333 | -| app.knora-api.external-protocol | KNORA_WEBAPI_KNORA_API_EXTERNAL_PROTOCOL | http | -| app.knora-api.external-host | KNORA_WEBAPI_KNORA_API_EXTERNAL_HOST | 0.0.0.0 | -| app.knora-api.external-port | KNORA_WEBAPI_KNORA_API_EXTERNAL_PORT | 3333 | -| app.sipi.internal-protocol | KNORA_WEBAPI_SIPI_INTERNAL_PROTOCOL | http | -| app.sipi.internal-host | KNORA_WEBAPI_SIPI_INTERNAL_HOST | localhost | -| app.sipi.internal-port | KNORA_WEBAPI_SIPI_INTERNAL_PORT | 1024 | -| app.sipi.external-protocol | KNORA_WEBAPI_SIPI_EXTERNAL_PROTOCOL | http | -| app.sipi.external-host | KNORA_WEBAPI_SIPI_EXTERNAL_HOST | localhost | -| app.sipi.external-port | KNORA_WEBAPI_SIPI_EXTERNAL_PORT | 443 | -| app.ark.resolver | KNORA_WEBAPI_ARK_RESOLVER_URL | http://0.0.0.0:3336 | -| app.ark.assigned-number | KNORA_WEBAPI_ARK_NAAN | 72163 | -| app.salsah1.base-url | KNORA_WEBAPI_SALSAH1_BASE_URL | http://localhost:3335| -| app.triplestore.dbtype | KNORA_WEBAPI_TRIPLESTORE_DBTYPE | fuseki | -| app.triplestore.use-https | KNORA_WEBAPI_TRIPLESTORE_USE_HTTPS | false | -| app.triplestore.host | KNORA_WEBAPI_TRIPLESTORE_HOST | localhost | -| app.triplestore.auto-init | KNORA_WEBAPI_TRIPLESTORE_AUTOINIT | false | -| app.triplestore.fuseki.port | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PORT | 3030 | -| app.triplestore.fuseki.repository-name | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_REPOSITORY_NAME | knora-test | -| app.triplestore.fuseki.username | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_USERNAME | admin | -| app.triplestore.fuseki.password | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PASSWORD | test | -| app.cache-service.enabled | KNORA_WEBAPI_CACHE_SERVICE_ENABLED | true | -| app.cache-service.redis.host | KNORA_WEBAPI_CACHE_SERVICE_REDIS_HOST | localhost | -| app.cache-service.redis.port | KNORA_WEBAPI_CACHE_SERVICE_REDIS_PORT | 6379 | +| key in application.conf | environment variable | default value | +| -------------------------------------- | ----------------------------------------------- | --------------------- | +| akka.log-config-on-start | KNORA_AKKA_LOG_CONFIG_ON_START | off | +| akka.loglevel | KNORA_AKKA_LOGLEVEL | INFO | +| akka.stdout-loglevel | KNORA_AKKA_STDOUT_LOGLEVEL | INFO | +| app.print-extended-config | KNORA_WEBAPI_PRINT_EXTENDED_CONFIG | false | +| app.bcrypt-password-strength | KNORA_WEBAPI_BCRYPT_PASSWORD_STRENGTH | 12 | +| app.jwt-secret-key | KNORA_WEBAPI_JWT_SECRET_KEY | super-secret-key | +| app.jwt-longevity | KNORA_WEBAPI_JWT_LONGEVITY | 30 days | +| app.cookie-domain | KNORA_WEBAPI_COOKIE_DOMAIN | localhost | +| app.allow-reload-over-http | KNORA_WEBAPI_ALLOW_RELOAD_OVER_HTTP | false | +| app.ark.resolver | KNORA_WEBAPI_ARK_RESOLVER_URL | http://0.0.0.0:3336 | +| app.ark.assigned-number | KNORA_WEBAPI_ARK_NAAN | 72163 | +| app.knora-api.internal-host | KNORA_WEBAPI_KNORA_API_INTERNAL_HOST | 0.0.0.0 | +| app.knora-api.internal-port | KNORA_WEBAPI_KNORA_API_INTERNAL_PORT | 3333 | +| app.knora-api.external-protocol | KNORA_WEBAPI_KNORA_API_EXTERNAL_PROTOCOL | http | +| app.knora-api.external-host | KNORA_WEBAPI_KNORA_API_EXTERNAL_HOST | 0.0.0.0 | +| app.knora-api.external-port | KNORA_WEBAPI_KNORA_API_EXTERNAL_PORT | 3333 | +| app.sipi.internal-protocol | KNORA_WEBAPI_SIPI_INTERNAL_PROTOCOL | http | +| app.sipi.internal-host | KNORA_WEBAPI_SIPI_INTERNAL_HOST | localhost | +| app.sipi.internal-port | KNORA_WEBAPI_SIPI_INTERNAL_PORT | 1024 | +| app.sipi.external-protocol | KNORA_WEBAPI_SIPI_EXTERNAL_PROTOCOL | http | +| app.sipi.external-host | KNORA_WEBAPI_SIPI_EXTERNAL_HOST | localhost | +| app.sipi.external-port | KNORA_WEBAPI_SIPI_EXTERNAL_PORT | 443 | +| app.ark.resolver | KNORA_WEBAPI_ARK_RESOLVER_URL | http://0.0.0.0:3336 | +| app.ark.assigned-number | KNORA_WEBAPI_ARK_NAAN | 72163 | +| app.salsah1.base-url | KNORA_WEBAPI_SALSAH1_BASE_URL | http://localhost:3335 | +| app.triplestore.dbtype | KNORA_WEBAPI_TRIPLESTORE_DBTYPE | fuseki | +| app.triplestore.use-https | KNORA_WEBAPI_TRIPLESTORE_USE_HTTPS | false | +| app.triplestore.host | KNORA_WEBAPI_TRIPLESTORE_HOST | localhost | +| app.triplestore.auto-init | KNORA_WEBAPI_TRIPLESTORE_AUTOINIT | false | +| app.triplestore.fuseki.port | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PORT | 3030 | +| app.triplestore.fuseki.repository-name | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_REPOSITORY_NAME | knora-test | +| app.triplestore.fuseki.username | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_USERNAME | admin | +| app.triplestore.fuseki.password | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PASSWORD | test | +| app.cache-service.enabled | KNORA_WEBAPI_CACHE_SERVICE_ENABLED | true | +| app.cache-service.redis.host | KNORA_WEBAPI_CACHE_SERVICE_REDIS_HOST | localhost | +| app.cache-service.redis.port | KNORA_WEBAPI_CACHE_SERVICE_REDIS_PORT | 6379 | ## Selectively Disabling Routes diff --git a/docs/04-publishing-deployment/getting-started.md b/docs/04-publishing-deployment/getting-started.md index 0ef498ce80..fc7a25f1ea 100644 --- a/docs/04-publishing-deployment/getting-started.md +++ b/docs/04-publishing-deployment/getting-started.md @@ -56,18 +56,6 @@ Other triplestores are planned. Use `git` to clone the DSP-API repository from [Github](https://github.com/dasch-swiss/dsp-api). -The following environment variables are **optional**: - -- `KNORA_DB_HOME`: sets the path to the folder where the triplestore will store -the database files -- `KNORA_DB_IMPORT`: sets the path to the import directory accessible from -inside the docker image - -```bash -$ export KNORA_DB_IMPORT=/path/to/some/folder -$ export KNORA_DB_HOME=/path/to/some/other_folder -``` - Then from inside the cloned `DSP-API` repository folder, run: ```bash diff --git a/docs/04-publishing-deployment/publishing.md b/docs/04-publishing-deployment/publishing.md index 39027af909..e99c45b61d 100644 --- a/docs/04-publishing-deployment/publishing.md +++ b/docs/04-publishing-deployment/publishing.md @@ -5,16 +5,14 @@ # Publishing -Knora is published as a set of [Docker](https://www.docker.com) images under the -[DaSCH Basel Dockerhub Organization](https://hub.docker.com/u/daschswiss). +DSP is published as a set of [Docker](https://www.docker.com) images under the +[DaSCH Dockerhub Organization](https://hub.docker.com/u/daschswiss). The following Docker images are published: - Knora-API: - https://hub.docker.com/r/daschswiss/knora-api -- Jena Fuseki: - - https://hub.docker.com/r/daschswiss/knora-jena-fuseki -- Sipi (includes Knora's Sipi scripts): +- Sipi (includes DSP's specific Sipi scripts): - https://hub.docker.com/r/daschswiss/knora-sipi - Salsah 1: - https://hub.docker.com/r/daschswiss/knora-salsah1 diff --git a/dsp-user/core/src/test/scala/dsp/user/domain/UserDomainSpec.scala b/dsp-user/core/src/test/scala/dsp/user/domain/UserDomainSpec.scala index 950fad4695..0948107c6c 100644 --- a/dsp-user/core/src/test/scala/dsp/user/domain/UserDomainSpec.scala +++ b/dsp-user/core/src/test/scala/dsp/user/domain/UserDomainSpec.scala @@ -17,7 +17,7 @@ import dsp.valueobjects.User._ */ object UserDomainSpec extends ZIOSpecDefault { - def spec = (compareUsersTest + createUserTest + updateUserTest) + def spec = suite("UserDomainSpec")(compareUsersTest, createUserTest, updateUserTest) private val compareUsersTest = suite("compareUsers")( test("compare two users") { diff --git a/vars.mk b/vars.mk index c3a0ac6061..9dbe962332 100644 --- a/vars.mk +++ b/vars.mk @@ -1,26 +1,7 @@ FUSEKI_HEAP_SIZE := 3G -KNORA_WEBAPI_DB_CONNECTIONS := 2 KNORA_DB_REPOSITORY_NAME := knora-test -ifeq ($(BUILD_TAG),) - BUILD_TAG := $(shell git describe --tag --dirty --abbrev=7) -endif -ifeq ($(BUILD_TAG),) - BUILD_TAG := $(shell git rev-parse --verify HEAD) -endif - -ifeq ($(GIT_EMAIL),) - GIT_EMAIL := $(shell git config user.email) -endif - -ifeq ($(KNORA_DB_IMPORT),) - KNORA_DB_IMPORT := unknown -endif - -ifeq ($(KNORA_DB_HOME),) - KNORA_DB_HOME := unknown -endif UNAME := $(shell uname) ifeq ($(UNAME),Darwin) diff --git a/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala b/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala index e31a440288..1b04ab5a0b 100644 --- a/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala @@ -50,7 +50,6 @@ import org.knora.webapi.store.triplestore.api.TriplestoreService import org.knora.webapi.store.triplestore.impl.TriplestoreServiceHttpConnectorImpl import org.knora.webapi.store.triplestore.upgrade.RepositoryUpdater import org.knora.webapi.testcontainers.FusekiTestContainer -import org.knora.webapi.testcontainers.SipiTestContainer import org.knora.webapi.util.StartupUtils object CoreSpec { @@ -140,9 +139,8 @@ abstract class CoreSpec(_system: ActorSystem) CacheServiceInMemImpl.layer, IIIFServiceManager.layer, IIIFServiceSipiImpl.layer, // alternative: MockSipiImpl.layer - AppConfigForTestContainers.testcontainers, + AppConfigForTestContainers.fusekiOnlyTestcontainer, JWTService.layer, - SipiTestContainer.layer, TriplestoreServiceManager.layer, TriplestoreServiceHttpConnectorImpl.layer, RepositoryUpdater.layer, diff --git a/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala b/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala index 01e9464c91..53af64f0d9 100644 --- a/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala @@ -59,7 +59,6 @@ import org.knora.webapi.store.triplestore.TriplestoreServiceManager import org.knora.webapi.store.triplestore.impl.TriplestoreServiceHttpConnectorImpl import org.knora.webapi.store.triplestore.upgrade.RepositoryUpdater import org.knora.webapi.testcontainers.FusekiTestContainer -import org.knora.webapi.testcontainers.SipiTestContainer import org.knora.webapi.testservices.FileToUpload import org.knora.webapi.testservices.TestActorSystemService import org.knora.webapi.testservices.TestClientService @@ -131,9 +130,8 @@ abstract class E2ESpec(_system: ActorSystem) CacheServiceInMemImpl.layer, IIIFServiceManager.layer, IIIFServiceSipiImpl.layer, // alternative: MockSipiImpl.layer - AppConfigForTestContainers.testcontainers, + AppConfigForTestContainers.fusekiOnlyTestcontainer, JWTService.layer, - SipiTestContainer.layer, TriplestoreServiceManager.layer, TriplestoreServiceHttpConnectorImpl.layer, RepositoryUpdater.layer, @@ -180,7 +178,7 @@ abstract class E2ESpec(_system: ActorSystem) appActor ! SetAllowReloadOverHTTPState(true) // start the knora service, loading data from the repository - appActor ! AppStart(ignoreRepository = true, requiresIIIFService = true) + appActor ! AppStart(ignoreRepository = true, requiresIIIFService = false) // waits until knora is up and running applicationStateRunning() diff --git a/webapi/src/test/scala/org/knora/webapi/ITKnoraLiveSpec.scala b/webapi/src/test/scala/org/knora/webapi/ITKnoraLiveSpec.scala index af352e7cda..5654700ca4 100644 --- a/webapi/src/test/scala/org/knora/webapi/ITKnoraLiveSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/ITKnoraLiveSpec.scala @@ -23,7 +23,11 @@ import org.scalatest.wordspec.AnyWordSpecLike import spray.json._ import zio._ +import java.util.concurrent.TimeUnit +import scala.concurrent.Await import scala.concurrent.ExecutionContext +import scala.concurrent.Future +import scala.concurrent.duration.FiniteDuration import org.knora.webapi.app.ApplicationActor import org.knora.webapi.auth.JWTService @@ -38,6 +42,7 @@ import org.knora.webapi.messages.store.sipimessages._ import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject import org.knora.webapi.messages.store.triplestoremessages.TriplestoreJsonProtocol import org.knora.webapi.messages.util.rdf.JsonLDDocument +import org.knora.webapi.messages.util.rdf.JsonLDUtil import org.knora.webapi.settings._ import org.knora.webapi.store.cache.CacheServiceManager import org.knora.webapi.store.cache.impl.CacheServiceInMemImpl @@ -269,4 +274,17 @@ abstract class ITKnoraLiveSpec(_system: ActorSystem) .getOrThrow() } + protected def responseToString(httpResponse: HttpResponse): String = { + val responseBodyFuture: Future[String] = + httpResponse.entity.toStrict(FiniteDuration(10L, TimeUnit.SECONDS)).map(_.data.decodeString("UTF-8")) + Await.result(responseBodyFuture, FiniteDuration(10L, TimeUnit.SECONDS)) + } + + protected def responseToJsonLDDocument(httpResponse: HttpResponse): JsonLDDocument = { + val responseBodyFuture: Future[String] = + httpResponse.entity.toStrict(FiniteDuration(10L, TimeUnit.SECONDS)).map(_.data.decodeString("UTF-8")) + val responseBodyStr = Await.result(responseBodyFuture, FiniteDuration(10L, TimeUnit.SECONDS)) + JsonLDUtil.parseJsonLD(responseBodyStr) + } + } diff --git a/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala b/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala index 05363acbdc..94dc827b87 100644 --- a/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala @@ -53,7 +53,6 @@ import org.knora.webapi.store.triplestore.TriplestoreServiceManager import org.knora.webapi.store.triplestore.impl.TriplestoreServiceHttpConnectorImpl import org.knora.webapi.store.triplestore.upgrade.RepositoryUpdater import org.knora.webapi.testcontainers.FusekiTestContainer -import org.knora.webapi.testcontainers.SipiTestContainer import org.knora.webapi.testservices.TestActorSystemService import org.knora.webapi.testservices.TestClientService import org.knora.webapi.util.FileUtil @@ -110,9 +109,8 @@ abstract class R2RSpec CacheServiceInMemImpl.layer, IIIFServiceManager.layer, IIIFServiceSipiImpl.layer, // alternative: MockSipiImpl.layer - AppConfigForTestContainers.testcontainers, + AppConfigForTestContainers.fusekiOnlyTestcontainer, JWTService.layer, - SipiTestContainer.layer, TriplestoreServiceManager.layer, TriplestoreServiceHttpConnectorImpl.layer, RepositoryUpdater.layer, diff --git a/webapi/src/test/scala/org/knora/webapi/e2e/v2/StandoffRouteV2E2ESpec.scala b/webapi/src/test/scala/org/knora/webapi/it/v2/StandoffRouteV2ITSpec.scala similarity index 98% rename from webapi/src/test/scala/org/knora/webapi/e2e/v2/StandoffRouteV2E2ESpec.scala rename to webapi/src/test/scala/org/knora/webapi/it/v2/StandoffRouteV2ITSpec.scala index c010503eeb..29a96c883b 100644 --- a/webapi/src/test/scala/org/knora/webapi/e2e/v2/StandoffRouteV2E2ESpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/it/v2/StandoffRouteV2ITSpec.scala @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.knora.webapi.e2e.v2 +package org.knora.webapi.it.v2 import akka.http.javadsl.model.StatusCodes import akka.http.scaladsl.model.HttpEntity @@ -40,9 +40,9 @@ import org.knora.webapi.util.FileUtil import org.knora.webapi.util.MutableTestIri /** - * End-to-end test specification for the standoff endpoint. + * Integration test specification for the standoff endpoint. */ -class StandoffRouteV2E2ESpec extends E2ESpec with AuthenticationV2JsonProtocol { +class StandoffRouteV2ITSpec extends ITKnoraLiveSpec with AuthenticationV2JsonProtocol { private implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -130,7 +130,7 @@ class StandoffRouteV2E2ESpec extends E2ESpec with AuthenticationV2JsonProtocol { val request = Get( s"$baseApiUrl/v2/resources/$iri" ) ~> addCredentials(BasicHttpCredentials(anythingUserEmail, password)) - getResponseAsJsonLD(request) + getResponseJsonLD(request) } "The Standoff v2 Endpoint" should {