From 6d85f314eff2ba820bc611888e75843da6a1f0a1 Mon Sep 17 00:00:00 2001 From: Xavier Bustamante Talavera Date: Thu, 19 Jul 2018 21:25:06 +0200 Subject: [PATCH] Add cpu.threads and network.wireless; add snapshots to testing / dummy --- .../files/dell-optiplexgx520.snapshot.11.yaml | 152 +++++++++++++++ .../dummy/files/hp1.snapshot.11.yaml | 142 ++++++++++++++ .../dummy/files/hp2.snapshot.11.yaml | 180 ++++++++++++++++++ .../files/lenovo-3493BAG.snapshot.11.yaml | 142 ++++++++++++++ .../dummy/files/nec.snapshot.11.yaml | 153 +++++++++++++++ .../files/real-eee-1001pxd.snapshot.11.yaml | 158 +++++++++++++++ .../files/real-hp-quad-core.snapshot.11.yaml | 116 +++++++++++ .../dummy/files/real-hp.snapshot.11.yaml | 3 +- .../dummy/files/real-toshiba.snapshot.11.yaml | 2 + .../dummy/files/smart.snapshot.11.yaml | 168 ++++++++++++++++ ereuse_devicehub/resources/device/models.py | 9 +- ereuse_devicehub/resources/device/schemas.py | 8 +- ereuse_devicehub/resources/enums.py | 1 + ereuse_devicehub/resources/event/models.py | 2 +- ereuse_devicehub/resources/event/schemas.py | 3 +- ...ssor.snapshot-and-adding-graphic-card.yaml | 1 + tests/files/real-custom.snapshot.11.yaml | 128 +++++++++++++ tests/files/real-eee-1001pxd.snapshot.11.yaml | 3 + .../files/real-hp-quad-core.snapshot.11.yaml | 116 +++++++++++ tests/files/real-hp.snapshot.11.yaml | 1 + tests/files/real-toshiba.snapshot.11.yaml | 2 + tests/test_snapshot.py | 29 ++- tests/test_workbench.py | 121 ++++++++++-- 23 files changed, 1620 insertions(+), 20 deletions(-) create mode 100644 ereuse_devicehub/dummy/files/dell-optiplexgx520.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/hp1.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/hp2.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/lenovo-3493BAG.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/nec.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/real-eee-1001pxd.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/real-hp-quad-core.snapshot.11.yaml create mode 100644 ereuse_devicehub/dummy/files/smart.snapshot.11.yaml create mode 100644 tests/files/real-custom.snapshot.11.yaml create mode 100644 tests/files/real-hp-quad-core.snapshot.11.yaml diff --git a/ereuse_devicehub/dummy/files/dell-optiplexgx520.snapshot.11.yaml b/ereuse_devicehub/dummy/files/dell-optiplexgx520.snapshot.11.yaml new file mode 100644 index 00000000..d732e595 --- /dev/null +++ b/ereuse_devicehub/dummy/files/dell-optiplexgx520.snapshot.11.yaml @@ -0,0 +1,152 @@ +{ + "device": { + "chassis": "Tower", + "serialNumber": "6G0772J", + "events": [ + { + "rate": 2.1341, + "type": "BenchmarkRamSysbench", + "elapsed": 2 + }, + { + "error": false, + "type": "StressTest", + "elapsed": 60 + } + ], + "type": "Desktop", + "manufacturer": "Dell Inc.", + "model": "OptiPlex GX520" + }, + "uuid": "bb848528-d708-4bb6-8a91-3d139d76b20f", + "software": "Workbench", + "components": [ + { + "serialNumber": null, + "address": 64, + "events": [ + { + "rate": 11970.92, + "type": "BenchmarkProcessor", + "elapsed": 0 + }, + { + "rate": 100.4242, + "type": "BenchmarkProcessorSysbench", + "elapsed": 101 + } + ], + "type": "Processor", + "manufacturer": "Intel Corp.", + "speed": 3.0, + "model": "Intel Pentium 4 CPU 3.00GHz" + }, + { + "serialNumber": null, + "events": [], + "type": "SoundCard", + "manufacturer": "Intel Corporation", + "model": "82801G AC'97 Audio Controller" + }, + { + "size": 512, + "serialNumber": "4A7012A1", + "events": [], + "speed": 533.0, + "type": "RamModule", + "format": "DIMM", + "manufacturer": "Nanya Technology", + "interface": "DDR", + "model": "NT512T64U88A0BY-37" + }, + { + "size": 512, + "serialNumber": null, + "events": [], + "speed": 533.0, + "type": "RamModule", + "format": "DIMM", + "manufacturer": null, + "interface": "DDR", + "model": null + }, + { + "serialNumber": "00:13:72:78:53:12", + "events": [], + "type": "NetworkAdapter", + "manufacturer": "Broadcom Limited", + "speed": 1000, + "model": "NetXtreme BCM5751 Gigabit Ethernet PCI Express", + "wireless": false + }, + { + "serialNumber": "5LR30DTZ", + "events": [ + { + "steps": [ + { + "error": false, + "type": "StepRandom", + "startTime": "2018-07-11T11:20:01.005336", + "endTime": "2018-07-11T11:42:12.971177" + } + ], + "zeros": false, + "error": false, + "type": "EraseBasic", + "endTime": "2018-07-11T11:42:12.975358", + "startTime": "2018-07-11T11:20:01.004892" + }, + { + "writeSpeed": 26.6, + "type": "BenchmarkDataStorage", + "readSpeed": 73.9, + "elapsed": 14 + }, + { + "length": "Short", + "error": true, + "type": "TestDataStorage", + "status": "Unspecified Error. Self-test not started.", + "elapsed": 0 + } + ], + "type": "HardDrive", + "size": 76293, + "manufacturer": "Seagate", + "interface": "ATA", + "model": "ST3808110AS" + }, + { + "serialNumber": null, + "events": [], + "type": "GraphicCard", + "manufacturer": "Intel Corporation", + "memory": 256.0, + "model": "82945G/GZ Integrated Graphics Controller" + }, + { + "slots": 0, + "usb": 5, + "serial": 1, + "events": [], + "serialNumber": "..CN1374063201S5.", + "pcmcia": 0, + "type": "Motherboard", + "firewire": 0, + "manufacturer": "Dell Inc.", + "model": "0UG982" + } + ], + "version": "11.0a3", + "closed": false, + "elapsed": 1512, + "date": "2018-07-11T11:17:00.888231", + "type": "Snapshot", + "expectedEvents": [ + "Benchmark", + "SmartTest", + "StressTest", + "EraseBasic" + ] +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/hp1.snapshot.11.yaml b/ereuse_devicehub/dummy/files/hp1.snapshot.11.yaml new file mode 100644 index 00000000..1fadfcb4 --- /dev/null +++ b/ereuse_devicehub/dummy/files/hp1.snapshot.11.yaml @@ -0,0 +1,142 @@ +{ + "software": "Workbench", + "expectedEvents": [ + "Benchmark", + "SmartTest", + "StressTest", + "EraseBasic" + ], + "closed": false, + "elapsed": -3058, + "uuid": "106930cd-e948-4cca-a8c8-1e39d6192ad6", + "date": "2018-07-11T10:47:50.822380", + "components": [ + { + "type": "Processor", + "speed": 1.199, + "events": [ + { + "type": "BenchmarkProcessor", + "rate": 23409.32, + "elapsed": 0 + }, + { + "type": "BenchmarkProcessorSysbench", + "rate": 17.0196, + "elapsed": 17 + } + ], + "serialNumber": null, + "address": 64, + "cores": 2, + "model": "Intel Core i3 CPU 530 @ 2.93GHz", + "manufacturer": "Intel Corp." + }, + { + "memory": 256.0, + "type": "GraphicCard", + "events": [], + "serialNumber": null, + "model": "Core Processor Integrated Graphics Controller", + "manufacturer": "Intel Corporation" + }, + { + "type": "NetworkAdapter", + "speed": 1000, + "events": [], + "serialNumber": "6c:62:6d:81:22:65", + "model": "82578DM Gigabit Network Connection", + "manufacturer": "Intel Corporation", + "wireless": false + }, + { + "type": "SoundCard", + "events": [], + "serialNumber": null, + "model": "5 Series/3400 Series Chipset High Definition Audio", + "manufacturer": "Intel Corporation" + }, + { + "speed": 1333.0, + "type": "RamModule", + "format": "DIMM", + "events": [], + "size": 2048, + "serialNumber": "E6002F30", + "interface": "DDR3", + "model": "16JTF25664AZ-1G4F", + "manufacturer": "JEDEC ID:80 2C" + }, + { + "type": "HardDrive", + "events": [ + { + "type": "EraseBasic", + "zeros": false, + "endTime": "2018-07-11T11:56:52.390306", + "error": false, + "startTime": "2018-07-11T10:49:31.998217", + "steps": [ + { + "type": "StepRandom", + "endTime": "2018-07-11T11:56:52.386505", + "error": false, + "startTime": "2018-07-11T10:49:31.998609" + } + ] + }, + { + "length": "Short", + "type": "TestDataStorage", + "status": "Unspecified Error. Self-test not started.", + "error": true, + "elapsed": 0 + }, + { + "type": "BenchmarkDataStorage", + "readSpeed": 61.1, + "writeSpeed": 17.1, + "elapsed": 20 + } + ], + "size": 190782, + "serialNumber": "5ND202LZ", + "interface": "ATA", + "model": "ST3200826AS", + "manufacturer": "Seagate" + }, + { + "pcmcia": 0, + "serial": 0, + "type": "Motherboard", + "slots": 0, + "events": [], + "serialNumber": "CZC0408YNC", + "usb": 2, + "firewire": 0, + "model": "304Ah", + "manufacturer": "Hewlett-Packard" + } + ], + "type": "Snapshot", + "device": { + "type": "Desktop", + "chassis": "Tower", + "events": [ + { + "type": "BenchmarkRamSysbench", + "rate": 0.9767, + "elapsed": 1 + }, + { + "type": "StressTest", + "error": false, + "elapsed": 60 + } + ], + "serialNumber": "CZC0408YNC", + "model": "HP Compaq 8100 Elite SFF", + "manufacturer": "Hewlett-Packard" + }, + "version": "11.0a3" +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/hp2.snapshot.11.yaml b/ereuse_devicehub/dummy/files/hp2.snapshot.11.yaml new file mode 100644 index 00000000..99ea49ae --- /dev/null +++ b/ereuse_devicehub/dummy/files/hp2.snapshot.11.yaml @@ -0,0 +1,180 @@ +{ + "type": "Snapshot", + "uuid": "1ced0f87-9e6e-4452-92a6-7a529df76738", + "components": [ + { + "speed": 1.199, + "cores": 2, + "model": "Intel Core i3 CPU 530 @ 2.93GHz", + "manufacturer": "Intel Corp.", + "type": "Processor", + "serialNumber": null, + "address": 64, + "events": [ + { + "elapsed": 0, + "rate": 23408.76, + "type": "BenchmarkProcessor" + }, + { + "elapsed": 17, + "rate": 17.0164, + "type": "BenchmarkProcessorSysbench" + } + ] + }, + { + "model": "Core Processor Integrated Graphics Controller", + "manufacturer": "Intel Corporation", + "type": "GraphicCard", + "serialNumber": null, + "memory": 256.0, + "events": [] + }, + { + "speed": 1000, + "model": "82578DM Gigabit Network Connection", + "manufacturer": "Intel Corporation", + "type": "NetworkAdapter", + "wireless": false, + "serialNumber": "6c:62:6d:81:21:7f", + "events": [] + }, + { + "model": "5 Series/3400 Series Chipset High Definition Audio", + "manufacturer": "Intel Corporation", + "type": "SoundCard", + "serialNumber": null, + "events": [] + }, + { + "interface": "DDR3", + "size": 2048, + "serialNumber": "E1482E29", + "model": "16JTF25664AZ-1G4F", + "format": "DIMM", + "manufacturer": "JEDEC ID:80 2C", + "type": "RamModule", + "speed": 1333.0, + "events": [] + }, + { + "interface": "ATA", + "size": 78533, + "model": "HDS72168", + "manufacturer": "Hitachi", + "type": "HardDrive", + "serialNumber": "PVB200Z30JWXRF", + "events": [ + { + "elapsed": 1, + "type": "TestDataStorage", + "error": true, + "status": "Unspecified Error. Self-test not started.", + "length": "Short" + }, + { + "writeSpeed": 25.3, + "elapsed": 14, + "type": "BenchmarkDataStorage", + "readSpeed": 77.7 + }, + { + "startTime": "2018-07-11T10:32:14.445306", + "zeros": false, + "type": "EraseBasic", + "error": false, + "endTime": "2018-07-11T10:53:46.442123", + "steps": [ + { + "startTime": "2018-07-11T10:32:14.445496", + "type": "StepRandom", + "error": false, + "endTime": "2018-07-11T10:53:46.438901" + } + ] + } + ] + }, + { + "interface": "ATA", + "size": 76324, + "model": "ST380815AS", + "manufacturer": "Seagate", + "type": "HardDrive", + "serialNumber": "9QZCVLJX", + "events": [ + { + "elapsed": 0, + "type": "TestDataStorage", + "error": true, + "status": "Unspecified Error. Self-test not started.", + "length": "Short" + }, + { + "startTime": "2018-07-11T10:53:46.442187", + "zeros": false, + "type": "EraseBasic", + "error": false, + "endTime": "2018-07-11T11:16:28.469899", + "steps": [ + { + "startTime": "2018-07-11T10:53:46.442343", + "type": "StepRandom", + "error": false, + "endTime": "2018-07-11T11:16:28.463789" + } + ] + }, + { + "writeSpeed": 22.8, + "elapsed": 15, + "type": "BenchmarkDataStorage", + "readSpeed": 74.7 + } + ] + }, + { + "firewire": 0, + "pcmcia": 0, + "model": "304Ah", + "serial": 0, + "manufacturer": "Hewlett-Packard", + "type": "Motherboard", + "serialNumber": "CZC0408YP6", + "slots": 0, + "usb": 2, + "events": [] + } + ], + "closed": false, + "version": "11.0a3", + "device": { + "model": "HP Compaq 8100 Elite SFF", + "manufacturer": "Hewlett-Packard", + "type": "Desktop", + "serialNumber": "CZC0408YP6", + "chassis": "Tower", + "events": [ + { + "error": false, + "elapsed": 60, + "type": "StressTest" + }, + { + "elapsed": 1, + "rate": 0.9783, + "type": "BenchmarkRamSysbench" + } + ] + }, + "expectedEvents": [ + "Benchmark", + "SmartTest", + "StressTest", + "EraseBasic" + ], + "software": "Workbench", + "date": "2018-07-11T10:30:22.395958", + "elapsed": 2766 +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/lenovo-3493BAG.snapshot.11.yaml b/ereuse_devicehub/dummy/files/lenovo-3493BAG.snapshot.11.yaml new file mode 100644 index 00000000..6f020866 --- /dev/null +++ b/ereuse_devicehub/dummy/files/lenovo-3493BAG.snapshot.11.yaml @@ -0,0 +1,142 @@ +{ + "uuid": "9c3560a9-371c-4392-b586-37090b5f79c6", + "version": "11.0a3", + "closed": false, + "date": "2018-07-11T13:26:29.365504", + "type": "Snapshot", + "device": { + "serialNumber": "PB357N0", + "events": [ + { + "elapsed": 60, + "type": "StressTest", + "error": false + }, + { + "elapsed": 1, + "type": "BenchmarkRamSysbench", + "rate": 0.8438 + } + ], + "chassis": "Tower", + "model": "3493BAG", + "manufacturer": "LENOVO", + "type": "Desktop" + }, + "elapsed": 2255, + "software": "Workbench", + "components": [ + { + "events": [], + "speed": 1000, + "serialNumber": "d4:3d:7e:41:c4:c4", + "model": "RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller", + "manufacturer": "Realtek Semiconductor Co., Ltd.", + "type": "NetworkAdapter", + "wireless": false + }, + { + "cores": 2, + "events": [ + { + "elapsed": 0, + "type": "BenchmarkProcessor", + "rate": 11573.64 + }, + { + "elapsed": 19, + "type": "BenchmarkProcessorSysbench", + "rate": 19.1558 + } + ], + "speed": 1.665234, + "serialNumber": null, + "address": 64, + "model": "Intel Pentium CPU G645 @ 2.90GHz", + "manufacturer": "Intel Corp.", + "type": "Processor" + }, + { + "events": [], + "memory": 256.0, + "serialNumber": null, + "model": "2nd Generation Core Processor Family Integrated Graphics Controller", + "manufacturer": "Intel Corporation", + "type": "GraphicCard" + }, + { + "events": [], + "serialNumber": null, + "model": "6 Series/C200 Series Chipset Family High Definition Audio Controller", + "manufacturer": "Intel Corporation", + "type": "SoundCard" + }, + { + "serialNumber": "292E48DA", + "events": [], + "speed": 1333.0, + "size": 2048, + "format": "DIMM", + "interface": "DDR3", + "model": "16JTF25664AZ-1G4F1", + "manufacturer": "Micron", + "type": "RamModule" + }, + { + "serialNumber": "Z2AYPLNP", + "events": [ + { + "writeSpeed": 20.4, + "type": "BenchmarkDataStorage", + "readSpeed": 139.0, + "elapsed": 15 + }, + { + "error": true, + "type": "TestDataStorage", + "elapsed": 0, + "length": "Short", + "status": "Unspecified Error. Self-test not started." + }, + { + "startTime": "2018-07-11T13:28:07.319948", + "type": "EraseBasic", + "endTime": "2018-07-11T14:04:04.864425", + "error": false, + "steps": [ + { + "startTime": "2018-07-11T13:28:07.320244", + "type": "StepRandom", + "endTime": "2018-07-11T14:04:04.861590", + "error": false + } + ], + "zeros": false + } + ], + "size": 238475, + "interface": "ATA", + "model": "ST250DM000-1BD14", + "manufacturer": "Seagate", + "type": "HardDrive" + }, + { + "serial": 1, + "usb": 2, + "pcmcia": 0, + "events": [], + "slots": 2, + "serialNumber": null, + "firewire": 0, + "model": null, + "manufacturer": "LENOVO", + "type": "Motherboard" + } + ], + "expectedEvents": [ + "Benchmark", + "SmartTest", + "StressTest", + "EraseBasic" + ] +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/nec.snapshot.11.yaml b/ereuse_devicehub/dummy/files/nec.snapshot.11.yaml new file mode 100644 index 00000000..f65ef095 --- /dev/null +++ b/ereuse_devicehub/dummy/files/nec.snapshot.11.yaml @@ -0,0 +1,153 @@ +{ + "software": "Workbench", + "uuid": "94eafe86-a99f-4507-8716-0a3a7adf1134", + "device": { + "serialNumber": "SN 123456789ABC", + "manufacturer": "NEC Computers SAS", + "events": [ + { + "error": false, + "elapsed": 60, + "type": "StressTest" + }, + { + "rate": 0.9323, + "elapsed": 1, + "type": "BenchmarkRamSysbench" + } + ], + "type": "Desktop", + "chassis": "Tower", + "model": "Powermate MLxxx" + }, + "components": [ + { + "serialNumber": "00:24:21:7a:90:02", + "manufacturer": "Intel Corporation", + "speed": 1000, + "events": [], + "type": "NetworkAdapter", + "wireless": false, + "model": "82566DM-2 Gigabit Network Connection" + }, + { + "serialNumber": null, + "manufacturer": "Intel Corp.", + "speed": 3.0, + "cores": 2, + "events": [ + { + "rate": 20.1309, + "elapsed": 20, + "type": "BenchmarkProcessorSysbench" + }, + { + "rate": 11999.24, + "elapsed": 0, + "type": "BenchmarkProcessor" + } + ], + "type": "Processor", + "model": "Intel Core2 Duo CPU E8400 @ 3.00GHz", + "address": 64 + }, + { + "serialNumber": null, + "manufacturer": "Intel Corporation", + "memory": 256.0, + "events": [], + "type": "GraphicCard", + "model": "82Q35 Express Integrated Graphics Controller" + }, + { + "serialNumber": null, + "manufacturer": "Intel Corporation", + "events": [], + "type": "SoundCard", + "model": "82801I HD Audio Controller" + }, + { + "serialNumber": "253C8F0C", + "manufacturer": "Samsung", + "speed": 667.0, + "interface": "DDR2", + "format": "DIMM", + "size": 1024, + "events": [], + "type": "RamModule", + "model": "M3 78T2863QZS-CE6" + }, + { + "serialNumber": "253C8DE7", + "manufacturer": "Samsung", + "speed": 667.0, + "interface": "DDR2", + "format": "DIMM", + "size": 1024, + "events": [], + "type": "RamModule", + "model": "M3 78T2863QZS-CE6" + }, + { + "serialNumber": "STA2L7MV39LL6D", + "manufacturer": "Hitachi", + "interface": "ATA", + "size": 305245, + "events": [ + { + "error": false, + "endTime": "2018-07-11T11:33:41.531918", + "startTime": "2018-07-11T10:30:35.643855", + "zeros": false, + "type": "EraseBasic", + "steps": [ + { + "type": "StepRandom", + "endTime": "2018-07-11T11:33:41.529224", + "startTime": "2018-07-11T10:30:35.644043", + "error": false + } + ] + }, + { + "writeSpeed": 24.1, + "elapsed": 14, + "type": "BenchmarkDataStorage", + "readSpeed": 105.0 + }, + { + "type": "TestDataStorage", + "length": "Short", + "elapsed": 1, + "error": true, + "status": "Unspecified Error. Self-test not started." + } + ], + "type": "HardDrive", + "model": "HDT72103" + }, + { + "serialNumber": "9516777584", + "manufacturer": "Micro-Star International Co Ltd", + "serial": 1, + "pcmcia": 0, + "usb": 8, + "events": [], + "type": "Motherboard", + "model": "MS-7377", + "firewire": 1, + "slots": 4 + } + ], + "version": "11.0a3", + "expectedEvents": [ + "Benchmark", + "SmartTest", + "StressTest", + "EraseBasic" + ], + "date": "2018-07-11T10:28:55.879745", + "type": "Snapshot", + "elapsed": 3886, + "closed": false +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/real-eee-1001pxd.snapshot.11.yaml b/ereuse_devicehub/dummy/files/real-eee-1001pxd.snapshot.11.yaml new file mode 100644 index 00000000..b924ac06 --- /dev/null +++ b/ereuse_devicehub/dummy/files/real-eee-1001pxd.snapshot.11.yaml @@ -0,0 +1,158 @@ +{ + "components": [ + { + "type": "NetworkAdapter", + "model": "AR9285 Wireless Network Adapter", + "serialNumber": "74:2f:68:8b:fd:c8", + "manufacturer": "Qualcomm Atheros", + "wireless": true, + "events": [] + }, + { + "type": "NetworkAdapter", + "model": "AR8152 v2.0 Fast Ethernet", + "serialNumber": "14:da:e9:42:f6:7c", + "manufacturer": "Qualcomm Atheros", + "speed": 100, + "wireless": false, + "events": [] + }, + { + "type": "Processor", + "cores": 1, + "threads": 1, + "address": 64, + "model": "Intel Atom CPU N455 @ 1.66GHz", + "serialNumber": null, + "manufacturer": "Intel Corp.", + "speed": 1.667, + "events": [ + { + "type": "BenchmarkProcessorSysbench", + "rate": 164.0803, + "elapsed": 164 + }, + { + "type": "BenchmarkProcessor", + "rate": 6666.24, + "elapsed": 0 + } + ] + }, + { + "type": "GraphicCard", + "model": "Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller", + "serialNumber": null, + "memory": 256.0, + "manufacturer": "Intel Corporation", + "events": [] + }, + { + "type": "SoundCard", + "model": "NM10/ICH7 Family High Definition Audio Controller", + "serialNumber": null, + "manufacturer": "Intel Corporation", + "events": [] + }, + { + "type": "SoundCard", + "model": "USB 2.0 UVC VGA WebCam", + "serialNumber": "0x0001", + "manufacturer": "Azurewave", + "events": [] + }, + { + "type": "RamModule", + "format": "DIMM", + "model": null, + "size": 1024, + "interface": "DDR2", + "serialNumber": null, + "manufacturer": null, + "speed": 667.0, + "events": [] + }, + { + "type": "HardDrive", + "model": "HTS54322", + "size": 238475, + "interface": "ATA", + "serialNumber": "E2024242CV86HJ", + "manufacturer": "Hitachi", + "events": [ + { + "type": "BenchmarkDataStorage", + "elapsed": 16, + "writeSpeed": 21.8, + "readSpeed": 66.2 + }, + { + "type": "TestDataStorage", + "length": "Short", + "elapsed": 2, + "error": true, + "status": "Unspecified Error. Self-test not started." + }, + { + "type": "EraseBasic", + "steps": [ + { + "type": "StepRandom", + "startTime": "2018-07-03T09:15:22.257059", + "error": false, + "endTime": "2018-07-03T10:32:11.843190" + } + ], + "startTime": "2018-07-03T09:15:22.256074", + "error": false, + "zeros": false, + "endTime": "2018-07-03T10:32:11.848455" + } + ] + }, + { + "type": "Motherboard", + "serial": 1, + "firewire": 0, + "model": "1001PXD", + "slots": 2, + "pcmcia": 0, + "serialNumber": "Eee0123456789", + "usb": 5, + "manufacturer": "ASUSTeK Computer INC.", + "events": [] + } + ], + "elapsed": 4875, + "uuid": "c058e8d2-fb92-47cb-a4b7-522b75561135", + "version": "11.0a2", + "type": "Snapshot", + "software": "Workbench", + "date": "2018-07-03T09:10:57.034598", + "device": { + "type": "Laptop", + "model": "1001PXD", + "serialNumber": "B8OAAS048286", + "manufacturer": "ASUSTeK Computer INC.", + "chassis": "Netbook", + "events": [ + { + "type": "BenchmarkRamSysbench", + "rate": 15.7188, + "elapsed": 16 + }, + { + "type": "StressTest", + "error": false, + "elapsed": 60 + } + ] + }, + "expectedEvents": [ + "Benchmark", + "SmartTest", + "StressTest", + "EraseBasic" + ], + "closed": false +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/real-hp-quad-core.snapshot.11.yaml b/ereuse_devicehub/dummy/files/real-hp-quad-core.snapshot.11.yaml new file mode 100644 index 00000000..5cd33be3 --- /dev/null +++ b/ereuse_devicehub/dummy/files/real-hp-quad-core.snapshot.11.yaml @@ -0,0 +1,116 @@ +{ + "elapsed": 4, + "type": "Snapshot", + "uuid": "0c822fb7-6e51-4781-86cf-994bd306212e", + "software": "Workbench", + "closed": false, + "date": "2018-07-05T11:57:17.284891", + "components": [ + { + "type": "NetworkAdapter", + "model": "82567LM-3 Gigabit Network Connection", + "speed": 1000, + "serialNumber": "00:23:24:0d:86:28", + "manufacturer": "Intel Corporation", + "wireless": false, + "events": [] + }, + { + "type": "NetworkAdapter", + "model": "82541PI Gigabit Ethernet Controller", + "speed": 1000, + "serialNumber": "00:0e:0c:b6:f2:91", + "manufacturer": "Intel Corporation", + "wireless": false, + "events": [] + }, + { + "cores": 4, + "type": "Processor", + "model": "Intel Core2 Quad CPU Q8400 @ 2.66GHz", + "speed": 1.9980000000000002, + "serialNumber": null, + "manufacturer": "Intel Corp.", + "events": [], + "address": 64 + }, + { + "type": "GraphicCard", + "model": "4 Series Chipset Integrated Graphics Controller", + "serialNumber": null, + "manufacturer": "Intel Corporation", + "events": [], + "memory": 256.0 + }, + { + "type": "SoundCard", + "model": "82801JD/DO HD Audio Controller", + "serialNumber": null, + "manufacturer": "Intel Corporation", + "events": [] + }, + { + "size": 2048, + "interface": "DDR3", + "type": "RamModule", + "model": "16JTF25664AZ-1G4F", + "speed": 1333.0, + "serialNumber": "F8482E29", + "format": "DIMM", + "manufacturer": "JEDEC ID:80 2C", + "events": [] + }, + { + "size": 2048, + "interface": "DDR3", + "type": "RamModule", + "model": "16JTF25664AZ-1G4F", + "speed": 1333.0, + "serialNumber": "62072F30", + "format": "DIMM", + "manufacturer": "JEDEC ID:80 2C", + "events": [] + }, + { + "size": 238475, + "interface": "ATA", + "type": "HardDrive", + "model": "ST3250318AS", + "serialNumber": "9VY6HBKE", + "manufacturer": "Seagate", + "events": [ + { + "elapsed": 0, + "type": "TestDataStorage", + "status": "Unspecified Error. Self-test not started.", + "error": true, + "length": "Short" + } + ] + }, + { + "slots": 0, + "pcmcia": 0, + "type": "Motherboard", + "model": "3646h", + "serialNumber": "CZC03217S7", + "firewire": 0, + "manufacturer": "Hewlett-Packard", + "events": [], + "serial": 0, + "usb": 8 + } + ], + "version": "11.0a3", + "device": { + "type": "Desktop", + "model": "HP Compaq 8000 Elite SFF", + "chassis": "Tower", + "serialNumber": "CZC03217S7", + "manufacturer": "Hewlett-Packard", + "events": [] + }, + "expectedEvents": [ + "SmartTest" + ] +} \ No newline at end of file diff --git a/ereuse_devicehub/dummy/files/real-hp.snapshot.11.yaml b/ereuse_devicehub/dummy/files/real-hp.snapshot.11.yaml index fa50f2f9..7a96075a 100644 --- a/ereuse_devicehub/dummy/files/real-hp.snapshot.11.yaml +++ b/ereuse_devicehub/dummy/files/real-hp.snapshot.11.yaml @@ -8,7 +8,8 @@ "type": "NetworkAdapter", "manufacturer": "Intel Corporation", "speed": 1000, - "model": "82578DM Gigabit Network Connection" + "model": "82578DM Gigabit Network Connection", + "wireless": false }, { "format": "DIMM", diff --git a/ereuse_devicehub/dummy/files/real-toshiba.snapshot.11.yaml b/ereuse_devicehub/dummy/files/real-toshiba.snapshot.11.yaml index 7a6268bd..bb899521 100644 --- a/ereuse_devicehub/dummy/files/real-toshiba.snapshot.11.yaml +++ b/ereuse_devicehub/dummy/files/real-toshiba.snapshot.11.yaml @@ -39,6 +39,7 @@ "manufacturer": "Qualcomm Atheros", "events": [], "type": "NetworkAdapter", + "wireless": true, "model": "AR9285 Wireless Network Adapter" }, { @@ -47,6 +48,7 @@ "events": [], "speed": 100, "type": "NetworkAdapter", + "wireless": false, "model": "RTL810xE PCI Express Fast Ethernet controller" }, { diff --git a/ereuse_devicehub/dummy/files/smart.snapshot.11.yaml b/ereuse_devicehub/dummy/files/smart.snapshot.11.yaml new file mode 100644 index 00000000..62861217 --- /dev/null +++ b/ereuse_devicehub/dummy/files/smart.snapshot.11.yaml @@ -0,0 +1,168 @@ +{ + "expectedEvents": [ + "Benchmark", + "TestDataStorage", + "StressTest" + ], + "device": { + "model": "HP Compaq 8100 Elite SFF", + "events": [ + { + "type": "BenchmarkRamSysbench", + "elapsed": 1, + "rate": 0.979 + }, + { + "type": "StressTest", + "elapsed": 300, + "error": false + } + ], + "serialNumber": "CZC0408YJG", + "type": "Desktop", + "manufacturer": "Hewlett-Packard", + "chassis": "Tower" + }, + "components": [ + { + "model": "Intel Core i3 CPU 530 @ 2.93GHz", + "address": 64, + "events": [ + { + "type": "BenchmarkProcessor", + "elapsed": 0, + "rate": 23408.68 + }, + { + "type": "BenchmarkProcessorSysbench", + "elapsed": 17, + "rate": 17.0138 + } + ], + "cores": 2, + "type": "Processor", + "manufacturer": "Intel Corp.", + "threads": 4, + "serialNumber": null, + "speed": 1.199 + }, + { + "model": "Core Processor Integrated Graphics Controller", + "events": [], + "serialNumber": null, + "type": "GraphicCard", + "manufacturer": "Intel Corporation", + "memory": 256.0 + }, + { + "model": "5 Series/3400 Series Chipset High Definition Audio", + "events": [], + "serialNumber": null, + "type": "SoundCard", + "manufacturer": "Intel Corporation" + }, + { + "model": "16JTF25664AZ-1G4F", + "interface": "DDR3", + "events": [], + "serialNumber": "B4012F30", + "type": "RamModule", + "manufacturer": "JEDEC ID:80 2C", + "format": "DIMM", + "size": 2048, + "speed": 1333.0 + }, + { + "model": "16JTF25664AZ-1G4F", + "interface": "DDR3", + "events": [], + "serialNumber": "8E9F2E29", + "type": "RamModule", + "manufacturer": "JEDEC ID:80 2C", + "format": "DIMM", + "size": 2048, + "speed": 1333.0 + }, + { + "model": "16JTF25664AZ-1G4F", + "interface": "DDR3", + "events": [], + "serialNumber": "9A012F30", + "type": "RamModule", + "manufacturer": "JEDEC ID:80 2C", + "format": "DIMM", + "size": 2048, + "speed": 1333.0 + }, + { + "model": "16JTF25664AZ-1G4F", + "interface": "DDR3", + "events": [], + "serialNumber": "8F9F2E29", + "type": "RamModule", + "manufacturer": "JEDEC ID:80 2C", + "format": "DIMM", + "size": 2048, + "speed": 1333.0 + }, + { + "model": "82578DM Gigabit Network Connection", + "events": [], + "serialNumber": "6c:62:6d:81:22:9f", + "type": "NetworkAdapter", + "wireless": false, + "manufacturer": "Intel Corporation", + "speed": 1000 + }, + { + "model": "WDC WD3200AAJS-6", + "interface": "ATA", + "events": [ + { + "currentPendingSectorCount": 0, + "commandTimeout": 0, + "status": "Completed without error", + "offlineUncorrectable": 1, + "powerCycleCount": 1838, + "assessment": true, + "error": false, + "type": "TestDataStorage", + "lifetime": 10546, + "reallocatedSectorCount": 0, + "reportedUncorrectableErrors": 0, + "elapsed": 115, + "length": "Short" + }, + { + "type": "BenchmarkDataStorage", + "writeSpeed": 24.6, + "readSpeed": 112.0, + "elapsed": 13 + } + ], + "serialNumber": "WD-WCAV2U909540", + "type": "HardDrive", + "manufacturer": "Western Digital", + "size": 305245 + }, + { + "model": "304Ah", + "pcmcia": 0, + "events": [], + "usb": 2, + "firewire": 0, + "type": "Motherboard", + "slots": 0, + "manufacturer": "Hewlett-Packard", + "serial": 0, + "serialNumber": "CZC0408YJG" + } + ], + "date": "2018-07-11T16:11:43.467824", + "version": "11.0a3", + "software": "Workbench", + "type": "Snapshot", + "closed": false, + "uuid": "c0c57946-d779-4e4e-b3e1-e63bd54cf939", + "elapsed": 449 +} \ No newline at end of file diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index c50e90af..f1598bb9 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -7,7 +7,7 @@ from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterfa from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE, STR_SM_SIZE, Thing from itertools import chain from sqlalchemy import BigInteger, Column, Enum as DBEnum, Float, ForeignKey, Integer, Sequence, \ - SmallInteger, Unicode, inspect + SmallInteger, Unicode, inspect, Boolean from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.orm import ColumnProperty, backref, relationship, validates from sqlalchemy.util import OrderedSet @@ -279,6 +279,10 @@ class NetworkMixin: speed.comment = """ The maximum speed this network adapter can handle, in mbps. """ + wireless = Column(Boolean) + wireless.comment = """ + Whether it is a wireless interface. + """ class NetworkAdapter(JoinedComponentTableMixin, NetworkMixin, Component): @@ -288,12 +292,13 @@ class NetworkAdapter(JoinedComponentTableMixin, NetworkMixin, Component): class Processor(JoinedComponentTableMixin, Component): speed = Column(Float, check_range('speed', 0.1, 15)) cores = Column(SmallInteger, check_range('cores', 1, 10)) + threads = Column(SmallInteger, check_range('threads', 1, 20)) address = Column(SmallInteger, check_range('address', 8, 256)) class RamModule(JoinedComponentTableMixin, Component): size = Column(SmallInteger, check_range('size', min=128, max=17000)) - speed = Column(Float, check_range('speed', min=100, max=10000)) + speed = Column(SmallInteger, check_range('speed', min=100, max=10000)) interface = Column(DBEnum(RamInterface)) format = Column(DBEnum(RamFormat)) diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 8380667b..5b186232 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -5,7 +5,7 @@ from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterfa from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE from ereuse_devicehub.resources.schemas import Thing, UnitCodes from marshmallow import post_load, pre_load -from marshmallow.fields import Float, Integer, Str +from marshmallow.fields import Float, Integer, Str, Boolean from marshmallow.validate import Length, OneOf, Range from sqlalchemy.util import OrderedSet from stdnum import imei, meid @@ -86,6 +86,7 @@ class NetworkMixin: speed = Integer(validate=Range(min=10, max=10000), unit=UnitCodes.mbps, description=m.NetworkAdapter.speed.comment) + wireless = Boolean(required=True) class Monitor(DisplayMixin, Device): @@ -163,13 +164,14 @@ class NetworkAdapter(NetworkMixin, Component): class Processor(Component): speed = Float(validate=Range(min=0.1, max=15), unit=UnitCodes.ghz) - cores = Integer(validate=Range(min=1, max=10)) # todo from numberOfCores + cores = Integer(validate=Range(min=1, max=10)) + threads = Integer(validate=Range(min=1, max=20)) address = Integer(validate=OneOf({8, 16, 32, 64, 128, 256})) class RamModule(Component): size = Integer(validate=Range(min=128, max=17000), unit=UnitCodes.mbyte) - speed = Float(validate=Range(min=100, max=10000), unit=UnitCodes.mhz) + speed = Integer(validate=Range(min=100, max=10000), unit=UnitCodes.mhz) interface = EnumField(RamInterface) format = EnumField(RamFormat) diff --git a/ereuse_devicehub/resources/enums.py b/ereuse_devicehub/resources/enums.py index 9669edc5..7bb7dbef 100644 --- a/ereuse_devicehub/resources/enums.py +++ b/ereuse_devicehub/resources/enums.py @@ -132,6 +132,7 @@ class SnapshotExpectedEvents(Enum): Benchmark = 'Benchmark' TestDataStorage = 'TestDataStorage' StressTest = 'StressTest' + EraseBasic = 'EraseBasic' EraseSectors = 'EraseSectors' SmartTest = 'SmartTest' Install = 'Install' diff --git a/ereuse_devicehub/resources/event/models.py b/ereuse_devicehub/resources/event/models.py index 2ab3ec67..81ba9ba2 100644 --- a/ereuse_devicehub/resources/event/models.py +++ b/ereuse_devicehub/resources/event/models.py @@ -113,7 +113,7 @@ class Event(Thing): order_by=lambda: Event.created, collection_class=OrderedSet), primaryjoin=parent_id == Computer.id) - """ + parent_id.comment = """ For events that are performed to components, the device parent at that time. diff --git a/ereuse_devicehub/resources/event/schemas.py b/ereuse_devicehub/resources/event/schemas.py index bc8b0770..94bb315c 100644 --- a/ereuse_devicehub/resources/event/schemas.py +++ b/ereuse_devicehub/resources/event/schemas.py @@ -5,7 +5,7 @@ from marshmallow.fields import Boolean, DateTime, Float, Integer, List, Nested, from marshmallow.validate import Length, Range from ereuse_devicehub.marshmallow import NestedOn -from ereuse_devicehub.resources.device.schemas import Component, Device +from ereuse_devicehub.resources.device.schemas import Component, Device, Computer from ereuse_devicehub.resources.enums import AppearanceRange, Bios, FunctionalityRange, \ PriceSoftware, RATE_POSITIVE, RatingSoftware, SnapshotExpectedEvents, SnapshotSoftware, \ TestHardDriveLength @@ -29,6 +29,7 @@ class Event(Thing): description = String(default='', description=m.Event.description.comment) author = NestedOn(User, dump_only=True, exclude=('token',)) closed = Boolean(missing=True, description=m.Event.closed.comment) + parent = NestedOn(Computer, dump_only=True, description=m.Event.parent_id.comment) class EventWithOneDevice(Event): diff --git a/tests/files/4-first-device-but-removing-processor.snapshot-and-adding-graphic-card.yaml b/tests/files/4-first-device-but-removing-processor.snapshot-and-adding-graphic-card.yaml index 49127af9..2a648269 100644 --- a/tests/files/4-first-device-but-removing-processor.snapshot-and-adding-graphic-card.yaml +++ b/tests/files/4-first-device-but-removing-processor.snapshot-and-adding-graphic-card.yaml @@ -9,6 +9,7 @@ components: serialNumber: p1c4s type: NetworkAdapter speed: 1000 + wireless: False - manufacturer: p1c3m serialNumber: p1c3s type: GraphicCard diff --git a/tests/files/real-custom.snapshot.11.yaml b/tests/files/real-custom.snapshot.11.yaml new file mode 100644 index 00000000..b9d9235e --- /dev/null +++ b/tests/files/real-custom.snapshot.11.yaml @@ -0,0 +1,128 @@ +{ + "version": "11.0a3", + "expectedEvents": [ + "Benchmark", + "TestDataStorage", + "StressTest" + ], + "uuid": "16467238-64bb-48e0-9058-0cba687d7db0", + "components": [ + { + "events": [], + "type": "NetworkAdapter", + "speed": 1000, + "wireless": false, + "manufacturer": "Marvell Technology Group Ltd.", + "serialNumber": "e0:cb:4e:0b:e4:11", + "model": "88E8056 PCI-E Gigabit Ethernet Controller" + }, + { + "events": [ + { + "rate": 4.8652, + "elapsed": 5, + "type": "BenchmarkProcessorSysbench" + }, + { + "rate": 56928.88, + "elapsed": 0, + "type": "BenchmarkProcessor" + } + ], + "type": "Processor", + "speed": 1.6, + "manufacturer": "Intel Corp.", + "serialNumber": null, + "cores": 4, + "threads": 8, + "model": "Intel Core i7 CPU 920 @ 2.67GHz", + "address": 64 + }, + { + "events": [], + "type": "SoundCard", + "manufacturer": "Advanced Micro Devices, Inc. AMD/ATI", + "serialNumber": null, + "model": "Barts HDMI Audio Radeon HD 6790/6850/6870 / 7720" + }, + { + "events": [], + "type": "SoundCard", + "manufacturer": "Intel Corporation", + "serialNumber": null, + "model": "82801JI HD Audio Controller" + }, + { + "events": [], + "type": "GraphicCard", + "memory": 256.0, + "manufacturer": "Advanced Micro Devices, Inc. AMD/ATI", + "serialNumber": null, + "model": "Barts XT Radeon HD 6870" + }, + { + "events": [ + { + "elapsed": 2, + "type": "BenchmarkDataStorage", + "writeSpeed": 151.0, + "readSpeed": 7270.4 + }, + { + "remainingLifetimePercentage": 98, + "assessment": true, + "reallocatedSectorCount": 0, + "elapsed": 54, + "type": "TestDataStorage", + "status": "Self-test routine in progress", + "powerCycleCount": 648, + "length": "Short", + "error": false, + "lifetime": 202 + } + ], + "type": "SolidStateDrive", + "interface": "ATA", + "manufacturer": null, + "serialNumber": "1609F017A70F", + "model": "CT240BX200SSD1", + "size": 228936 + }, + { + "events": [], + "type": "Motherboard", + "slots": 6, + "pcmcia": 0, + "manufacturer": "ASUSTeK Computer INC.", + "serialNumber": "102743030000221", + "serial": 1, + "firewire": 0, + "model": "P6T DELUXE V2", + "usb": 9 + } + ], + "elapsed": 7339, + "device": { + "events": [ + { + "rate": 16.5946, + "elapsed": 17, + "type": "BenchmarkRamSysbench" + }, + { + "error": false, + "elapsed": 60, + "type": "StressTest" + } + ], + "type": "Desktop", + "manufacturer": null, + "serialNumber": null, + "chassis": "Tower", + "model": null + }, + "type": "Snapshot", + "software": "Workbench", + "date": "2018-07-19T15:48:40.635776", + "closed": false +} \ No newline at end of file diff --git a/tests/files/real-eee-1001pxd.snapshot.11.yaml b/tests/files/real-eee-1001pxd.snapshot.11.yaml index cb55ab02..b924ac06 100644 --- a/tests/files/real-eee-1001pxd.snapshot.11.yaml +++ b/tests/files/real-eee-1001pxd.snapshot.11.yaml @@ -5,6 +5,7 @@ "model": "AR9285 Wireless Network Adapter", "serialNumber": "74:2f:68:8b:fd:c8", "manufacturer": "Qualcomm Atheros", + "wireless": true, "events": [] }, { @@ -13,11 +14,13 @@ "serialNumber": "14:da:e9:42:f6:7c", "manufacturer": "Qualcomm Atheros", "speed": 100, + "wireless": false, "events": [] }, { "type": "Processor", "cores": 1, + "threads": 1, "address": 64, "model": "Intel Atom CPU N455 @ 1.66GHz", "serialNumber": null, diff --git a/tests/files/real-hp-quad-core.snapshot.11.yaml b/tests/files/real-hp-quad-core.snapshot.11.yaml new file mode 100644 index 00000000..5cd33be3 --- /dev/null +++ b/tests/files/real-hp-quad-core.snapshot.11.yaml @@ -0,0 +1,116 @@ +{ + "elapsed": 4, + "type": "Snapshot", + "uuid": "0c822fb7-6e51-4781-86cf-994bd306212e", + "software": "Workbench", + "closed": false, + "date": "2018-07-05T11:57:17.284891", + "components": [ + { + "type": "NetworkAdapter", + "model": "82567LM-3 Gigabit Network Connection", + "speed": 1000, + "serialNumber": "00:23:24:0d:86:28", + "manufacturer": "Intel Corporation", + "wireless": false, + "events": [] + }, + { + "type": "NetworkAdapter", + "model": "82541PI Gigabit Ethernet Controller", + "speed": 1000, + "serialNumber": "00:0e:0c:b6:f2:91", + "manufacturer": "Intel Corporation", + "wireless": false, + "events": [] + }, + { + "cores": 4, + "type": "Processor", + "model": "Intel Core2 Quad CPU Q8400 @ 2.66GHz", + "speed": 1.9980000000000002, + "serialNumber": null, + "manufacturer": "Intel Corp.", + "events": [], + "address": 64 + }, + { + "type": "GraphicCard", + "model": "4 Series Chipset Integrated Graphics Controller", + "serialNumber": null, + "manufacturer": "Intel Corporation", + "events": [], + "memory": 256.0 + }, + { + "type": "SoundCard", + "model": "82801JD/DO HD Audio Controller", + "serialNumber": null, + "manufacturer": "Intel Corporation", + "events": [] + }, + { + "size": 2048, + "interface": "DDR3", + "type": "RamModule", + "model": "16JTF25664AZ-1G4F", + "speed": 1333.0, + "serialNumber": "F8482E29", + "format": "DIMM", + "manufacturer": "JEDEC ID:80 2C", + "events": [] + }, + { + "size": 2048, + "interface": "DDR3", + "type": "RamModule", + "model": "16JTF25664AZ-1G4F", + "speed": 1333.0, + "serialNumber": "62072F30", + "format": "DIMM", + "manufacturer": "JEDEC ID:80 2C", + "events": [] + }, + { + "size": 238475, + "interface": "ATA", + "type": "HardDrive", + "model": "ST3250318AS", + "serialNumber": "9VY6HBKE", + "manufacturer": "Seagate", + "events": [ + { + "elapsed": 0, + "type": "TestDataStorage", + "status": "Unspecified Error. Self-test not started.", + "error": true, + "length": "Short" + } + ] + }, + { + "slots": 0, + "pcmcia": 0, + "type": "Motherboard", + "model": "3646h", + "serialNumber": "CZC03217S7", + "firewire": 0, + "manufacturer": "Hewlett-Packard", + "events": [], + "serial": 0, + "usb": 8 + } + ], + "version": "11.0a3", + "device": { + "type": "Desktop", + "model": "HP Compaq 8000 Elite SFF", + "chassis": "Tower", + "serialNumber": "CZC03217S7", + "manufacturer": "Hewlett-Packard", + "events": [] + }, + "expectedEvents": [ + "SmartTest" + ] +} \ No newline at end of file diff --git a/tests/files/real-hp.snapshot.11.yaml b/tests/files/real-hp.snapshot.11.yaml index fa50f2f9..c4eadc08 100644 --- a/tests/files/real-hp.snapshot.11.yaml +++ b/tests/files/real-hp.snapshot.11.yaml @@ -8,6 +8,7 @@ "type": "NetworkAdapter", "manufacturer": "Intel Corporation", "speed": 1000, + "wireless": false, "model": "82578DM Gigabit Network Connection" }, { diff --git a/tests/files/real-toshiba.snapshot.11.yaml b/tests/files/real-toshiba.snapshot.11.yaml index 7a6268bd..bb899521 100644 --- a/tests/files/real-toshiba.snapshot.11.yaml +++ b/tests/files/real-toshiba.snapshot.11.yaml @@ -39,6 +39,7 @@ "manufacturer": "Qualcomm Atheros", "events": [], "type": "NetworkAdapter", + "wireless": true, "model": "AR9285 Wireless Network Adapter" }, { @@ -47,6 +48,7 @@ "events": [], "speed": 100, "type": "NetworkAdapter", + "wireless": false, "model": "RTL810xE PCI Express Fast Ethernet controller" }, { diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 0d6492a0..b72ba52b 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -4,7 +4,6 @@ from typing import List, Tuple from uuid import uuid4 import pytest - from ereuse_devicehub.client import UserClient from ereuse_devicehub.db import db from ereuse_devicehub.devicehub import Devicehub @@ -253,6 +252,34 @@ def test_snapshot_tag_inner_tag_mismatch_between_tags_and_hid(user: UserClient, user.post(pc2, res=Snapshot, status=MismatchBetweenTagsAndHid) +@pytest.mark.xfail(reason='There is no attribute checking for tag-matching devices') +def test_snapshot_different_properties_same_tags(user: UserClient, tag_id: str): + """ + Tests a snapshot performed to device 1 with tag A and then to + device 2 with tag B. Both don't have HID but are different type. + Devicehub must fail the Snapshot. + """ + # 1. Upload PC1 without hid but with tag + pc1 = file('basic.snapshot') + pc1['device']['tags'] = [{'type': 'Tag', 'id': tag_id}] + del pc1['device']['serialNumber'] + user.post(pc1, res=Snapshot) + # 2. Upload PC2 without hid, a different characteristic than PC1, but with same tag + pc2 = file('basic.snapshot') + pc2['uuid'] = uuid4() + pc2['device']['tags'] = pc1['device']['tags'] + del pc2['device'][ + 'model'] # pc2 model is unknown but pc1 model is set = different characteristic + user.post(pc2, res=Snapshot, status=422) + + +@pytest.mark.xfail(reason='duplicate Snapshot is a human error and needs a nice error message.') +def test_snapshot_upload_twice_uuid_error(user: UserClient): + pc1 = file('basic.snapshot') + user.post(pc1, res=Snapshot) + user.post(pc1, res=Snapshot, status=422) + + def test_erase(user: UserClient): """Tests a Snapshot with EraseSectors.""" s = file('erase-sectors.snapshot') diff --git a/tests/test_workbench.py b/tests/test_workbench.py index c1382231..ef4f46f7 100644 --- a/tests/test_workbench.py +++ b/tests/test_workbench.py @@ -1,11 +1,12 @@ """ Tests that emulates the behaviour of a WorkbenchServer. """ + import pytest from ereuse_devicehub.client import UserClient +from ereuse_devicehub.resources.device.exceptions import NeedsId from ereuse_devicehub.resources.device.models import Device -from ereuse_devicehub.resources.event.models import EraseSectors, Install, Snapshot, \ - StressTest +from ereuse_devicehub.resources.event import models as em from ereuse_devicehub.resources.tag.model import Tag from tests.conftest import file @@ -27,7 +28,7 @@ def test_workbench_server_condensed(user: UserClient): s['components'][5]['events'] = [file('workbench-server-3.erase')] # Create tags user.post(res=Tag, query=[('ids', t['id']) for t in s['device']['tags']], data={}) - snapshot, _ = user.post(res=Snapshot, data=s) + snapshot, _ = user.post(res=em.Snapshot, data=s) events = snapshot['events'] assert {(event['type'], event['device']) for event in events} == { # todo missing Rate event aggregating the rates @@ -55,33 +56,33 @@ def test_workbench_server_phases(user: UserClient): """ # 1. Snapshot with sync / rate / benchmarks / test data storage s = file('workbench-server-1.snapshot') - snapshot, _ = user.post(res=Snapshot, data=s) + snapshot, _ = user.post(res=em.Snapshot, data=s) assert not snapshot['closed'], 'Snapshot must be waiting for the new events' # 2. stress test st = file('workbench-server-2.stress-test') st['snapshot'] = snapshot['id'] - stress_test, _ = user.post(res=StressTest, data=st) + stress_test, _ = user.post(res=em.StressTest, data=st) # 3. erase ssd_id, hdd_id = snapshot['components'][4]['id'], snapshot['components'][5]['id'] e = file('workbench-server-3.erase') e['snapshot'], e['device'] = snapshot['id'], ssd_id - erase1, _ = user.post(res=EraseSectors, data=e) + erase1, _ = user.post(res=em.EraseSectors, data=e) # 3 bis. a second erase e = file('workbench-server-3.erase') e['snapshot'], e['device'] = snapshot['id'], hdd_id - erase2, _ = user.post(res=EraseSectors, data=e) + erase2, _ = user.post(res=em.EraseSectors, data=e) # 4. Install i = file('workbench-server-4.install') i['snapshot'], i['device'] = snapshot['id'], ssd_id - install, _ = user.post(res=Install, data=i) + install, _ = user.post(res=em.Install, data=i) # Check events have been appended in Snapshot and devices # and that Snapshot is closed - snapshot, _ = user.get(res=Snapshot, item=snapshot['id']) + snapshot, _ = user.get(res=em.Snapshot, item=snapshot['id']) events = snapshot['events'] assert len(events) == 9 assert events[0]['type'] == 'Rate' @@ -116,7 +117,7 @@ def test_workbench_server_phases(user: UserClient): def test_real_hp_11(user: UserClient): s = file('real-hp.snapshot.11') - snapshot, _ = user.post(res=Snapshot, data=s) + snapshot, _ = user.post(res=em.Snapshot, data=s) assert snapshot['device']['hid'] == 'hewlett-packard-czc0408yjg-hp_compaq_8100_elite_sff' assert snapshot['device']['chassis'] == 'Tower' assert set(e['type'] for e in snapshot['events']) == { @@ -132,4 +133,102 @@ def test_real_hp_11(user: UserClient): def test_real_toshiba_11(user: UserClient): s = file('real-toshiba.snapshot.11') - snapshot, _ = user.post(res=Snapshot, data=s) + snapshot, _ = user.post(res=em.Snapshot, data=s) + + +def test_real_eee_1001pxd(user: UserClient): + """ + Checks the values of the device, components, + events and their relationships of a real pc. + """ + s = file('real-eee-1001pxd.snapshot.11') + snapshot, _ = user.post(res=em.Snapshot, data=s) + pc, _ = user.get(res=Device, item=snapshot['device']['id']) + assert pc['type'] == 'Laptop' + assert pc['chassis'] == 'Netbook' + assert pc['model'] == '1001PXD' + assert pc['serialNumber'] == 'B8OAAS048286' + assert pc['manufacturer'] == 'ASUSTeK Computer INC.' + assert pc['hid'] == 'asustek_computer_inc-b8oaas048286-1001pxd' + assert pc['tags'] == [] + components = snapshot['components'] + wifi = components[0] + assert wifi['hid'] == 'qualcomm_atheros-74_2f_68_8b_fd_c8-ar9285_wireless_network_adapter' + assert wifi['serialNumber'] == '74:2f:68:8b:fd:c8' + assert wifi['wireless'] + eth = components[1] + assert eth['hid'] == 'qualcomm_atheros-14_da_e9_42_f6_7c-ar8152_v2_0_fast_ethernet' + assert eth['speed'] == 100 + assert not eth['wireless'] + cpu = components[2] + assert cpu['address'] == 64 + assert cpu['cores'] == 1 + assert cpu['threads'] == 1 + assert cpu['speed'] == 1.667 + assert 'hid' not in cpu + assert cpu['model'] == 'Intel Atom CPU N455 @ 1.66GHz' + cpu, _ = user.get(res=Device, item=cpu['id']) + events = cpu['events'] + sysbench = next(e for e in events if e['type'] == em.BenchmarkProcessorSysbench.t) + assert sysbench['elapsed'] == 164 + assert sysbench['rate'] == 164 + assert sysbench['snapshot'] == snapshot['id'] + assert sysbench['device'] == cpu['id'] + assert sysbench['parent'] == pc['id'] + benchmark_cpu = next(e for e in events if e['type'] == em.BenchmarkProcessor.t) + assert benchmark_cpu['rate'] == 6666 + assert benchmark_cpu['elapsed'] == 0 + event_types = tuple(e['type'] for e in events) + assert em.BenchmarkRamSysbench.t in event_types + assert em.StressTest.t in event_types + assert em.Snapshot.t in event_types + assert len(events) == 5 + gpu = components[3] + assert gpu['model'] == 'Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller' + assert gpu['manufacturer'] == 'Intel Corporation' + assert gpu['memory'] == 256 + gpu, _ = user.get(res=Device, item=gpu['id']) + event_types = tuple(e['type'] for e in gpu['events']) + assert em.BenchmarkRamSysbench.t in event_types + assert em.StressTest.t in event_types + assert em.Snapshot.t in event_types + assert len(event_types) == 3 + sound = components[4] + assert sound['model'] == 'NM10/ICH7 Family High Definition Audio Controller' + sound = components[5] + assert sound['model'] == 'USB 2.0 UVC VGA WebCam' + ram = components[6] + assert ram['interface'] == 'DDR2' + assert ram['speed'] == 667 + hdd = components[7] + assert hdd['type'] == 'HardDrive' + assert hdd['hid'] == 'hitachi-e2024242cv86hj-hts54322' + assert hdd['interface'] == 'ATA' + assert hdd['size'] == 238475 + hdd, _ = user.get(res=Device, item=hdd['id']) + event_types = tuple(e['type'] for e in hdd['events']) + assert em.BenchmarkRamSysbench.t in event_types + assert em.StressTest.t in event_types + assert em.BenchmarkDataStorage.t in event_types + assert em.TestDataStorage.t in event_types + assert em.EraseBasic.t in event_types + assert em.Snapshot.t in event_types + assert len(event_types) == 6 + erase = next(e for e in hdd['events'] if e['type'] == em.EraseBasic.t) + assert erase['endTime'] + assert erase['startTime'] + assert erase['zeros'] is False + assert erase['error'] is False + mother = components[8] + assert mother['hid'] == 'asustek_computer_inc-eee0123456789-1001pxd' + + +def test_real_custom(user: UserClient): + s = file('real-custom.snapshot.11') + snapshot, _ = user.post(res=em.Snapshot, data=s, status=NeedsId) + # todo insert with tag + + +def test_real_hp_quad_core(user: UserClient): + s = file('real-hp-quad-core.snapshot.11') + snapshot, _ = user.post(res=em.Snapshot, data=s)