From 0356ef875725fe4514fea26e69944a3a5fc4268f Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Tue, 28 Jun 2022 17:23:02 -0700 Subject: [PATCH] Use config.test.rb instead of OVERRIDE_CONFIG, add dip support --- .github/workflows/ruby-unit-tests-ag.yml | 2 +- .github/workflows/ruby-unit-tests.yml | 3 +- Gemfile.lock | 1 + config/config.test.rb | 35 +++++++++++++++ dip.yml | 56 ++++++++++++++++++++++++ docker-compose.yml | 19 +++++--- 6 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 config/config.test.rb create mode 100644 dip.yml diff --git a/.github/workflows/ruby-unit-tests-ag.yml b/.github/workflows/ruby-unit-tests-ag.yml index 8882add6..f4090d0b 100644 --- a/.github/workflows/ruby-unit-tests-ag.yml +++ b/.github/workflows/ruby-unit-tests-ag.yml @@ -12,7 +12,7 @@ jobs: - name: Set up solr configsets run: ./test/solr/generate_ncbo_configsets.sh - name: create config.rb file - run: cp config/config.rb.sample config/config.rb + run: cp config/config.test.rb config/config.rb - name: Build docker-compose run: docker-compose --profile agraph build - name: Run unit tests diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index b4e01ed3..42697af8 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -12,9 +12,8 @@ jobs: - name: Set up solr configsets run: ./test/solr/generate_ncbo_configsets.sh - name: create config.rb file - run: cp config/config.rb.sample config/config.rb + run: cp config/config.test.rb config/config.rb - name: Build docker-compose run: docker-compose --profile 4store build - name: Run unit tests run: docker-compose run ruby wait-for-it solr-ut:8983 -- bundle exec rake test TESTOPTS='-v' - diff --git a/Gemfile.lock b/Gemfile.lock index 964e3378..12dfd2be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -174,6 +174,7 @@ GEM PLATFORMS x86_64-darwin-18 + x86_64-linux DEPENDENCIES activesupport (~> 4) diff --git a/config/config.test.rb b/config/config.test.rb new file mode 100644 index 00000000..6ea50e35 --- /dev/null +++ b/config/config.test.rb @@ -0,0 +1,35 @@ +### +# This file is designed for use in docker based unit testing +# +# All the defaults are set in +# https://github.com/ncbo/ontologies_linked_data/blob/master/lib/ontologies_linked_data/config/config.rb +### + +GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "4store" +GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/sparql/" +GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/data/" +GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/update/" +GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 9000 +GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost" +REDIS_HOST = ENV.include?("REDIS_HOST") ? ENV["REDIS_HOST"] : "localhost" +REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"] : 6379 +SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr/term_search_core1" +SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr/prop_search_core1" + +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.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 +# config.enable_notifications = false +end diff --git a/dip.yml b/dip.yml new file mode 100644 index 00000000..70dc642b --- /dev/null +++ b/dip.yml @@ -0,0 +1,56 @@ +version: '7.1' + +# Define default environment variables to pass +# to Docker Compose +#environment: +# RAILS_ENV: development + +compose: + files: + - .docker-compose.yml + project_name: ontologies_linked_data + +interaction: + # This command spins up a ontologies_api container with the required dependencies (solr, 4store, etc), + # and opens a terminal within it. + runner: + description: Open a Bash shell within a ontologies_api container (with dependencies up) + service: ruby + command: /bin/bash + + # Run a Rails container without any dependent services (useful for non-Rails scripts) + bash: + description: Run an arbitrary script within a container (or open a shell without deps) + service: ruby + command: /bin/bash + compose_run_options: [ no-deps ] + + # A shortcut to run Bundler commands + bundle: + description: Run Bundler commands + service: ruby + command: bundle + compose_run_options: [ no-deps ] + + # A shortcut to run unit tests + test: + description: Run minitest unit tests + service: ruby + command: bundle exec rake test + + test-ag: + description: Run minitest unit tests + service: ruby-ag + command: bundle exec rake test + + + 'redis-cli': + description: Run Redis console + service: redis-ut + command: redis-cli -h redis-ut + +#provision: + #- dip compose down --volumes + #- dip compose up -d solr 4store + #- dip bundle install + #- dip bash -c bin/setup diff --git a/docker-compose.yml b/docker-compose.yml index 7436f1d5..da3d7d71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,19 +6,24 @@ x-app: &app # Increase the version number in the image tag every time Dockerfile or its arguments is changed image: ontologies_ld-dev:0.0.2 environment: &env + # default bundle config resolves to /usr/local/bundle/config inside of the container + # we are setting it to local app directory if we need to use 'bundle config local' + BUNDLE_APP_CONFIG: /srv/ontoportal/ontologies_api/.bundle BUNDLE_PATH: /srv/ontoportal/bundle COVERAGE: 'true' - OVERRIDE_CONFIG: 'true' - # OVERRIDE_CONNECT_GOO: 'true' - REDIS_HOST: 'redis-ut' + REDIS_HOST: redis-ut REDIS_PORT: 6379 - SOLR_HOST: 'solr-ut' + SOLR_TERM_SEARCH_URL: http://solr-ut:8983/solr/term_search_core1 + SOLR_PROP_SEARCH_URL: http://solr-ut:8983/solr/prop_search_core1 stdin_open: true tty: true - command: "/bin/bash" + command: /bin/bash volumes: + # bundle volume for hosting gems installed by bundle; it speeds up gem install in local development - bundle:/srv/ontoportal/bundle - .:/srv/ontoportal/ontologies_linked_data + # mount directory containing development version of the gems if you need to use 'bundle config local' + #- /Users/alexskr/ontoportal:/Users/alexskr/ontoportal depends_on: - solr-ut - redis-ut @@ -36,7 +41,7 @@ services: GOO_PATH_DATA: /data/ GOO_PATH_UPDATE: /update/ profiles: - - '4store' + - 4store depends_on: - solr-ut - redis-ut @@ -54,7 +59,7 @@ services: GOO_PATH_DATA: /repositories/bioportal_test/statements GOO_PATH_UPDATE: /repositories/bioportal_test/statements profiles: - - 'agraph' + - agraph depends_on: - solr-ut - redis-ut