Skip to content

Commit

Permalink
minor unit testing reorg
Browse files Browse the repository at this point in the history
1. minor linting
2. remove log output from containers when unit tests are run
  • Loading branch information
alexskr committed Mar 4, 2022
1 parent f3532d2 commit 4e01ac4
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 126 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Git
.git
.gitignore
# Logs
log/*
# Temp files
tmp/*
# Editor temp files
*.swp
*.swo
test/solr
7 changes: 5 additions & 2 deletions .github/workflows/ruby-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up solr configsets
run: test/solr/generate_ncbo_configsets.sh
working-directory: ./test
run: solr/generate_ncbo_configsets.sh
- name: create config.rb file
run: cp config/config.rb.sample config/config.rb
- name: Build docker-compose
working-directory: ./test
run: docker-compose build
- name: Run unit tests
run: docker-compose up --exit-code-from unit-test
working-directory: ./test
run: docker-compose run ld-unit-test wait-for-it ld-solr-ut:8983 -- rake test TESTOPTS='-v'

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM ruby:2.6

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends vim openjdk-11-jre-headless raptor2-utils
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends openjdk-11-jre-headless raptor2-utils wait-for-it
# The Gemfile Caching Trick
RUN mkdir -p /srv/ontoportal/ontologies_linked_data
COPY Gemfile* /srv/ontoportal/ontologies_linked_data/
COPY Gemfile* *.gemspec /srv/ontoportal/ontologies_linked_data/
WORKDIR /srv/ontoportal/ontologies_linked_data
RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
RUN bundle install --binstubs
RUN bundle install

COPY . /srv/ontoportal/ontologies_linked_data

Expand Down
11 changes: 0 additions & 11 deletions run-unit-tests.sh

This file was deleted.

42 changes: 17 additions & 25 deletions docker-compose.yml → test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
version: '3'

services:
unit-test:
# volumes:
# - .:/srv/ontoportal/ontologies_linked_data
build: .
#command: "bundle exec rake test TESTOPTS='-v' TEST='./test/parser/test_owl_api_command.rb'"
ld-unit-test:
build: ../.
environment:
- OVERRIDE_CONNECT_GOO=true
- GOO_BACKEND_NAME=4store
- GOO_PORT=9000
- GOO_HOST=4store
- GOO_HOST=4store-ut
- GOO_PATH_QUERY=/sparql/
- GOO_PATH_DATA=/data/
- GOO_PATH_UPDATE=/update/
- OVERRIDE_CONNECT_GOO=true
- REDIS_HOST=redis
- REDIS_HOST=redis-ut
- REDIS_PORT=6379
- SOLR_HOST=solr
command: "bundle exec rake test TESTOPTS='-v'"
- SOLR_HOST=ld-solr-ut
command: "rake test TESTOPTS='-v'"
depends_on:
- solr
- redis
- 4store
- ld-solr-ut
- redis-ut
- 4store-ut

redis:
redis-ut:
image: redis

4store:
4store-ut:
image: bde2020/4store
ports:
- "9000:9000"
command: >
bash -c "4s-backend-setup --segments 4 ontoportal_kb
&& 4s-backend ontoportal_kb
&& 4s-httpd -D -s-1 -p 9000 ontoportal_kb"
solr:
image: solr:8.8
ld-solr-ut:
image: solr:8
volumes:
- ./test/solr/configsets:/configsets:ro
ports:
- "8983:8983"
- ./solr/configsets:/configsets:ro
#ports:
# - "8983:8983"
command: >
bash -c "precreate-core term_search_core1 /configsets/term_search
&& precreate-core prop_search_core1 /configsets/property_search
&& solr-foreground"
# mgrep:
# image: ontoportal/mgrep-ncbo:0.1
15 changes: 15 additions & 0 deletions test/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# sample script to run unit tests with docker

# add config for unit testing
[ -f ../config/config.rb ] || cp ../config/config.rb.sample ../config/config.rb

#generate solr configsets for solr container
solr/generate_ncbo_configsets.sh

# build docker containers
docker-compose build

#docker-compose up --exit-code-from unit-test
docker-compose run --rm ld-unit-test wait-for-it ld-solr-ut:8983 -- bundle exec rake test TESTOPTS='-v'

32 changes: 18 additions & 14 deletions test/solr/generate_ncbo_configsets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
# generates solr configsets by merging _default configset with config files in config/solr
# _default is copied from sorl distribuion solr-8.10.1/server/solr/configsets/_default/

#cd solr/configsets
ld_config='../config/solr'
[ -d solr/configsets/property_search ] && rm -Rf solr/configsets/property_search
[ -d solr/configsets/term_search ] && rm -Rf solr/configsets/term_search
if [[ ! -d ${ld_config}/property_search ]]; then
echo 'cant find ld solr config sets'
exit 1
fi
if [[ ! -d solr/configsets/_default/conf ]]; then
echo 'cant find default solr configset'
exit 1
fi
mkdir -p solr/configsets/property_search/conf
mkdir -p solr/configsets/term_search/conf
cp -a solr/configsets/_default/conf/* solr/configsets/property_search/conf/
cp -a solr/configsets/_default/conf/* solr/configsets/term_search/conf/
cp -a $ld_config/property_search/* solr/configsets/property_search/conf
cp -a $ld_config/term_search/* solr/configsets/term_search/conf

pushd test/solr/configsets
ld_config='../../../config/solr/'
ls -l $ld_config
pwd
[ -d property_search ] && rm -Rf property_search
[ -d term_search ] && rm -Rf property_search
[ -d $ld_config/property_search ] || echo "cant find ontologies_linked_data project"
mkdir -p property_search/conf
mkdir -p term_search/conf
cp -a _default/conf/* property_search/conf/
cp -a _default/conf/* term_search/conf/
cp -a $ld_config/property_search/* property_search/conf
cp -a $ld_config/term_search/* term_search/conf
popd
Loading

0 comments on commit 4e01ac4

Please sign in to comment.