Skip to content

Commit fdae248

Browse files
authored
GitHub testing with virtuoso service (#16)
GitHub testing with virtuoso service * include virtuoso as a service in CI * include the tenforce/virutoso docker container as a service in the github ci.yml however, currently just the service, not yet included in any tests #15 * a basic integration test that does a simple query #15 * a simple check that the repo is connecting and querying within the Github CI environment * the default graph is unlikely to be needed #15 * wait 3 seconds extra, to give virtuoso service more time * after the container starts, it needs just a couple of seconds to initialise. Hopefully 3s is enough to avoid any sporadic errors #15 * rubocop on integration spec * uses not run! #15 * include it_behaves_like an RDF::Repository * try a different sleep action #15 * the previous one gave a warning * disable the it_behaves_like check for now #15 * extend tests to check the connection is working and some cleaning up * check with a single select which is unlikely to change, and also include a simple insert #15 * fixed invoking it_behaves_like but commented out until resolved * explicitly setting the let(:repository) caused an infinite loop and stack overflow, because the subject is already named it works without #15 * control whether the integration tests are run with an env variable #15 * Update spec/integration_spec.rb
1 parent a0902ab commit fdae248

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
env:
1717
CI: true
18+
VIRTUOSO_INTEGRATION_TESTS: true
1819
strategy:
1920
fail-fast: false
2021
matrix:
@@ -26,6 +27,15 @@ jobs:
2627
- 3.0
2728
- ruby-head # Eventualy
2829
- jruby
30+
services:
31+
virtuoso:
32+
image: tenforce/virtuoso
33+
env:
34+
DBA_PASSWORD: tester
35+
SPARQL_UPDATE: true
36+
ports:
37+
- 8890:8890
38+
- 1111:1111
2939
steps:
3040
- name: Clone repository
3141
uses: actions/checkout@v2
@@ -35,6 +45,10 @@ jobs:
3545
ruby-version: ${{ matrix.ruby }}
3646
- name: Install dependencies
3747
run: bundle install --jobs 4 --retry 3
48+
- name: Wait to give Virtuoso a little extra time
49+
uses: juliangruber/sleep-action@v1
50+
with:
51+
time: '3s'
3852
- name: Run tests
3953
run: bundle exec rspec spec
4054

spec/integration_spec.rb

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# frozen_string_literal: true
2+
3+
$LOAD_PATH.unshift '.'
4+
require_relative 'spec_helper'
5+
require 'rdf/spec/repository'
6+
7+
# these tests rely on a Virtuoso service being available, at port 8890
8+
# the easiest way to do this is with docker ( https://docs.docker.com/get-docker/ ), running the following:
9+
# docker run -p 8890:8890 -p 1111:1111 -e DBA_PASSWORD=tester -e SPARQL_UPDATE=true --name virtuoso-testing -d tenforce/virtuoso
10+
# when finished you can stop with
11+
# docker stop virtuoso-testing
12+
#
13+
# to avoid the tests being skipped, you will need to set the environment variable VIRTUOSO_INTEGRATION_TESTS, e.g.
14+
# VIRTUOSO_INTEGRATION_TESTS=true bundle exec rspec spec
15+
16+
skip = ENV['VIRTUOSO_INTEGRATION_TESTS'] ? false : 'Skipping Integration tests against a running repository, see spec/integration_spec.rb'
17+
18+
describe RDF::Virtuoso::Repository, skip: skip do
19+
context('when interacting with a virtuoso repository service') do
20+
subject(:repository) do
21+
described_class.new(uri,
22+
update_uri: update_uri,
23+
username: username,
24+
password: password,
25+
auth_method: 'digest')
26+
end
27+
28+
let(:uri) { 'http://localhost:8890/sparql' }
29+
let(:update_uri) { 'http://localhost:8890/sparql-auth' }
30+
let(:password) { 'tester' }
31+
let(:username) { 'dba' }
32+
let(:graph) { 'http://example.org/' }
33+
34+
it 'is able to select' do
35+
# check a single triple result which is unlikely to change
36+
query = RDF::Virtuoso::Query.select.where([RDF::URI('http://localhost:8890/sparql'),
37+
RDF::URI('http://www.w3.org/ns/sparql-service-description#endpoint'), :o])
38+
39+
expect(repository.select(query).last.o).to eql RDF::URI('http://localhost:8890/sparql')
40+
end
41+
42+
it 'is able to insert' do
43+
query = RDF::Virtuoso::Query.insert([RDF::URI('subject:person'), RDF::URI('http://purl.org/dc/terms/title'),
44+
'The title']).graph(graph)
45+
expect(repository.insert(query)).to eql 'Insert into <http://example.org/>, 1 (or less) triples -- done'
46+
47+
# #clean up
48+
query = RDF::Virtuoso::Query.delete([RDF::URI('subject:person'), :p,
49+
:o]).where([RDF::URI('subject:person'), :p, :o]).graph(graph)
50+
repository.delete(query)
51+
end
52+
53+
# commented out until conformance issues are resolved, otherwise there are many errors
54+
# it_behaves_like "an RDF::Repository"
55+
end
56+
end

0 commit comments

Comments
 (0)