add wbid in the snapshots

This commit is contained in:
Cayo Puigdefabregas 2022-03-30 13:48:55 +02:00
parent 4881aac5c9
commit ca71494e2b
6 changed files with 476 additions and 294 deletions

View file

@ -5,6 +5,7 @@ Revises: 8571fb32c912
Create Date: 2022-03-29 11:49:39.270791 Create Date: 2022-03-29 11:49:39.270791
""" """
import citext
import sqlalchemy as sa import sqlalchemy as sa
from alembic import context, op from alembic import context, op
from sqlalchemy.dialects import postgresql from sqlalchemy.dialects import postgresql
@ -29,7 +30,13 @@ def upgrade():
sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=True),
schema=f'{get_inv()}', schema=f'{get_inv()}',
) )
op.add_column(
'snapshot',
sa.Column('wbid', citext.CIText(), nullable=True),
schema=f'{get_inv()}',
)
def downgrade(): def downgrade():
op.drop_column('computer', 'uuid', schema=f'{get_inv()}') op.drop_column('computer', 'uuid', schema=f'{get_inv()}')
op.drop_column('snapshot', 'wbid', schema=f'{get_inv()}')

View file

@ -33,6 +33,7 @@ class ParseSnapshot:
"version": snapshot["version"], "version": snapshot["version"],
"endTime": snapshot["timestamp"], "endTime": snapshot["timestamp"],
"elapsed": 1, "elapsed": 1,
"wbid": snapshot["wbid"],
} }
def set_basic_datas(self): def set_basic_datas(self):
@ -339,6 +340,7 @@ class ParseSnapshotLsHw:
"version": snapshot["version"], "version": snapshot["version"],
"endTime": snapshot["timestamp"], "endTime": snapshot["timestamp"],
"elapsed": 1, "elapsed": 1,
"wbid": snapshot["wbid"],
} }
def parse_hwinfo(self): def parse_hwinfo(self):

File diff suppressed because it is too large Load diff

View file

@ -424,10 +424,12 @@ class Snapshot_lite_data(MarshmallowSchema):
class Snapshot_lite(MarshmallowSchema): class Snapshot_lite(MarshmallowSchema):
uuid = String() uuid = String(required=True)
version = String() version = String(required=True)
type = String() software = String(required=True)
timestamp = String() wbid = String(required=True)
type = String(required=True)
timestamp = String(required=True)
data = Nested(Snapshot_lite_data) data = Nested(Snapshot_lite_data)
@validates_schema @validates_schema
@ -451,6 +453,7 @@ class Snapshot(ActionWithOneDevice):
See docs for more info. See docs for more info.
""" """
uuid = UUID() uuid = UUID()
wbid = String(required=False)
software = EnumField( software = EnumField(
SnapshotSoftware, SnapshotSoftware,
required=True, required=True,

File diff suppressed because one or more lines are too long

View file

@ -274,9 +274,7 @@ def test_snapshot_component_add_remove(user: UserClient):
s3 = yaml2json( s3 = yaml2json(
'3-first-device-but-removing-motherboard-and-adding-processor-from-2.snapshot' '3-first-device-but-removing-motherboard-and-adding-processor-from-2.snapshot'
) )
snapshot_and_check( snapshot_and_check(user, s3, ('Remove',), perform_second_snapshot=False)
user, s3, ('Remove',), perform_second_snapshot=False
)
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id) pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id) pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
# Check if the update_timestamp is updated # Check if the update_timestamp is updated
@ -365,9 +363,7 @@ def test_snapshot_tag_inner_tag(user: UserClient, tag_id: str, app: Devicehub):
b = yaml2json('basic.snapshot') b = yaml2json('basic.snapshot')
b['device']['tags'] = [{'type': 'Tag', 'id': tag_id}] b['device']['tags'] = [{'type': 'Tag', 'id': tag_id}]
snapshot_and_check( snapshot_and_check(user, b, action_types=(BenchmarkProcessor.t, VisualTest.t))
user, b, action_types=(BenchmarkProcessor.t, VisualTest.t)
)
with app.app_context(): with app.app_context():
tag = Tag.query.all()[0] # type: Tag tag = Tag.query.all()[0] # type: Tag
assert tag.device_id == 3, 'Tag should be linked to the first device' assert tag.device_id == 3, 'Tag should be linked to the first device'
@ -970,6 +966,7 @@ def test_snapshot_wb_lite(user: UserClient):
ssd = [x for x in body['components'] if x['type'] == 'SolidStateDrive'][0] ssd = [x for x in body['components'] if x['type'] == 'SolidStateDrive'][0]
assert body['device']['manufacturer'] == 'lenovo' assert body['device']['manufacturer'] == 'lenovo'
assert body['wbid'] == "LXVC"
assert ssd['serialNumber'] == 's35anx0j' assert ssd['serialNumber'] == 's35anx0j'
assert res.status == '201 CREATED' assert res.status == '201 CREATED'
assert '00:28:f8:a6:d5:7e' in body['device']['hid'] assert '00:28:f8:a6:d5:7e' in body['device']['hid']