Skip to content

Commit f2950e1

Browse files
authored
Merge pull request #216 from DMTF/additional-usecase-types
Added new usecases, test profiles, double reporting, test fix
2 parents 396543b + a5c9ea6 commit f2950e1

File tree

11 files changed

+206
-8
lines changed

11 files changed

+206
-8
lines changed

redfish_interop_validator/interop.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,15 @@ def checkInteropURI(r_obj, profile_entry):
767767
my_id, my_uri = r_obj.jsondata.get('Id'), r_obj.uri
768768
return compareRedfishURI(profile_entry, my_uri)
769769

770+
# Expected Type, Key
771+
entry_type_table = {
772+
'ChassisType': ("Chassis", "ChassisType"),
773+
'DriveProtocol': ("Drive", "Protocol"),
774+
'MemoryType': ("Memory", "MemoryType"),
775+
'PortProtocol': ("Port", "PortProtocol"),
776+
'ProcessorType': ("Processor", "ProcessorType"),
777+
}
778+
770779

771780
def validateInteropResource(propResourceObj, interop_profile, rf_payload):
772781
"""
@@ -783,11 +792,12 @@ def validateInteropResource(propResourceObj, interop_profile, rf_payload):
783792
for use_case in interop_profile['UseCases']:
784793
entry_title = use_case.get("UseCaseTitle", "NoName").replace(' ', '_')
785794
entry_type = use_case.get("UseCaseType", "Normal")
795+
my_parent = propResourceObj.parent
786796
my_logger.debug('UseCase {} {}'.format(entry_title, entry_type))
787797

788798
# Check if we have a valid UseCase
789-
if 'URIs' not in use_case and 'UseCaseKeyProperty' not in use_case and entry_type != 'AbsentResource':
790-
my_logger.error('UseCase does not have URIs or UseCaseKeyProperty...')
799+
if ('URIs' not in use_case) and ('UseCaseKeyProperty' not in use_case) and (entry_type not in ['AbsentResource'] + list(entry_type_table.keys())):
800+
my_logger.error('UseCase does not have URIs or valid UseCase...')
791801

792802
if entry_type == 'AbsentResource':
793803
my_status = rf_payload.get('Status')
@@ -797,6 +807,28 @@ def validateInteropResource(propResourceObj, interop_profile, rf_payload):
797807
use_case_applies = False
798808
if 'URIs' in use_case:
799809
use_case_applies = use_case_applies and checkInteropURI(propResourceObj, use_case['URIs'])
810+
811+
elif entry_type in entry_type_table:
812+
target_type_found = False
813+
target_type, entry_key = entry_type_table[entry_type]
814+
entry_comparison, entry_values = use_case['UseCaseComparison'], use_case['UseCaseKeyValues']
815+
816+
# Iterate until we find our target type, if not found then use case cannot apply
817+
while my_parent is not None and not target_type_found:
818+
parent_type = getType(my_parent.jsondata.get('@odata.type', 'NoType'))
819+
target_type_found = parent_type == target_type
820+
if not target_type_found:
821+
my_parent = my_parent.parent
822+
823+
if target_type_found:
824+
target_payload = my_parent.jsondata
825+
target_value = target_payload.get(entry_key)
826+
827+
_, use_case_applies = checkComparison(target_payload.get(entry_key, REDFISH_ABSENT), entry_comparison, entry_values)
828+
else:
829+
my_logger.verbose1('Type {} was not found in parent typechain'.format(target_type))
830+
use_case_applies = False
831+
800832

801833
elif 'UseCaseKeyProperty' in use_case:
802834
entry_key, entry_comparison, entry_values = use_case['UseCaseKeyProperty'], use_case['UseCaseComparison'], use_case['UseCaseKeyValues']

redfish_interop_validator/validateResource.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def validateSingleURI(URI, profile, uriName='', expectedType=None, expectedSchem
168168
profile_resources = profile_resources.get(SchemaType)
169169
try:
170170
propMessages, propCounts = interop.validateInteropResource(resource_obj, profile_resources, jsondata)
171-
messages = messages.extend(propMessages)
171+
messages.extend(propMessages)
172172
counts.update(propCounts)
173173
my_logger.info('{} of {} tests passed.'.format(counts['pass'] + counts['warn'], counts['totaltests']))
174174
except Exception:
@@ -312,8 +312,7 @@ def validateURITree(URI, profile, uriName, expectedType=None, expectedSchema=Non
312312
allLinks.add(link.rstrip('/'))
313313

314314
results.update(linkResults)
315-
counts.update(linkCounts)
316-
315+
317316
if not linkSuccess:
318317
continue
319318

test-profiles/ChassisType_1.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "ChassisType5",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Ensures at least one chassis is an 'Enclosure'. This test should pass.",
6+
"Resources": {
7+
"Thermal": {
8+
"PropertyRequirements": {
9+
"Temperatures": {
10+
"PropertyRequirements": {
11+
"PhysicalContext": {
12+
"Comparison": "AllOf",
13+
"Values": [ "Intake", "CPU" ]
14+
}
15+
}
16+
}
17+
}
18+
}
19+
}
20+
}

test-profiles/ChassisType_2.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "ChassisType1",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Ensures at least one chassis is an 'Enclosure'. This test should pass (MultiBladeEncl is an Enclosure).",
6+
"Resources": {
7+
"Chassis": {
8+
"PropertyRequirements": {
9+
"ChassisType": {
10+
"Comparison": "AnyOf",
11+
"Values": [
12+
"Enclosure"
13+
]
14+
}
15+
}
16+
}
17+
}
18+
}

test-profiles/ChassisType_3.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "ChassisType2",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Ensures at least one chassis is an 'Enclosure' or a 'Rack'. This test should pass (MultiBladeEncl is an Enclosure).",
6+
"Resources": {
7+
"Chassis": {
8+
"PropertyRequirements": {
9+
"ChassisType": {
10+
"Comparison": "AnyOf",
11+
"Values": [
12+
"Enclosure",
13+
"Rack"
14+
]
15+
}
16+
}
17+
}
18+
}
19+
}

test-profiles/ChassisType_4.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "ChassisType3",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Ensures at least one chassis is an 'Enclosure' and a 'Rack'. This test should fail (there are no 'Rack' chassis).",
6+
"Resources": {
7+
"Chassis": {
8+
"PropertyRequirements": {
9+
"ChassisType": {
10+
"Comparison": "AllOf",
11+
"Values": [
12+
"Enclosure",
13+
"Rack"
14+
]
15+
}
16+
}
17+
}
18+
}
19+
}

test-profiles/ChassisType_5.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "ChassisType4",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Ensures at least one chassis is an 'Enclosure' and a 'Blade'. This test should pass.",
6+
"Resources": {
7+
"Chassis": {
8+
"PropertyRequirements": {
9+
"ChassisType": {
10+
"Comparison": "AllOf",
11+
"Values": [
12+
"Enclosure",
13+
"Blade"
14+
]
15+
}
16+
}
17+
}
18+
}
19+
}

test-profiles/ChassisType_6.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "ChassisType5",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Ensures at least one chassis is an 'Enclosure'. This test should pass.",
6+
"Resources": {
7+
"Chassis": {
8+
"PropertyRequirements": {
9+
"ChassisType": {
10+
"Comparison": "AllOf",
11+
"Values": [
12+
"Enclosure"
13+
]
14+
}
15+
}
16+
}
17+
}
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "UseCaseType_ChassisType",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Test for UseCaseType 'ChassisType'. Should pass one test for every Sensor in public-rackmount1.",
6+
"Resources": {
7+
"Sensor": {
8+
"UseCases": [
9+
{
10+
"UseCaseTitle": "Chassis Sensor",
11+
"UseCaseType": "ChassisType",
12+
"UseCaseComparison": "Equal",
13+
"UseCaseKeyValues": [
14+
"RackMount"
15+
],
16+
"PropertyRequirements": {
17+
"PhysicalContext": {}
18+
}
19+
}
20+
]
21+
}
22+
}
23+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0",
3+
"ProfileName": "UseCaseType_PortProtocol",
4+
"ProfileVersion": "1.0.0",
5+
"Purpose": "Test for UseCaseType 'ProcessorType'. Should pass one test for each SubProcessor in public-tower.",
6+
"Resources": {
7+
"Processor": {
8+
"UseCases": [
9+
{
10+
"UseCaseTitle": "Sub Processor",
11+
"UseCaseType": "ProcessorType",
12+
"UseCaseComparison": "Equal",
13+
"UseCaseKeyValues": [
14+
"CPU"
15+
],
16+
"PropertyRequirements": {
17+
"ProcessorType": {
18+
"ReadRequirement": "Mandatory",
19+
"Comparison": "AnyOf",
20+
"Values": [
21+
"Thread",
22+
"Core"
23+
]
24+
}
25+
}
26+
}
27+
]
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)