swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7fd5f787df60>
def test_journal_client_origin_visit_status_from_journal_last_failed(swh_scheduler):
visit_statuses = [
{
"origin": "foo",
"visit": 1,
"status": "partial",
"date": utcnow(),
"type": "git",
"snapshot": None,
},
{
"origin": "bar",
"visit": 2,
"status": "full",
"date": D1,
"type": "git",
"snapshot": None,
},
]
process_journal_objects(
{"origin_visit_status": visit_statuses}, scheduler=swh_scheduler
)
# Ensure those visit status are ignored
for visit_status in visit_statuses:
actual_origin_visit_stats = swh_scheduler.origin_visit_stats_get(
visit_status["origin"], visit_status["type"]
)
assert actual_origin_visit_stats is not None
assert actual_origin_visit_stats == OriginVisitStats(
url=visit_status["origin"],
visit_type=visit_status["type"],
last_eventful=None,
last_uneventful=None,
last_failed=visit_status["date"],
last_notfound=None,
last_snapshot=None,
)
visit_statuses = [
{
"origin": "bar",
"visit": 3,
"status": "full",
"date": D3,
"type": "git",
"snapshot": None,
},
{
"origin": "bar",
"visit": 3,
"status": "full",
"date": D2,
"type": "git",
"snapshot": None,
},
]
process_journal_objects(
> {"origin_visit_status": visit_statuses}, scheduler=swh_scheduler
)
.tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_journal_client.py:209:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/scheduler/journal_client.py:89: in process_journal_objects
scheduler.origin_visit_stats_upsert(origin_visit_stats)
.tox/py3/lib/python3.7/site-packages/swh/core/db/common.py:62: in _meth
return meth(self, *args, db=db, cur=cur, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/scheduler/backend.py:813: in origin_visit_stats_upsert
fetch=False,
.tox/py3/lib/python3.7/site-packages/psycopg2/extras.py:1292: in execute_values
cur.execute(b''.join(parts))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <cursor object at 0x7fd5fee83348; closed: -1>
query = b"\n INSERT into origin_visit_stats AS ovi (last_eventful, last_failed, last_notfound, last_snapshot, last_...\n else ovi.last_snapshot -- touch nothing\n end\n )\n "
vars = None
def execute(self, query, vars=None):
self.column_mapping = []
self._query_executed = True
> return super(RealDictCursor, self).execute(query, vars)
E psycopg2.errors.CardinalityViolation: ON CONFLICT DO UPDATE command cannot affect row a second time
E HINT: Ensure that no rows proposed for insertion within the same command have duplicate constrained values.
.tox/py3/lib/python3.7/site-packages/psycopg2/extras.py:251: CardinalityViolation
TEST RESULT
TEST RESULT
- Run At
- Jan 15 2021, 8:54 AM