fixing bug for live snapshot

This commit is contained in:
Cayo Puigdefabregas 2021-01-04 15:53:58 +01:00
parent e10985ed44
commit e9a5cfe2f1
4 changed files with 154 additions and 0 deletions

View File

@ -108,6 +108,8 @@ class LiveView(View):
tmp_snapshots = app.config['TMP_LIVES'] tmp_snapshots = app.config['TMP_LIVES']
path_live = save_json(res_json, tmp_snapshots, '', live=True) path_live = save_json(res_json, tmp_snapshots, '', live=True)
res_json.pop('debug', None) res_json.pop('debug', None)
res_json.pop('elapsed', None)
res_json.pop('os', None)
res_json_valid = self.schema.load(res_json) res_json_valid = self.schema.load(res_json)
live = self.live(res_json_valid) live = self.live(res_json_valid)
db.session.add(live) db.session.add(live)

112
tests/files/live.yaml Normal file
View File

@ -0,0 +1,112 @@
{
"uuid": "3a36788c-977a-4dca-8da6-11b2c067605d",
"type": "Snapshot",
"software": "WorkbenchDesktop",
"version": "1.1",
"os": "Windows 10",
"elapsed": 8.700594902038574,
"device": {
"serialNumber": "Default string",
"manufacturer": "System manufacturer",
"sku": "SKU",
"model": "To be filled by O.E.M.",
"type": "Desktop",
"chassis": "Tower"
},
"components": [
{
"type": "Motherboard",
"manufacturer": "ASUSTeK COMPUTER INC.",
"model": "PRIME B350M-A",
"serialNumber": "170398047405335"
},
{
"type": "Processor",
"manufacturer": "AMD",
"model": "AMD Ryzen 7 1700X Eight-Core Processor",
"speed": 3.775,
"address": 64,
"cores": 8,
"threads": 16,
"serialNumber": null
},
{
"type": "RamModule",
"format": "DIMM",
"size": 8192.0,
"manufacturer": "G-Skill",
"speed": 3000,
"interface": null,
"serialNumber": null
},
{
"type": "RamModule",
"format": "DIMM",
"size": 8192.0,
"manufacturer": "G-Skill",
"speed": 3000,
"interface": null,
"serialNumber": null
},
{
"model": "OCZ-VERTEX3",
"serialNumber": "OCZ-Z497M0BE7524G5Y3",
"interface": "ATA",
"size": 120034,
"type": "SolidStateDrive",
"actions": [
{
"type": "TestDataStorage",
"powerCycleCount": 3821,
"length": "Short",
"status": "Completed without error",
"elapsed": 0.23179006576538086
},
{
"type": "BenchmarkDataStorage",
"writeSpeed": 904.2566402212553,
"readSpeed": 3360.8205129630537,
"elapsed": 0.5097715854644775
}
]
},
{
"model": "Samsung SSD 860 EVO 500GB",
"serialNumber": "S3Z2NB0KB60292K",
"interface": "ATA",
"size": 500107,
"type": "SolidStateDrive",
"actions": [
{
"type": "TestDataStorage",
"powerCycleCount": 1924,
"length": "Short",
"status": "Completed without error",
"elapsed": 0.18494343757629395
},
{
"type": "BenchmarkDataStorage",
"writeSpeed": 922.3115489498899,
"readSpeed": 3855.058823544439,
"elapsed": 0.45442771911621094
}
]
},
{
"type": "GraphicCard",
"manufacturer": "Advanced Micro Devices, Inc.",
"model": "Radeon RX Vega",
"memory": 8190,
"serialNumber": null
},
{
"type": "NetworkAdapter",
"manufacturer": "Realtek",
"model": "Realtek PCIe GbE Family Controller",
"serialNumber": "88:D7:F6:42:F5:03",
"wireless": false,
"speed": 1000
}
],
"licence_version": "3.0.0"
}

View File

@ -0,0 +1,14 @@
{"uuid": "3b6a9288-0ba6-4bdd-862a-2b1f660e7114", "type": "Snapshot", "software": "Workbench", "version": "11.0b9", "elapsed": 8.08529806137085, "device": {"serialNumber": "Default string", "manufacturer": "System manufacturer", "sku": "SKU", "model": "To be filled by O.E.M.", "type": "Desktop", "chassis": "Tower"}, "components": [{"type": "Motherboard", "manufacturer": "ASUSTeK COMPUTER INC.", "model": "PRIME B350M-A", "serialNumber": "170398047405335"}, {"type": "Processor", "manufacturer": "AMD", "model": "AMD Ryzen 7 1700X Eight-Core Processor", "speed": 3.775, "address": 64, "cores": 8, "threads": 16,
"actions": [
{
"elapsed": 172,
"rate": 171.6818,
"type": "BenchmarkProcessorSysbench"
},
{
"elapsed": 0,
"rate": 6383.8,
"type": "BenchmarkProcessor"
}
],
}, {"type": "RamModule", "format": "DIMM", "size": 8192.0, "manufacturer": "G-Skill", "speed": 3000}, {"type": "RamModule", "format": "DIMM", "size": 8192.0, "manufacturer": "G-Skill", "speed": 3000}, {"type": "DataStorage", "model": "OCZ-VERTEX3", "serialNumber": "OCZ-Z497M0BE7524G5Y3", "interface": "ATA", "size": 120034, "actions": [{"type": "TestDataStorage", "powerCycleCount": 3772, "length": "Short", "status": "Completed without error", "elapsed": 0.23526978492736816}, {"type": "BenchmarkDataStorage", "writeSpeed": 665.086895851833, "readSpeed": 3148.876876875565, "elapsed": 0.45989012718200684}]}, {"type": "DataStorage", "model": "Samsung SSD 860 EVO 500GB", "serialNumber": "S3Z2NB0KB60292K", "interface": "ATA", "size": 500107, "actions": [{"type": "TestDataStorage", "powerCycleCount": 1874, "length": "Short", "status": "Completed without error", "elapsed": 0.19500422477722168}, {"type": "BenchmarkDataStorage", "writeSpeed": 668.8626650506853, "readSpeed": 3495.253333362175, "elapsed": 0.45978426933288574}]}, {"type": "GraphicCard", "manufacturer": "Advanced Micro Devices, Inc.", "model": "Radeon RX Vega"}, {"type": "NetworkAdapter", "manufacturer": "Realtek", "model": "Realtek PCIe GbE Family Controller", "serialNumber": "88:D7:F6:42:F5:03", "wireless": false, "speed": 1000}]}

View File

@ -281,6 +281,32 @@ def test_live(user: UserClient, client: Client, app: Devicehub):
assert action_live[0].licence_version == '1.0' assert action_live[0].licence_version == '1.0'
assert str(action_live[0].snapshot_uuid) == acer['uuid'] assert str(action_live[0].snapshot_uuid) == acer['uuid']
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_live_example(user: UserClient, client: Client, app: Devicehub):
"""Tests inserting a Live into the database and GETting it."""
acer = file('snapshotLive')
snapshot, _ = user.post(acer, res=models.Snapshot)
device_id = snapshot['device']['id']
db_device = Device.query.filter_by(id=1).one()
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
"devices": [device_id], "description": "aaa",
"finalUserCode": "abcdefjhi",
"startTime": "2020-11-01T02:00:00+00:00",
"endTime": "2020-12-01T02:00:00+00:00"
}
user.post(res=models.Allocate, data=post_request)
acer = file('live')
live, _ = client.post(acer, res=models.Live)
db_device = Device.query.filter_by(id=1).one()
action_live = [a for a in db_device.actions if a.type == 'Live']
assert len(action_live) == 1
assert str(action_live[0].snapshot_uuid) == acer['uuid']
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__) @pytest.mark.usefixtures(conftest.app_context.__name__)
def test_live_without_TestDataStorage(user: UserClient, client: Client, app: Devicehub): def test_live_without_TestDataStorage(user: UserClient, client: Client, app: Devicehub):