Skip to content

Commit

Permalink
use celerymonitor in CDS tests
Browse files Browse the repository at this point in the history
Signed-off-by: Szymon Łopaciuk <[email protected]>
  • Loading branch information
szymonlopaciuk committed Dec 12, 2017
1 parent 3c0a238 commit 7b5a6ab
Show file tree
Hide file tree
Showing 6 changed files with 1,606 additions and 72 deletions.
22 changes: 20 additions & 2 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ services:
functional_cds:
<<: *service_base
command: py.test -vv tests/functional/cds
links:
- scrapyd
depends_on:
scrapyd:
condition: service_healthy
cds-http-server.local:
condition: service_healthy

functional_pos:
<<: *service_base
Expand Down Expand Up @@ -130,6 +133,21 @@ services:
- "CMD-SHELL"
- "curl https://localhost:443/"

cds-http-server.local:
image: nginx:stable-alpine
volumes:
- ${PWD}/tests/functional/cds/fixtures/http_server/conf/proxy.conf:/etc/nginx/conf.d/default.conf
- ${PWD}/tests/functional/cds/fixtures/http_server/records:/etc/nginx/html/
ports:
- 80:80
healthcheck:
timeout: 5s
interval: 5s
retries: 5
test:
- "CMD-SHELL"
- "curl http://localhost:80/"

rabbitmq:
image: rabbitmq
healthcheck:
Expand Down
11 changes: 8 additions & 3 deletions hepcrawl/spiders/cds_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ class CDSSpider(OAIPMHSpider):

name = 'CDS'

def __init__(self, from_date=None, oai_set="forINSPIRE", *args, **kwargs):
def __init__(self,
oai_endpoint='http://cds.cern.ch/oai2d',
from_date=None,
oai_set="forINSPIRE",
*args, **kwargs):
super(CDSSpider, self).__init__(
url='http://cds.cern.ch/oai2d',
url=oai_endpoint,
metadata_prefix='marcxml',
oai_set=oai_set,
from_date=from_date,
**kwargs)
**kwargs
)

def parse_record(self, selector):
selector.remove_namespaces()
Expand Down
10 changes: 8 additions & 2 deletions hepcrawl/spiders/oaipmh_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ class OAIPMHSpider(StatefulSpider):
name = 'OAI-PMH'
granularity = _Granularity.DATE

def __init__(self, url, metadata_prefix='marcxml', oai_set=None, alias=None,
from_date=None, until_date=None, granularity=_Granularity.DATE,
def __init__(self,
url,
metadata_prefix='oai_dc',
oai_set=None,
alias=None,
from_date=None,
until_date=None,
granularity=_Granularity.DATE,
record_class=Record, *args, **kwargs):
super(OAIPMHSpider, self).__init__(*args, **kwargs)
self.url = url
Expand Down
12 changes: 12 additions & 0 deletions tests/functional/cds/fixtures/http_server/conf/proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;
server_name localhost;
charset_types text/xml;
charset UTF-8;

location /oai2d {
if ($args ~ from=2017-11-15&verb=ListRecords&set=forINSPIRE&metadataPrefix=marcxml) {
rewrite ^.*$ /cds.xml permanent;
}
}
}
Loading

0 comments on commit 7b5a6ab

Please sign in to comment.