From 0723ea22870d2c051d0d4871ddc1bd99daef035a Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 13 Feb 2026 16:55:13 -0800 Subject: [PATCH 1/4] add ontoportal testkit --- .github/workflows/ruby-unit-tests.yml | 32 ------- .ontoportal-testkit.yml | 9 ++ Dockerfile | 28 +----- Gemfile | 1 + Gemfile.lock | 14 ++- docker-compose.yml | 121 -------------------------- rakelib/ontoportal_testkit.rake | 2 + test/test_case.rb | 2 +- test/test_mgrep_client.rb | 2 +- 9 files changed, 30 insertions(+), 181 deletions(-) delete mode 100644 .github/workflows/ruby-unit-tests.yml create mode 100644 .ontoportal-testkit.yml delete mode 100644 docker-compose.yml create mode 100644 rakelib/ontoportal_testkit.rake diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml deleted file mode 100644 index f2d562b..0000000 --- a/.github/workflows/ruby-unit-tests.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Ruby Unit Tests - -on: - push: - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - backend: ['ruby', 'ruby-agraph'] # api runs tests with 4store backend and api-agraph runs with AllegroGraph backend - steps: - - uses: actions/checkout@v4 - - name: copy config file - run: cp config/config.test.rb config/config.rb - - name: Build docker compose - run: docker compose build - - name: Run unit tests - # unit tests are run inside a container - # http://docs.codecov.io/docs/testing-with-docker - run: | - ci_env=`bash <(curl -s https://codecov.io/env)` - docker compose run $ci_env -e CI ${{ matrix.backend }} 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/.ontoportal-testkit.yml b/.ontoportal-testkit.yml new file mode 100644 index 0000000..ecf441a --- /dev/null +++ b/.ontoportal-testkit.yml @@ -0,0 +1,9 @@ +component_name: ncbo_annotator +app_service: test-linux +backends: + - fs + - ag + - vo + - gd +dependency_services: + - mgrep diff --git a/Dockerfile b/Dockerfile index c585383..6c56623 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,18 @@ -ARG RUBY_VERSION=3.1 +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 \ - 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 -# Use a dedicated bundle path -ENV BUNDLE_PATH=/usr/local/bundle -ENV GEM_HOME=/usr/local/bundle -ENV PATH="$BUNDLE_PATH/bin:$PATH" - COPY Gemfile* *.gemspec ./ -RUN gem update --system - -#I nstall the exact Bundler version from Gemfile.lock (if it exists) +# 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 --local path '/usr/local/bundle' -RUN bundle config set --global no-document 'true' RUN bundle install --jobs 4 --retry 3 COPY . ./ diff --git a/Gemfile b/Gemfile index 9be1a91..ff153cc 100644 --- a/Gemfile +++ b/Gemfile @@ -23,3 +23,4 @@ end gem 'goo', github: 'ncbo/goo', branch: 'ontoportal-lirmm-development' gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'chore/ontoportal-lirmm-goo-compat' gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'ontoportal-lirmm-development' +gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main' diff --git a/Gemfile.lock b/Gemfile.lock index c28ad4b..9c4ef40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,14 @@ +GIT + remote: https://github.com/alexskr/ontoportal_testkit.git + revision: 3f3887feb5b73c74ce9507068f256ad7384c72c2 + branch: main + specs: + ontoportal_testkit (0.1.0) + rake (>= 13.0) + GIT remote: https://github.com/ncbo/goo.git - revision: 13a8559a2346cc8320d7d36046646907bfa8a27c + revision: f6310650f578200f0e1465bd013dc5a737ef0170 branch: ontoportal-lirmm-development specs: goo (0.0.2) @@ -18,7 +26,7 @@ GIT GIT remote: https://github.com/ncbo/ontologies_linked_data.git - revision: 3204c0a830d344eb9ae1db82c22b46be1ef468b3 + revision: 36879f444b5bbbc4c468ed20dca83ac419d1105b branch: chore/ontoportal-lirmm-goo-compat specs: ontologies_linked_data (0.0.1) @@ -263,6 +271,7 @@ DEPENDENCIES minitest-reporters oj (~> 3.0) ontologies_linked_data! + ontoportal_testkit! parallel pry rake @@ -335,6 +344,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 pony (1.13.1) sha256=ab507c8ade8b35de96f1e75c0ae4566a3c40ac8a0d5101433969b6fd29c718a7 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index c643b99..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,121 +0,0 @@ -x-app: &app - image: ncbo_annotator:0.0.3 - build: - context: . - args: - RUBY_VERSION: '3.2' - environment: &env - COVERAGE: 'true' # enable simplecov code coverage - REDIS_HOST: redis-ut - REDIS_PORT: 6379 - MGREP_HOST: mgrep-ut - MGREP_PORT: 55556 - SOLR_TERM_SEARCH_URL: http://solr-ut:8983/solr - SOLR_PROP_SEARCH_URL: http://solr-ut:8983/solr - volumes: - - .:/app - - bundle:/usr/local/bundle - stdin_open: true - tty: true - command: "bundle exec rake test TESTOPTS='-v'" - depends_on: &depends_on - solr-ut: - condition: service_healthy - redis-ut: - condition: service_healthy - mgrep-ut: - condition: service_healthy - -services: - ruby: - <<: *app - environment: - <<: *env - GOO_BACKEND_NAME: 4store - GOO_PORT: 9000 - GOO_HOST: 4store-ut - depends_on: - <<: *depends_on - 4store-ut: - condition: service_started - profiles: - - 4store - - ruby-agraph: - <<: *app - environment: - <<: *env - GOO_BACKEND_NAME: ag - 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: - <<: *depends_on - agraph-ut: - condition: service_healthy - profiles: - - agraph - - solr-ut: - image: ontoportal/solr-ut:0.2.0 - healthcheck: - test: ["CMD-SHELL", "curl -sf http://localhost:8983/solr/term_search_core1/admin/ping?wt=json | grep -iq '\"status\":\"OK\"}' || exit 1"] - start_period: 3s - interval: 10s - timeout: 5s - retries: 5 - - redis-ut: - image: redis - healthcheck: - test: redis-cli ping - interval: 10s - timeout: 3s - retries: 10 - - mgrep-ut: - image: ontoportal/mgrep:0.0.3 - platform: linux/amd64 - healthcheck: - test: ["CMD", "nc", "-z", "-v", "127.0.0.1", "55556"] - start_period: 3s - interval: 10s - timeout: 5s - retries: 5 - - 4store-ut: - image: bde2020/4store - platform: linux/amd64 - command: > - bash -c "4s-backend-setup --segments 4 ontoportal_kb - && 4s-backend ontoportal_kb - && 4s-httpd -D -s-1 -p 9000 ontoportal_kb" - profiles: - - 4store - - agraph-ut: - image: franzinc/agraph:v8.3.1 - platform: linux/amd64 - environment: - - AGRAPH_SUPER_USER=test - - AGRAPH_SUPER_PASSWORD=xyzzy - shm_size: 1g - 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-SHELL", "agtool storage-report ontoportal_test || exit 1"] - start_period: 30s - interval: 10s - timeout: 5s - retries: 5 - profiles: - - agraph - -volumes: - bundle: diff --git a/rakelib/ontoportal_testkit.rake b/rakelib/ontoportal_testkit.rake new file mode 100644 index 0000000..7f04305 --- /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/test_case.rb b/test/test_case.rb index 443693d..1311615 100644 --- a/test/test_case.rb +++ b/test/test_case.rb @@ -16,7 +16,7 @@ end require_relative '../lib/ncbo_annotator' -require_relative '../config/config' +require_relative '../config/config.test' # Check to make sure you want to run if not pointed at localhost safe_host = Regexp.new(/localhost|-ut|ncbo-dev*|ncbo-unittest*/) diff --git a/test/test_mgrep_client.rb b/test/test_mgrep_client.rb index 7a70ca6..921b581 100644 --- a/test/test_mgrep_client.rb +++ b/test/test_mgrep_client.rb @@ -2,7 +2,7 @@ require "minitest/autorun" require_relative "../lib/ncbo_annotator.rb" -require_relative "../config/config.rb" +require_relative "../config/config.test" class TestMgrepClient < Minitest::Test From 9592a2f956ff568e10f66776950d6e31984faa90 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 13 Feb 2026 17:00:46 -0800 Subject: [PATCH 2/4] add ontoportal testkit --- .github/workflows/testkit-unit-tests.yml | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/testkit-unit-tests.yml diff --git a/.github/workflows/testkit-unit-tests.yml b/.github/workflows/testkit-unit-tests.yml new file mode 100644 index 0000000..eae8509 --- /dev/null +++ b/.github/workflows/testkit-unit-tests.yml @@ -0,0 +1,55 @@ +name: Docker Unit Tests + +on: + push: + branches: + - '**' + tags-ignore: + - '**' + pull_request: + +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: Run unit tests in linux container + env: + CI: "true" + TESTOPTS: "-v" + run: bundle exec rake test:docker:${{ matrix.backend }}:linux + + - 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 From f51d61b68b2fb677d5f75c737085dcba8f017de3 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 13 Feb 2026 20:05:01 -0800 Subject: [PATCH 3/4] testkit init update --- .github/workflows/testkit-unit-tests.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testkit-unit-tests.yml b/.github/workflows/testkit-unit-tests.yml index eae8509..89e3f54 100644 --- a/.github/workflows/testkit-unit-tests.yml +++ b/.github/workflows/testkit-unit-tests.yml @@ -38,13 +38,20 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: .ruby-version - bundler-cache: true + + - name: Checkout ontoportal_testkit + uses: actions/checkout@v4 + with: + repository: alexskr/ontoportal_testkit + path: .tooling/ontoportal_testkit - name: Run unit tests in linux container env: CI: "true" TESTOPTS: "-v" - run: bundle exec rake test:docker:${{ matrix.backend }}:linux + BACKEND: ${{ matrix.backend }} + run: | + ruby -I .tooling/ontoportal_testkit/lib -e 'require "rake"; require "ontoportal/testkit/tasks"; Rake::Task["test:docker:#{ENV.fetch("BACKEND")}:linux"].invoke' - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 From 8100998f2986d530b46f270c99f82683e9dfaa13 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Tue, 24 Feb 2026 13:17:04 -0800 Subject: [PATCH 4/4] update config for unit tests --- Gemfile | 2 +- Gemfile.lock | 9 ++++----- config/config.test.rb | 25 ++++++++++++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index ff153cc..fedff20 100644 --- a/Gemfile +++ b/Gemfile @@ -17,10 +17,10 @@ group :test do gem 'pry' gem 'simplecov' gem 'simplecov-cobertura' # for codecov.io + gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main' end # NCBO gems (can be from a local dev path or from rubygems/git) gem 'goo', github: 'ncbo/goo', branch: 'ontoportal-lirmm-development' gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'chore/ontoportal-lirmm-goo-compat' gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'ontoportal-lirmm-development' -gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main' diff --git a/Gemfile.lock b/Gemfile.lock index 9c4ef40..79eb567 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/alexskr/ontoportal_testkit.git - revision: 3f3887feb5b73c74ce9507068f256ad7384c72c2 + revision: c1eb12818b208f6d9ed46c6793e6115135052f16 branch: main specs: ontoportal_testkit (0.1.0) @@ -26,7 +26,7 @@ GIT GIT remote: https://github.com/ncbo/ontologies_linked_data.git - revision: 36879f444b5bbbc4c468ed20dca83ac419d1105b + revision: 637fdfcfc0f9201a631b4d827d34aa8993325565 branch: chore/ontoportal-lirmm-goo-compat specs: ontologies_linked_data (0.0.1) @@ -156,7 +156,7 @@ GEM uri (>= 0.11.1) net-http-persistent (4.0.8) connection_pool (>= 2.2.4, < 4) - net-imap (0.6.2) + net-imap (0.6.3) date net-protocol net-pop (0.1.2) @@ -253,7 +253,6 @@ PLATFORMS arm-linux-gnu arm-linux-musl arm64-darwin - ruby x86-linux-gnu x86-linux-musl x86_64-darwin @@ -336,7 +335,7 @@ CHECKSUMS net-ftp (0.3.9) sha256=307817ccf7f428f79d083f7e36dbb46a9d1d375e0d23027824de1866f0b13b65 net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996 net-http-persistent (4.0.8) sha256=ef3de8319d691537b329053fae3a33195f8b070bbbfae8bf1a58c796081960e6 - net-imap (0.6.2) sha256=08caacad486853c61676cca0c0c47df93db02abc4a8239a8b67eb0981428acc6 + net-imap (0.6.3) sha256=9bab75f876596d09ee7bf911a291da478e0cd6badc54dfb82874855ccc82f2ad net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3 net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736 diff --git a/config/config.test.rb b/config/config.test.rb index c33e281..cd918bb 100644 --- a/config/config.test.rb +++ b/config/config.test.rb @@ -16,20 +16,27 @@ SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr" SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr" - LinkedData.config do |config| - config.goo_backend_name = GOO_BACKEND_NAME.to_s - config.goo_host = GOO_HOST.to_s - config.goo_port = GOO_PORT.to_i - config.goo_path_query = GOO_PATH_QUERY.to_s - config.goo_path_data = GOO_PATH_DATA.to_s - config.goo_path_update = GOO_PATH_UPDATE.to_s - config.search_server_url = SOLR_TERM_SEARCH_URL.to_s - config.property_search_server_url = SOLR_PROP_SEARCH_URL.to_s + config.goo_backend_name = GOO_BACKEND_NAME.to_s + config.goo_host = GOO_HOST.to_s + config.goo_port = GOO_PORT.to_i + config.goo_path_query = GOO_PATH_QUERY.to_s + config.goo_path_data = GOO_PATH_DATA.to_s + config.goo_path_update = GOO_PATH_UPDATE.to_s + config.goo_redis_host = REDIS_HOST.to_s + config.goo_redis_port = REDIS_PORT.to_i + config.http_redis_host = REDIS_HOST.to_s + config.http_redis_port = REDIS_PORT.to_i + config.ontology_analytics_redis_host = REDIS_HOST.to_s + config.ontology_analytics_redis_port = REDIS_PORT.to_i + config.search_server_url = SOLR_TERM_SEARCH_URL.to_s + config.property_search_server_url = SOLR_PROP_SEARCH_URL.to_s end Annotator.config do |config| config.mgrep_host = MGREP_HOST.to_s config.mgrep_port = MGREP_PORT.to_i + config.mgrep_alt_host = MGREP_HOST.to_s + config.mgrep_alt_port = MGREP_PORT.to_s config.mgrep_dictionary_file = './test/data/dictionary.txt' config.annotator_redis_host = REDIS_HOST.to_s config.annotator_redis_port = REDIS_PORT.to_i