self = <swh.search.tests.test_api_client.TestRemoteSearch testMethod=test_origin_intrinsic_metadata_inconsistent_type>
def test_origin_intrinsic_metadata_inconsistent_type(self):
"""Checks the same field can have a concrete value, an object, or an array
in different documents."""
origin1_foobar = {"url": "http://origin1"}
origin2_barbaz = {"url": "http://origin2"}
origin3_bazqux = {"url": "http://origin3"}
self.search.origin_update(
[
{
**origin1_foobar,
"intrinsic_metadata": {
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
> "author": {"familyName": "Foo", "givenName": "Bar",},
},
},
]
)
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_search.py:365:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:181: in meth_
return self.post(meth._endpoint_path, post_data)
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:278: in post
return self._decode_response(response)
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:354: in _decode_response
self.raise_for_status(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RemoteSearch url=http://127.0.0.1:33025/>, response = <Response [500]>
def raise_for_status(self, response) -> None:
"""check response HTTP status code and raise an exception if it denotes an
error; do nothing otherwise
"""
status_code = response.status_code
status_class = response.status_code // 100
if status_code == 404:
raise RemoteException(payload="404 not found", response=response)
exception = None
# TODO: only old servers send pickled error; stop trying to unpickle
# after they are all upgraded
try:
if status_class == 4:
data = self._decode_response(response, check_status=False)
if isinstance(data, dict):
# TODO: remove "exception" key check once all servers
# are using new schema
exc_data = data["exception"] if "exception" in data else data
for exc_type in self.reraise_exceptions:
if exc_type.__name__ == exc_data["type"]:
exception = exc_type(*exc_data["args"])
break
else:
exception = RemoteException(payload=exc_data, response=response)
else:
exception = pickle.loads(data)
elif status_class == 5:
data = self._decode_response(response, check_status=False)
if "exception_pickled" in data:
exception = pickle.loads(data["exception_pickled"])
else:
# TODO: remove "exception" key check once all servers
# are using new schema
exc_data = data["exception"] if "exception" in data else data
exception = RemoteException(payload=exc_data, response=response)
except (TypeError, pickle.UnpicklingError):
raise RemoteException(payload=data, response=response)
if exception:
> raise exception from None
E swh.core.api.RemoteException: <RemoteException 500 BulkIndexError: ['1 document(s) failed to index.', [{'update': {'_index': 'test', '_type': '_doc', '_id': '3468b61f6b312e97bdd44dd2e57e62987f20ebbb', 'status': 400, 'error': {'type': 'illegal_argument_exception', 'reason': 'failed to execute script', 'caused_by': {'type': 'script_exception', 'reason': 'compile error', 'script_stack': ['... it_types field value\nLit visit_types = ctx._source ...', ' ^---- HERE'], 'script': '\n// backup current visit_types field value\nLit visit_types = ctx._source.getOrDefault("visit_types", []);\n\n// update origin document with new field values\nctx._source.putAll(params);\n\n// restore previous visit types after visit_types field overriding\nif (ctx._source.containsKey("visit_types")) {\n for (int i = 0; i < visit_types.length; ++i) {\n if (!ctx._source.visit_types.contains(visit_types[i])) {\n ctx._source.visit_types.add(visit_types[i]);\n }\n }\n}\n', 'lang': 'painless', 'position': {'offset': 47, 'start': 22, 'end': 72}, 'caused_by': {'type': 'illegal_argument_exception', 'reason': 'invalid declaration: cannot resolve type [Lit]'}}}, 'data': {'scripted_upsert': True, 'upsert': {'url': 'http://origin1', 'intrinsic_metadata': [{'http://schema.org/author': [{'@list': [{'http://schema.org/familyName': [{'@value': 'Foo'}], 'http://schema.org/givenName': [{'@value': 'Bar'}]}]}]}], 'sha1': '3468b61f6b312e97bdd44dd2e57e62987f20ebbb'}, 'script': {'source': '\n// backup current visit_types field value\nLit visit_types = ctx._source.getOrDefault("visit_types", []);\n\n// update origin document with new field values\nctx._source.putAll(params);\n\n// restore previous visit types after visit_types field overriding\nif (ctx._source.containsKey("visit_types")) {\n for (int i = 0; i < visit_types.length; ++i) {\n if (!ctx._source.visit_types.contains(visit_types[i])) {\n ctx._source.visit_types.add(visit_types[i]);\n }\n }\n}\n', 'lang': 'painless', 'params': {'url': 'http://origin1', 'intrinsic_metadata': [{'http://schema.org/author': [{'@list': [{'http://schema.org/familyName': [{'@value': 'Foo'}], 'http://schema.org/givenName': [{'@value': 'Bar'}]}]}]}]}}}}}]]>
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:344: RemoteException
TEST RESULT
TEST RESULT
- Run At
- Jun 11 2021, 12:30 PM