Backup hover names the check and the capture separately
This commit is contained in:
@@ -412,10 +412,13 @@ def _backup_revision(db, hostname, kind, ageda):
|
||||
db.session.add(asset)
|
||||
db.session.flush()
|
||||
db.session.add(Computer(assetid=asset.assetid, hostname=hostname))
|
||||
db.session.add(BackupRevision(assetid=asset.assetid, backupkind=kind,
|
||||
sourcehostname=hostname,
|
||||
contenthash='0' * 64,
|
||||
lastseenat=_utcnow() - timedelta(days=ageda)))
|
||||
db.session.add(BackupRevision(
|
||||
assetid=asset.assetid, backupkind=kind, sourcehostname=hostname,
|
||||
contenthash='0' * 64,
|
||||
# captured well before the last confirmation on purpose: an unchanged
|
||||
# config is the normal case, and the two dates must not be conflated
|
||||
collectedat=_utcnow() - timedelta(days=ageda + 30),
|
||||
lastseenat=_utcnow() - timedelta(days=ageda)))
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@@ -461,3 +464,25 @@ def test_no_backup_at_all_is_unknown_not_good(client, db, app, auth_headers):
|
||||
row = _row_for(client, auth_headers, 'WJBAK03')
|
||||
assert row['backupkind'] is None
|
||||
assert row['backupok'] is None
|
||||
|
||||
|
||||
def test_the_capture_date_is_reported_separately_from_the_check(client, db, app, auth_headers):
|
||||
"""Two dates, two meanings: when it was last CHECKED vs last CAPTURED.
|
||||
|
||||
collectedat only moves when the config actually changed, so a healthy
|
||||
machine has a recent check against an old capture. The hover says both;
|
||||
one date would have to stand for both and ends up meaning neither.
|
||||
"""
|
||||
_seed_and_publish(app)
|
||||
secret = _token(client, auth_headers, ['geenforce.report'])
|
||||
_backup_revision(db, 'WJBAK04', 'ntlars', ageda=1)
|
||||
client.post('/api/geenforce/report', json={
|
||||
'hostname': 'WJBAK04', 'scopename': 'gea-shopfloor-cmm', 'counts': {}},
|
||||
headers={'X-API-Key': secret})
|
||||
|
||||
row = _row_for(client, auth_headers, 'WJBAK04')
|
||||
assert row['backupok'] is True
|
||||
assert row['backuplastseen'] is not None
|
||||
assert row['backupcollectedat'] is not None
|
||||
assert row['backupcollectedat'] < row['backuplastseen'], \
|
||||
'captured before it was last confirmed'
|
||||
|
||||
Reference in New Issue
Block a user