Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Webpage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LEAPS WG3
Webpage
Commits
89b10ae9
Commit
89b10ae9
authored
1 year ago
by
Sophie Servan (DESY)
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for oai-pmh endpoints
parent
6e319a57
No related branches found
Branches containing commit
No related tags found
1 merge request
!18
Add tests for oai-pmh endpoints
Pipeline
#350700
passed
1 year ago
Stage: test
Stage: build
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitlab-ci.yml
+8
-1
8 additions, 1 deletion
.gitlab-ci.yml
Gemfile
+8
-0
8 additions, 0 deletions
Gemfile
Gemfile.lock
+12
-0
12 additions, 0 deletions
Gemfile.lock
_data/facilities.yml
+2
-2
2 additions, 2 deletions
_data/facilities.yml
scripts/check_oai_pmh.rb
+54
-0
54 additions, 0 deletions
scripts/check_oai_pmh.rb
with
84 additions
and
3 deletions
.gitlab-ci.yml
+
8
−
1
View file @
89b10ae9
image
:
ruby:3.0
stages
:
-
test
-
build
variables
:
...
...
@@ -8,11 +9,17 @@ variables:
before_script
:
-
gem install bundler jekyll --no-document
-
bundle install
test
:
stage
:
test
script
:
-
bundle exec ruby scripts/check_oai_pmh.rb
allow_failure
:
true
build
:
stage
:
build
script
:
-
bundle install
-
bundle exec jekyll build
artifacts
:
paths
:
...
...
This diff is collapsed.
Click to expand it.
Gemfile
+
8
−
0
View file @
89b10ae9
...
...
@@ -2,3 +2,11 @@ source "https://rubygems.org"
# add jekyll as a dependency
gem
"
jekyll
"
# add dependencies for HTTP requests
gem
"
httparty
"
# add dependencies to work with yaml and xml files
gem
"
yaml
"
gem
"
nokogiri
"
This diff is collapsed.
Click to expand it.
Gemfile.lock
+
12
−
0
View file @
89b10ae9
...
...
@@ -13,6 +13,9 @@ GEM
forwardable-extended (2.6.0)
google-protobuf (3.23.3-x86_64-linux)
http_parser.rb (0.8.0)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jekyll (4.3.2)
...
...
@@ -44,9 +47,14 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
mini_mime (1.1.5)
multi_xml (0.6.0)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.1)
racc (1.7.3)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
...
...
@@ -61,12 +69,16 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.4.2)
webrick (1.8.1)
yaml (0.3.0)
PLATFORMS
x86_64-linux
DEPENDENCIES
httparty
jekyll
nokogiri
yaml
BUNDLED WITH
2.4.15
This diff is collapsed.
Click to expand it.
_data/facilities.yml
+
2
−
2
View file @
89b10ae9
...
...
@@ -249,9 +249,9 @@
odr
:
link
:
https://rodare.hzdr.de/
oai-pmh-endpoint
:
link
:
https://
www
.hzdr.de/
publications/OAI-PMH
?verb=Identify
link
:
https://
rodare
.hzdr.de/
oai2d
?verb=Identify
status
:
Active
last-check
:
2024-02-
07
last-check
:
2024-02-
19
## ILL ##
-
short-name
:
ILL
...
...
This diff is collapsed.
Click to expand it.
scripts/check_oai_pmh.rb
0 → 100644
+
54
−
0
View file @
89b10ae9
# check_oai_pmh.rb
require
'httparty'
require
'nokogiri'
require
'yaml'
def
check_oai_pmh_endpoint
(
endpoint_url
)
begin
response
=
HTTParty
.
head
(
endpoint_url
)
if
response
.
success?
response
=
HTTParty
.
get
(
endpoint_url
)
if
!
(
response
.
body
.
nil?
||
response
.
body
.
empty?
)
xml_response
=
Nokogiri
::
XML
(
response
.
body
)
oai_pmh_tag
=
xml_response
.
at_xpath
(
'//*[name()="OAI-PMH"]'
)
if
oai_pmh_tag
puts
"Endpoint is functional. OAI-PMH tag found in response."
return
"Active"
else
puts
"Endpoint does not contain OAI-PMH tag."
return
"Error"
end
else
puts
"Endpoint returned an empty body."
return
"Error"
end
else
puts
"Endpoint returned HTTP status code
#{
response
.
code
}
."
return
"Error"
end
rescue
StandardError
=>
e
puts
"Error occurred while accessing endpoint:
#{
e
.
message
}
"
return
"Error"
end
end
up_to_date
=
true
facilities
=
YAML
.
safe_load
(
File
.
read
(
'_data/facilities.yml'
),
permitted_classes:
[
Date
])
facilities
.
each
do
|
facility
|
odr
=
facility
[
'odr'
]
if
odr
&&
odr
.
key?
(
'oai-pmh-endpoint'
)
oai_pmh_endpoint
=
odr
[
'oai-pmh-endpoint'
][
'link'
]
if
oai_pmh_endpoint
expected_status
=
odr
[
'oai-pmh-endpoint'
][
'status'
]
puts
"Checking OAI-PMH endpoint for
#{
facility
[
'short-name'
]
}
:
#{
oai_pmh_endpoint
}
"
endpoint_status
=
check_oai_pmh_endpoint
(
oai_pmh_endpoint
)
status_match
=
expected_status
==
endpoint_status
puts
"Error: Expected status '
#{
expected_status
}
' for
#{
facility
[
'short-name'
]
}
OAI-PMH endpoint, but found status '
#{
endpoint_status
}
'."
unless
status_match
up_to_date
&=
status_match
end
end
end
exit
(
1
)
unless
up_to_date
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment