diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml deleted file mode 100644 index 63d322633..000000000 --- a/.github/workflows/ruby-unit-tests.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Ruby Unit Tests - -on: - push: - branches: - - '**' - tags-ignore: - - '**' # ignore all tag pushes - pull_request: - -jobs: - test: - env: - RUBY_VERSION: '3.2' - COMPOSE_CMD: > - docker compose -f docker-compose.yml - -f dev/compose/linux/${{ matrix.triplestore }}.yml - --profile linux - --profile ${{ matrix.triplestore }} - strategy: - fail-fast: false - matrix: - #triplestore: [ 'fs', 'ag', 'vo', 'gd' ] - triplestore: [ 'fs', 'ag' ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build docker container - run: > - $COMPOSE_CMD build - - name: Run unit tests - run: > - $COMPOSE_CMD run -v "$PWD/coverage:/app/coverage" -e CI=true - test-linux bundle exec rake test TESTOPTS="-v" - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: unittests - verbose: true - fail_ci_if_error: false # optional (default = false) diff --git a/.github/workflows/testkit-unit-tests.yml b/.github/workflows/testkit-unit-tests.yml new file mode 100644 index 000000000..b5fe5ba83 --- /dev/null +++ b/.github/workflows/testkit-unit-tests.yml @@ -0,0 +1,87 @@ +name: Docker Unit Tests + +on: + push: + branches: + - '**' + tags-ignore: + - '**' + pull_request: + +env: + # CI execution mode for backend tests: + # - container: run `test:docker::container` (default) + # - native: run `test:docker:` on host Ruby + OPTK_CI_RUN_MODE: ${{ vars.OPTK_CI_RUN_MODE || 'container' }} + # Example override to force native mode in this workflow file: + # OPTK_CI_RUN_MODE: native + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + backends: ${{ steps.cfg.outputs.backends }} + steps: + - uses: actions/checkout@v4 + + - id: cfg + name: Read backend matrix from .ontoportal-testkit.yml + run: | + BACKENDS=$(ruby -ryaml -rjson -e 'c=YAML.safe_load_file(".ontoportal-testkit.yml") || {}; b=c["backends"] || %w[fs ag vo gd]; puts JSON.generate(b)') + echo "backends=$BACKENDS" >> "$GITHUB_OUTPUT" + + test: + needs: prepare + runs-on: ubuntu-latest + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + backend: ${{ fromJson(needs.prepare.outputs.backends) }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby from .ruby-version + uses: ruby/setup-ruby@v1 + with: + ruby-version: .ruby-version + bundler-cache: true + + - name: Set up Java 11 (native mode) + if: env.OPTK_CI_RUN_MODE == 'native' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '11' + + - name: Install native system dependencies + if: env.OPTK_CI_RUN_MODE == 'native' + run: | + sudo apt-get update + sudo apt-get install -y raptor2-utils + + - name: Run unit tests + env: + CI: "true" + TESTOPTS: "-v" + BACKEND: ${{ matrix.backend }} + run: | + MODE="${OPTK_CI_RUN_MODE:-container}" + TASK="test:docker:${BACKEND}" + if [ "$MODE" = "container" ]; then + TASK="${TASK}:container" + elif [ "$MODE" != "native" ]; then + echo "Invalid OPTK_CI_RUN_MODE=$MODE (expected container or native)" + exit 1 + fi + + bundle exec rake "$TASK" + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests,${{ matrix.backend }} + verbose: true + fail_ci_if_error: false diff --git a/.ontoportal-testkit.yml b/.ontoportal-testkit.yml new file mode 100644 index 000000000..ded529258 --- /dev/null +++ b/.ontoportal-testkit.yml @@ -0,0 +1,8 @@ +component_name: ontologies_linked_data +app_service: test-container +backends: + - fs + - ag + - vo + - gd +dependency_services: {} diff --git a/Dockerfile b/Dockerfile index 0b920394f..7946d8bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,21 @@ ARG RUBY_VERSION=3.2 ARG DISTRO=bullseye - -FROM ruby:$RUBY_VERSION-$DISTRO - -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - git \ - libxml2 \ - libxslt-dev \ - libxslt1-dev zlib1g-dev \ - openjdk-11-jre-headless \ - raptor2-utils \ - && rm -rf /var/lib/apt/lists/* +ARG TESTKIT_BASE_IMAGE=ontoportal/testkit-base:ruby${RUBY_VERSION}-${DISTRO} +FROM ${TESTKIT_BASE_IMAGE} WORKDIR /app -# set default test config -COPY config/config.test.rb config/config.rb - -COPY Gemfile* *.gemspec ./ - -# Copy only the `version.rb` file to prevent missing file errors! +# Copy only the `version.rb` file to prevent missing file errors COPY lib/ontologies_linked_data/version.rb lib/ontologies_linked_data/ +COPY Gemfile* *.gemspec ./ -#Install the exact Bundler version from Gemfile.lock (if it exists) -RUN gem update --system && \ - if [ -f Gemfile.lock ]; then \ +# Respect the project's Bundler lock when present. +RUN if [ -f Gemfile.lock ]; then \ BUNDLER_VERSION=$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d ' '); \ gem install bundler -v "$BUNDLER_VERSION"; \ - else \ - gem install bundler; \ fi -RUN bundle config set --global no-document 'true' RUN bundle install --jobs 4 --retry 3 COPY . ./ diff --git a/Gemfile b/Gemfile index c943fccca..caeed0534 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ group :test do gem 'minitest-reporters' gem 'mocha', '~> 2.7' gem 'mock_redis', '~> 0.5' + gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main' gem 'pry' gem 'rack-test', '~> 0.6' gem 'simplecov' @@ -41,5 +42,6 @@ end gem 'goo', github: 'ncbo/goo', branch: 'ontoportal-lirmm-development' gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'ontoportal-lirmm-development' + gem 'public_suffix', '~> 5.1.1' gem 'net-imap', '~> 0.4.18' diff --git a/Gemfile.lock b/Gemfile.lock index 68cb82777..9da2e8d1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: https://github.com/alexskr/ontoportal_testkit.git + revision: 5138aa94c028ec97adeaf1f7a5ed9f1c40b12950 + branch: main + specs: + ontoportal_testkit (0.1.0) + rake (>= 13.0) + GIT remote: https://github.com/ncbo/goo.git revision: 13a8559a2346cc8320d7d36046646907bfa8a27c @@ -96,17 +104,10 @@ GEM logger faraday-net_http (3.4.2) net-http (~> 0.5) - ffi (1.17.3) ffi (1.17.3-aarch64-linux-gnu) - ffi (1.17.3-aarch64-linux-musl) - ffi (1.17.3-arm-linux-gnu) - ffi (1.17.3-arm-linux-musl) ffi (1.17.3-arm64-darwin) - ffi (1.17.3-x86-linux-gnu) - ffi (1.17.3-x86-linux-musl) ffi (1.17.3-x86_64-darwin) ffi (1.17.3-x86_64-linux-gnu) - ffi (1.17.3-x86_64-linux-musl) hashdiff (1.2.1) htmlentities (4.3.4) http-accept (1.7.0) @@ -292,15 +293,9 @@ GEM PLATFORMS aarch64-linux-gnu - aarch64-linux-musl - arm-linux-gnu - arm-linux-musl arm64-darwin - x86-linux-gnu - x86-linux-musl x86_64-darwin x86_64-linux-gnu - x86_64-linux-musl DEPENDENCIES activesupport @@ -321,6 +316,7 @@ DEPENDENCIES oj (~> 3.0) omni_logger ontologies_linked_data! + ontoportal_testkit! pony pry public_suffix (~> 5.1.1) @@ -362,17 +358,10 @@ CHECKSUMS eventmachine (1.2.7) sha256=994016e42aa041477ba9cff45cbe50de2047f25dd418eba003e84f0d16560972 faraday (2.14.1) sha256=a43cceedc1e39d188f4d2cdd360a8aaa6a11da0c407052e426ba8d3fb42ef61c faraday-net_http (3.4.2) sha256=f147758260d3526939bf57ecf911682f94926a3666502e24c69992765875906c - ffi (1.17.3) sha256=0e9f39f7bb3934f77ad6feab49662be77e87eedcdeb2a3f5c0234c2938563d4c ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068 - ffi (1.17.3-aarch64-linux-musl) sha256=020b33b76775b1abacc3b7d86b287cef3251f66d747092deec592c7f5df764b2 - ffi (1.17.3-arm-linux-gnu) sha256=5bd4cea83b68b5ec0037f99c57d5ce2dd5aa438f35decc5ef68a7d085c785668 - ffi (1.17.3-arm-linux-musl) sha256=0d7626bb96265f9af78afa33e267d71cfef9d9a8eb8f5525344f8da6c7d76053 ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f - ffi (1.17.3-x86-linux-gnu) sha256=868a88fcaf5186c3a46b7c7c2b2c34550e1e61a405670ab23f5b6c9971529089 - ffi (1.17.3-x86-linux-musl) sha256=f0286aa6ef40605cf586e61406c446de34397b85dbb08cc99fdaddaef8343945 ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5 ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f - ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56 goo (0.0.2) hashdiff (1.2.1) sha256=9c079dbc513dfc8833ab59c0c2d8f230fa28499cc5efb4b8dd276cf931457cd1 htmlentities (4.3.4) sha256=125a73c6c9f2d1b62100b7c3c401e3624441b663762afa7fe428476435a673da @@ -412,6 +401,7 @@ CHECKSUMS oj (3.16.15) sha256=4d3324cac3e8fef54c0fa250b2af26a16dadd9f9788a1d6b1b2098b793a1b2cd omni_logger (0.1.4) sha256=b61596f7d96aa8426929e46c3500558d33e838e1afd7f4735244feb4d082bb3e ontologies_linked_data (0.0.1) + ontoportal_testkit (0.1.0) ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130 parser (3.3.10.1) sha256=06f6a725d2cd91e5e7f2b7c32ba143631e1f7c8ae2fb918fc4cebec187e6a688 diff --git a/dev/compose/linux/ag.yml b/dev/compose/linux/ag.yml deleted file mode 100644 index b56d9c8e5..000000000 --- a/dev/compose/linux/ag.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - test-linux: - environment: - GOO_BACKEND_NAME: allegrograph - GOO_PORT: 10035 - GOO_HOST: agraph-ut - GOO_PATH_QUERY: /repositories/ontoportal_test - GOO_PATH_DATA: /repositories/ontoportal_test/statements - GOO_PATH_UPDATE: /repositories/ontoportal_test/statements - depends_on: - solr-ut: - condition: service_healthy - redis-ut: - condition: service_healthy - agraph-ut: - condition: service_healthy diff --git a/dev/compose/linux/docker-compose.ci.yml b/dev/compose/linux/docker-compose.ci.yml deleted file mode 100644 index 4397c33d6..000000000 --- a/dev/compose/linux/docker-compose.ci.yml +++ /dev/null @@ -1,3 +0,0 @@ -services: - test-linux: - image: ontologies_linked_data-test-linux:ci diff --git a/dev/compose/linux/fs.yml b/dev/compose/linux/fs.yml deleted file mode 100644 index 27acf4b33..000000000 --- a/dev/compose/linux/fs.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - test-linux: - environment: - GOO_BACKEND_NAME: '4store' - GOO_HOST: 4store-ut - GOO_PORT: 9000 - depends_on: - solr-ut: - condition: service_healthy - redis-ut: - condition: service_healthy - 4store-ut: - condition: service_healthy diff --git a/dev/compose/linux/gd.yml b/dev/compose/linux/gd.yml deleted file mode 100644 index 87576c734..000000000 --- a/dev/compose/linux/gd.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - test-linux: - environment: - GOO_BACKEND_NAME: graphdb - GOO_PORT: 7200 - GOO_HOST: graphdb-ut - GOO_PATH_QUERY: /repositories/ontoportal_test - GOO_PATH_DATA: /repositories/ontoportal_test/statements - GOO_PATH_UPDATE: /repositories/ontoportal_test/statements - depends_on: - solr-ut: - condition: service_healthy - redis-ut: - condition: service_healthy - graphdb-ut: - condition: service_healthy diff --git a/dev/compose/linux/no-ports.yml b/dev/compose/linux/no-ports.yml deleted file mode 100644 index f42191b93..000000000 --- a/dev/compose/linux/no-ports.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - redis-ut: - ports: [] - solr-ut: - ports: [] - agraph-ut: - ports: [] - 4store-ut: - ports: [] - virtuoso-ut: - ports: [] - graphdb-ut: - ports: [] diff --git a/dev/compose/linux/vo.yml b/dev/compose/linux/vo.yml deleted file mode 100644 index c47dd6543..000000000 --- a/dev/compose/linux/vo.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - test-linux: - environment: - GOO_BACKEND_NAME: 'virtuoso' - GOO_HOST: virtuoso-ut - GOO_PORT: 8890 - GOO_PATH_QUERY: /sparql - GOO_PATH_DATA: /sparql - GOO_PATH_UPDATE: /sparql - depends_on: - solr-ut: - condition: service_healthy - redis-ut: - condition: service_healthy - virtuoso-ut: - condition: service_healthy diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 2aec73dcf..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,126 +0,0 @@ -# unit tests in containerased env -services: - test-linux: - build: - context: . - args: - RUBY_VERSION: '3.2' - command: ["bash", "-lc", "bundle exec rake test"] - environment: - COVERAGE: 'true' # enable simplecov code coverage - REDIS_HOST: redis-ut - SOLR_TERM_SEARCH_URL: http://solr-ut:8983/solr - SOLR_PROP_SEARCH_URL: http://solr-ut:8983/solr - depends_on: - solr-ut: - condition: service_healthy - redis-ut: - condition: service_healthy - profiles: - - linux - - redis-ut: - image: redis - ports: - - 6379:6379 - command: ["redis-server", "--save", "", "--appendonly", "no"] - healthcheck: - test: redis-cli ping - interval: 10s - timeout: 3s - retries: 10 - - solr-ut: - image: solr:9 - command: bin/solr start -cloud -f - ports: - - 8983:8983 - healthcheck: - test: ["CMD", "curl", "-sf", "http://localhost:8983/solr/admin/info/system?wt=json"] - start_period: 5s - interval: 10s - timeout: 5s - retries: 5 - - 4store-ut: - image: bde2020/4store - platform: linux/amd64 - ports: - - 9000:9000 - command: > - bash -c "4s-backend-setup --segments 4 ontoportal_test - && 4s-backend ontoportal_test - && 4s-httpd -D -s-1 -p 9000 ontoportal_test" - healthcheck: - test: ["CMD", "4s-backend-info", "ontoportal_test"] - start_period: 5s - interval: 10s - timeout: 10s - retries: 5 - profiles: - - fs - - agraph-ut: - image: franzinc/agraph:v8.4.3 - platform: linux/amd64 #agraph doesn't provide arm platform - environment: - - AGRAPH_SUPER_USER=test - - AGRAPH_SUPER_PASSWORD=xyzzy - shm_size: 1g - ports: - - 10035:10035 - command: > - bash -c "/agraph/bin/agraph-control --config /agraph/etc/agraph.cfg start - ; agtool repos create --supersede ontoportal_test - ; agtool users add anonymous - ; agtool users grant anonymous root:ontoportal_test:rw - ; tail -f /agraph/data/agraph.log" - healthcheck: - test: ["CMD", "agtool", "storage-report", "ontoportal_test"] - start_period: 30s #AllegroGraph can take a loooooong time to start - interval: 20s - timeout: 10s - retries: 20 - profiles: - - ag - - virtuoso-ut: - image: openlink/virtuoso-opensource-7:7.2.16 - environment: - - SPARQL_UPDATE=true - - DBA_PASSWORD=dba - - DAV_PASSWORD=dba - ports: - - 1111:1111 - - 8890:8890 - volumes: - - ./test/fixtures/backends/virtuoso_initdb_d:/initdb.d - healthcheck: - test: [ "CMD-SHELL", "echo 'status();' | isql localhost:1111 dba dba || exit 1" ] - start_period: 10s - interval: 10s - timeout: 5s - retries: 3 - profiles: - - vo - - graphdb-ut: - image: ontotext/graphdb:10.8.12 - environment: - GDB_HEAP_SIZE: 5G - GDB_JAVA_OPTS: >- - -Xms5g -Xmx5g - ports: - - 7200:7200 - - 7300:7300 - healthcheck: - test: [ "CMD", "curl", "-sf", "http://localhost:7200/repositories/ontoportal_test/health" ] - start_period: 10s - interval: 10s - volumes: - - ./test/fixtures/backends/graphdb:/opt/graphdb/dist/configs/templates/data - entrypoint: > - bash -c " importrdf load -f -c /opt/graphdb/dist/configs/templates/data/graphdb-repo-config.ttl -m parallel /opt/graphdb/dist/configs/templates/data/graphdb-test-load.nt - ; graphdb -Ddefault.min.distinct.threshold=3000 " - profiles: - - gd diff --git a/rakelib/docker_based_test.rake b/rakelib/docker_based_test.rake deleted file mode 100644 index c3cd32aa8..000000000 --- a/rakelib/docker_based_test.rake +++ /dev/null @@ -1,240 +0,0 @@ -# Docker compose driven unit test orchestration -# -# Notes: -# - Backend names match compose profile names (ag, fs, vo, gd). -# - Hostnames are NOT set here. The app defaults them (localhost for host runs). -# - Linux container env is provided via compose override files: -# dev/compose/linux/ag.yml -# dev/compose/linux/fs.yml -# dev/compose/linux/vo.yml -# dev/compose/linux/gd.yml -namespace :test do - namespace :docker do - BASE_COMPOSE = 'docker-compose.yml' - LINUX_OVERRIDE_DIR = 'dev/compose/linux' - LINUX_NO_PORTS_OVERRIDE = "#{LINUX_OVERRIDE_DIR}/no-ports.yml" - TIMEOUT = (ENV['OP_TEST_DOCKER_TIMEOUT'] || '600').to_i - DEFAULT_BACKEND = (ENV['OP_TEST_DOCKER_BACKEND'] || 'fs').to_sym - - # Minimal per-backend config for host runs only. - # Do not set hostnames here. The app defaults them. - BACKENDS = { - ag: { - host_env: { - 'GOO_BACKEND_NAME' => 'allegrograph', - 'GOO_PORT' => '10035', - 'GOO_PATH_QUERY' => '/repositories/ontoportal_test', - 'GOO_PATH_DATA' => '/repositories/ontoportal_test/statements', - 'GOO_PATH_UPDATE' => '/repositories/ontoportal_test/statements' - } - }, - fs: { - host_env: { - 'GOO_BACKEND_NAME' => '4store', - 'GOO_PORT' => '9000', - 'GOO_PATH_QUERY' => '/sparql/', - 'GOO_PATH_DATA' => '/data/', - 'GOO_PATH_UPDATE' => '/update/' - } - }, - vo: { - host_env: { - 'GOO_BACKEND_NAME' => 'virtuoso', - 'GOO_PORT' => '8890', - 'GOO_PATH_QUERY' => '/sparql', - 'GOO_PATH_DATA' => '/sparql', - 'GOO_PATH_UPDATE' => '/sparql' - } - }, - gd: { - host_env: { - 'GOO_BACKEND_NAME' => 'graphdb', - 'GOO_PORT' => '7200', - 'GOO_PATH_QUERY' => '/repositories/ontoportal_test', - 'GOO_PATH_DATA' => '/repositories/ontoportal_test/statements', - 'GOO_PATH_UPDATE' => '/repositories/ontoportal_test/statements' - } - } - }.freeze - - def abort_with(msg) - warn(msg) - exit(1) - end - - def shell!(cmd) - system(cmd) || abort_with("Command failed: #{cmd}") - end - - def cfg!(key) - cfg = BACKENDS[key] - abort_with("Unknown backend key: #{key}. Supported: #{BACKENDS.keys.join(', ')}") unless cfg - cfg - end - - def compose_files(*files) - files.flatten.map { |f| "-f #{f}" }.join(' ') - end - - def linux_override_for(key) - "#{LINUX_OVERRIDE_DIR}/#{key}.yml" - end - - def compose_up(key, files:) - # Host tests use only the backend profile. Linux tests add the linux profile. - # `docker compose up --wait` only applies to services started by `up`, - # so linux runs still call `run` separately after this wait completes. - shell!("docker compose #{compose_files(files)} --profile #{key} up -d --wait --wait-timeout #{TIMEOUT}") - end - - def compose_down(files:) - return puts('OP_KEEP_CONTAINERS=1 set, skipping docker compose down') if ENV['OP_KEEP_CONTAINERS'] == '1' - - shell!( - "docker compose #{compose_files(files)} " \ - '--profile ag --profile fs --profile vo --profile gd --profile linux down' - ) - end - - def apply_host_env(key) - cfg!(key)[:host_env].each { |k, v| ENV[k] = v } - end - - def run_host_tests(key) - apply_host_env(key) - files = [BASE_COMPOSE] - - compose_up(key, files: files) - Rake::Task['test'].invoke - end - - def run_linux_tests(key) - override = linux_override_for(key) - abort_with("Missing compose override file: #{override}") unless File.exist?(override) - abort_with("Missing compose override file: #{LINUX_NO_PORTS_OVERRIDE}") unless File.exist?(LINUX_NO_PORTS_OVERRIDE) - - files = [BASE_COMPOSE, override, LINUX_NO_PORTS_OVERRIDE] - # docker compose is handleling wait_for_healthy - compose_up(key, files: files) - - shell!( - "docker compose #{compose_files(files)} --profile linux --profile #{key} " \ - 'run --rm --build test-linux bundle exec rake test TESTOPTS="-v"' - ) - end - - def run_linux_shell(key) - override = linux_override_for(key) - abort_with("Missing compose override file: #{override}") unless File.exist?(override) - abort_with("Missing compose override file: #{LINUX_NO_PORTS_OVERRIDE}") unless File.exist?(LINUX_NO_PORTS_OVERRIDE) - - files = [BASE_COMPOSE, override, LINUX_NO_PORTS_OVERRIDE] - compose_up(key, files: files) - - shell!( - "docker compose #{compose_files(files)} --profile linux --profile #{key} " \ - 'run --rm --build test-linux bash' - ) - end - - # - # Public tasks - # - - desc 'Run unit tests with AllegroGraph backend (docker deps, host Ruby)' - task :ag do - run_host_tests(:ag) - ensure - Rake::Task['test'].reenable - compose_down(files: [BASE_COMPOSE]) - end - - desc 'Run unit tests with AllegroGraph backend (docker deps, Linux container)' - task 'ag:linux' do - files = [BASE_COMPOSE, linux_override_for(:ag)] - begin - run_linux_tests(:ag) - ensure - compose_down(files: files) - end - end - - desc 'Run unit tests with 4store backend (docker deps, host Ruby)' - task :fs do - run_host_tests(:fs) - ensure - Rake::Task['test'].reenable - compose_down(files: [BASE_COMPOSE]) - end - - desc 'Run unit tests with 4store backend (docker deps, Linux container)' - task 'fs:linux' do - files = [BASE_COMPOSE, linux_override_for(:fs)] - begin - run_linux_tests(:fs) - ensure - compose_down(files: files) - end - end - - desc 'Run unit tests with Virtuoso backend (docker deps, host Ruby)' - task :vo do - run_host_tests(:vo) - ensure - Rake::Task['test'].reenable - compose_down(files: [BASE_COMPOSE]) - end - - desc 'Run unit tests with Virtuoso backend (docker deps, Linux container)' - task 'vo:linux' do - files = [BASE_COMPOSE, linux_override_for(:vo)] - begin - run_linux_tests(:vo) - ensure - compose_down(files: files) - end - end - - desc 'Run unit tests with GraphDB backend (docker deps, host Ruby)' - task :gd do - run_host_tests(:gd) - ensure - Rake::Task['test'].reenable - compose_down(files: [BASE_COMPOSE]) - end - - desc 'Run unit tests with GraphDB backend (docker deps, Linux container)' - task 'gd:linux' do - files = [BASE_COMPOSE, linux_override_for(:gd)] - begin - run_linux_tests(:gd) - ensure - compose_down(files: files) - end - end - - desc 'Start a shell in the Linux test container (default backend: fs)' - task :shell, [:backend] do |_t, args| - key = (args[:backend] || DEFAULT_BACKEND).to_sym - cfg!(key) - files = [BASE_COMPOSE, linux_override_for(key), LINUX_NO_PORTS_OVERRIDE] - begin - run_linux_shell(key) - ensure - compose_down(files: files) - end - end - - desc 'Start backend services for development (default backend: fs)' - task :up, [:backend] do |_t, args| - key = (args[:backend] || DEFAULT_BACKEND).to_sym - cfg!(key) - compose_up(key, files: [BASE_COMPOSE]) - end - - desc 'Stop backend services for development (default backend: fs)' - task :down, [:backend] do |_t, args| - compose_down(files: [BASE_COMPOSE]) - end - end -end diff --git a/rakelib/ontoportal_testkit.rake b/rakelib/ontoportal_testkit.rake new file mode 100644 index 000000000..7f04305c0 --- /dev/null +++ b/rakelib/ontoportal_testkit.rake @@ -0,0 +1,2 @@ +# Loads shared OntoPortal testkit rake tasks into this component. +require "ontoportal/testkit/tasks" diff --git a/test/fixtures/backends/graphdb/graphdb-repo-config.ttl b/test/fixtures/backends/graphdb/graphdb-repo-config.ttl deleted file mode 100644 index 84032a0b1..000000000 --- a/test/fixtures/backends/graphdb/graphdb-repo-config.ttl +++ /dev/null @@ -1,33 +0,0 @@ -@prefix rdfs: . -@prefix rep: . -@prefix sail: . -@prefix xsd: . - -<#ontoportal_test> a rep:Repository; - rep:repositoryID "ontoportal_test"; - rep:repositoryImpl [ - rep:repositoryType "graphdb:SailRepository"; - [ - "http://example.org/owlim#"; - "false"; - ""; - "true"; - "false"; - "true"; - "true"; - "32"; - "10000000"; - ""; - "true"; - ""; - "0"; - "0"; - "false"; - "file-repository"; - "rdfsplus-optimized"; - "storage"; - "false"; - sail:sailType "owlim:Sail" - ] - ]; - rdfs:label "" . diff --git a/test/fixtures/backends/graphdb/graphdb-test-load.nt b/test/fixtures/backends/graphdb/graphdb-test-load.nt deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql b/test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql deleted file mode 100644 index d509c6fb8..000000000 --- a/test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql +++ /dev/null @@ -1,3 +0,0 @@ -GRANT EXECUTE ON DB.DBA.SPARQL_INSERT_DICT_CONTENT TO "SPARQL"; -GRANT SPARQL_UPDATE TO "SPARQL"; -DB.DBA.RDF_DEFAULT_USER_PERMS_SET ('nobody', 7); diff --git a/test/models/test_ontology_submission.rb b/test/models/test_ontology_submission.rb index 6e2e7a203..2399694b6 100644 --- a/test/models/test_ontology_submission.rb +++ b/test/models/test_ontology_submission.rb @@ -411,7 +411,7 @@ def test_process_submission_archive assert old_sub.zipped? assert File.file?(old_sub.uploadFilePath) - LinkedData::Models::OntologySubmission.const_set(:FILE_SIZE_ZIPPING_THRESHOLD, old_threshold) + LinkedData::Services::OntologySubmissionArchiver.const_set(:FILE_SIZE_ZIPPING_THRESHOLD, old_threshold) end def test_submission_diff_across_ontologies diff --git a/test/rack/test_request_authorization.rb b/test/rack/test_request_authorization.rb index 9005ecc00..f087c50b2 100644 --- a/test/rack/test_request_authorization.rb +++ b/test/rack/test_request_authorization.rb @@ -3,7 +3,7 @@ require "json" require "logger" require_relative "../../lib/ontologies_linked_data" -require_relative "../../config/config.rb" +require_relative "../../config/config.test" LOGGER = Logger.new($stdout) ENV["rack.test"] = "true" @@ -63,10 +63,12 @@ def test_authorize assert_equal 401, last_response.status get "/ontologies", {}, {"Authorization" => "bogus auth header"} assert_equal 401, last_response.status + get "/ontologies", {}, {"Authorization" => 'apikey token=bugutoken'} + assert_equal 401, last_response.status get "/ontologies", {}, {"Authorization" => 'apikey token="'+@apikey+''+'"'} assert_equal 200, last_response.status apikey = MultiJson.load(last_response.body) - assert @apikey.eql?(apikey) + assert_equal @apikey, apikey get "/ontologies", {}, {"Authorization" => "apikey token=#{@apikey}"} assert_equal 200, last_response.status apikey = MultiJson.load(last_response.body) @@ -75,6 +77,8 @@ def test_authorize assert_equal 200, last_response.status apikey = MultiJson.load(last_response.body) assert_equal @apikey, apikey + get "/ontologies", {}, {"Authorization" => "apikey token=#{@apikey}&userapikey=bogusapikey"} + assert_equal 401, last_response.status get "/ontologies", {}, {"Authorization" => 'apikey token="'+@apikey+'&userapikey='+@userapikey+'"'} assert_equal 200, last_response.status apikey = MultiJson.load(last_response.body) diff --git a/test/serializer/test_serializer_json.rb b/test/serializer/test_serializer_json.rb index 5003848e6..c0fede1ff 100644 --- a/test/serializer/test_serializer_json.rb +++ b/test/serializer/test_serializer_json.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require "multi_json" require_relative "../../lib/ontologies_linked_data" -require_relative "../../config/config" +require_relative "../../config/config.test" class TestSerializerOutput < Minitest::Test class Car < LinkedData::Models::Base