Skip to content

Commit

Permalink
add agent and ontology search tests
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Feb 17, 2024
1 parent 1fb990d commit 2e6c459
Show file tree
Hide file tree
Showing 6 changed files with 390 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 00d321a32d10acf6d659ef2aa9a305141b181cac
revision: 4773e7f90a1afba33f3d84d4b05105826465d8a9
branch: feature/index-ontology-agent-metadata
specs:
ontologies_linked_data (0.0.1)
Expand Down
56 changes: 39 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
x-app: &app
build:
context: .
args:
RUBY_VERSION: '2.7'
# Increase the version number in the image tag every time Dockerfile or its arguments is changed
image: ontologies_ld-dev:0.0.2
image: agroportal/ontologies_api:development
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'
Expand All @@ -13,15 +8,15 @@ x-app: &app
COVERAGE: 'true' # enable simplecov code coverage
REDIS_HOST: redis-ut
REDIS_PORT: 6379
SOLR_TERM_SEARCH_URL: http://solr-term-ut:8983/solr/term_search_core1
SOLR_PROP_SEARCH_URL: http://solr-prop-ut:8984/solr/prop_search_core1
SOLR_TERM_SEARCH_URL: http://solr-ut:8983/solr
SOLR_PROP_SEARCH_URL: http://solr-ut:8983/solr
stdin_open: true
tty: true
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
- .:/srv/ontoportal/ontologies_api
# mount directory containing development version of the gems if you need to use 'bundle config local'
#- /Users/alexskr/ontoportal:/Users/alexskr/ontoportal
depends_on: &depends_on
Expand All @@ -33,6 +28,27 @@ x-app: &app
condition: service_healthy

services:
api:
<<: *app
env_file:
.env
environment:
<<: *env
GOO_BACKEND_NAME: 4store
GOO_PORT: 9000
GOO_HOST: 4store-ut
GOO_PATH_QUERY: /sparql/
GOO_PATH_DATA: /data/
GOO_PATH_UPDATE: /update/
profiles:
- 4store
depends_on:
- solr-ut
- redis-ut
- mgrep-ut
- 4store-ut
ports:
- "9393:9393"

mgrep-ut:
image: ontoportal/mgrep-ncbo:0.1
Expand All @@ -52,20 +68,24 @@ services:

4store-ut:
image: bde2020/4store
volumes:
- 4store:/var/lib/4store
command: >
bash -c "4s-backend-setup --segments 4 ontoportal_kb
&& 4s-backend ontoportal_kb
&& 4s-httpd -D -s-1 -p 9000 ontoportal_kb"
bash -c "if [ ! -d '/var/lib/4store/ontoportal_kb' ]; then 4s-backend-setup --segments 4 ontoportal_kb; fi ; 4s-backend ontoportal_kb ; 4s-httpd -D -s-1 -p 9000 ontoportal_kb"
ports:
- "9000:9000"
profiles:
- fs
- 4store

solr-ut:
image: solr:8
ports:
- 8983:8983
command: bin/solr start -cloud -f
image: solr:8
ports:
- 8983:8983
command: bin/solr start -cloud -f
# volumes:
#- solr_data:/var/solr/data
agraph-ut:
image: franzinc/agraph:v8.0.0.rc1
platform: linux/amd64
Expand Down Expand Up @@ -133,4 +153,6 @@ services:

volumes:
bundle:
agdata:
agdata:
4store:
#solr_data:
19 changes: 2 additions & 17 deletions test/controllers/test_agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,9 @@ def test_delete_agent
end

private

def _agent_data(type: 'organization')
schema_agencies = LinkedData::Models::AgentIdentifier::IDENTIFIER_SCHEMES.keys
users = LinkedData::Models::User.all
users = [LinkedData::Models::User.new(username: "tim", email: "[email protected]", password: "password").save] if users.empty?
test_identifiers = 5.times.map { |i| { notation: rand.to_s[2..11], schemaAgency: schema_agencies.sample.to_s } }
user = users.sample.id.to_s

i = rand.to_s[2..11]
return {
agentType: type,
name: "name #{i}",
homepage: "home page #{i}",
acronym: "acronym #{i}",
email: "email_#{i}@test.com",
identifiers: test_identifiers.sample(2).map { |x| x.merge({ creator: user }) },
affiliations: [],
creator: user
}
agent_data(type: type)
end

def _find_agent(name)
Expand Down
14 changes: 5 additions & 9 deletions test/controllers/test_search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class TestSearchController < TestCase
def self.before_suite
LinkedData::Models::Ontology.indexClear
LinkedData::Models::Agent.indexClear
LinkedData::Models::Class.indexClear
LinkedData::Models::OntologyProperty.indexClear

count, acronyms, bro = LinkedData::SampleData::Ontology.create_ontologies_and_submissions({
process_submission: true,
acronym: "BROSEARCHTEST",
Expand Down Expand Up @@ -61,10 +64,10 @@ def self.after_suite
@@test_pc_child.delete
LinkedData::SampleData::Ontology.delete_ontologies_and_submissions
@@test_user.delete
LinkedData::Models::Class.indexClear
LinkedData::Models::Class.indexCommit
LinkedData::Models::Ontology.indexClear
LinkedData::Models::Agent.indexClear
LinkedData::Models::Class.indexClear
LinkedData::Models::OntologyProperty.indexClear
end

def test_search
Expand Down Expand Up @@ -262,11 +265,4 @@ def test_multilingual_search
end


def test_show_all_collection
get '/search/collections'
assert last_response.ok?
res = MultiJson.load(last_response.body)
assert_equal res["collections"], Goo.search_connections.keys.map(&:to_s)
end

end
Loading

0 comments on commit 2e6c459

Please sign in to comment.