Adam Litke has uploaded a new change for review.
Change subject: schema: Strengthen schema verification ......................................................................
schema: Strengthen schema verification
Add additional checking to process-schema.py to detect the following errors: - Symbol comment documents a field which is not defined in the symbol - Symbol references an undefined type
Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Signed-off-by: Adam Litke agl@us.ibm.com --- M vdsm_api/process-schema.py M vdsm_api/vdsmapi-schema.json 2 files changed, 46 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/97/11397/1
diff --git a/vdsm_api/process-schema.py b/vdsm_api/process-schema.py index 970637b..686e624 100755 --- a/vdsm_api/process-schema.py +++ b/vdsm_api/process-schema.py @@ -140,6 +140,9 @@ m = re.search('^@(.*?):\s*(.*)', line) if m: name, desc = (m.group(1), m.group(2)) + if name not in strip_stars(symbol['data']): + raise ValueError("'%s' comment mentions '%s' which is " \ + "not defined" % (symbol['name'], name)) symbol[mode][name] = desc # Track the name in case there is are multiple lines to append last_arg = name @@ -175,23 +178,24 @@ return "".join(html_escape_table.get(c, c) for c in text)
+def strip_stars(items): + """ + A symbol prepended with '*' means the symbol is optional. Strip this + when looking up the symbol documentation. + """ + ret = [] + for i in items: + if i.startswith('*'): + ret.append(i[1:]) + else: + ret.append(i) + return ret + + def write_symbol(f, s): """ Write an HTML reprentation of a symbol definition and documentation. """ - def strip_stars(items): - """ - A symbol prepended with '*' means the symbol is optional. Strip this - when looking up the symbol documentation. - """ - ret = [] - for i in items: - if i.startswith('*'): - ret.append(i[1:]) - else: - ret.append(i) - return ret - def filter_types(items): """ When creating the type crosslink, if an entity is a list container we @@ -327,6 +331,29 @@ f.write(footer)
+def verify_symbols(symbols): + def filter_name(name): + if isinstance(name, list): + name = name[0] + if name.startswith('*'): + name = name[1:] + return name + + names = ['str', 'bool', 'int', 'uint', 'float'] + names.extend([s['type'] for s in symbols if 'type' in s]) + names.extend([s['enum'] for s in symbols if 'enum' in s]) + names.extend([s['alias'] for s in symbols if 'alias' in s]) + names.extend([s['map'] for s in symbols if 'map' in s]) + + # Make sure all type references are defined + for s in symbols: + if 'type' in s or 'command' in s: + for k, v in s.get('data', {}).items(): + if filter_name(v) not in names: + raise ValueError("'%s': undefined type reference '%s'" % ( + s['type'], v)) + + def main(): schema = sys.argv[1] output = sys.argv[2] @@ -335,6 +362,8 @@ # First read in the progmatic schema definition with open(schema) as f: symbols = vdsmapi.parse_schema(f) + verify_symbols(symbols) + # Now merge in the information from the comments with open(schema) as f: symbols = read_schema_doc(f, symbols) diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 1baffe2..47777b8 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -368,7 +368,7 @@ # Since: 4.10.0 ## {'enum': 'TaskState', - 'data': ['unknown', 'running', 'finished', 'aborting', 'cleaning']} + 'data': ['unknown', 'init', 'running', 'finished', 'aborting', 'cleaning']}
## # @TaskResult: @@ -1550,13 +1550,13 @@ 'storageDomains': 'StorageDomainVitalsMap', 'elapsedTime': 'uint', 'memUsed': 'uint', 'anonHugePages': 'uint', 'cpuLoad': 'float', - 'diskStats': 'PathStatsMap', 'thpState': 'THPStates'}, + 'diskStats': 'PathStatsMap', 'thpState': 'THPStates', 'memAvailable': 'int', 'memShared': 'int', 'memCommitted': 'int', 'swapTotal': 'int', 'swapFree': 'int','vmCount': 'int', 'vmActive': 'int', 'vmMigrating': 'int', 'dateTime': 'str', 'ksmState': 'bool', 'ksmPages': 'int', 'ksmCpu': 'float', 'netConfigDirty': 'bool', 'generationID': 'UUID', - 'momStatus': 'MOMStatus'} + 'momStatus': 'MOMStatus'}}
## # @Host.getStats: @@ -2363,7 +2363,7 @@ # # Since: 4.10.0 ## -{'enum': 'VmChannelDeviceType', 'data': ['unix', 'spicevmc']} +{'enum': 'VmChannelDeviceType', 'data': ['unix', 'spicevmc', 'virtio-serial']}
## # @VmChannelDevice: @@ -6278,8 +6278,6 @@ # @storagedomainID: The Storage Domain associated with the Volume # # @imageID: The Image associated with the Volume -# -# @legality: The new Volume legality # # Since: 4.10.0 ##
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/57/ (1/3)
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/947/ (2/3)
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/912/ (3/3)
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 1: Fails; I would prefer that you didn't submit this
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/912/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/947/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/57/ : FAILURE
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/58/ (2/3)
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/913/ (3/3)
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/948/ (1/3)
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2: Fails
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/913/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/948/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/58/ : FAILURE
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: oVirt Jenkins CI Server
Adam Litke has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2: Verified
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com
Saggi Mizrahi has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2: Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com
Dan Kenigsberg has submitted this change and it was merged.
Change subject: schema: Strengthen schema verification ......................................................................
schema: Strengthen schema verification
Add additional checking to process-schema.py to detect the following errors: - Symbol comment documents a field which is not defined in the symbol - Symbol references an undefined type
Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Signed-off-by: Adam Litke agl@us.ibm.com --- M vdsm_api/process-schema.py M vdsm_api/vdsmapi-schema.json 2 files changed, 46 insertions(+), 19 deletions(-)
Approvals: Adam Litke: Verified Saggi Mizrahi: Looks good to me, approved Dan Kenigsberg:
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com
Saggi Mizrahi has posted comments on this change.
Change subject: schema: Strengthen schema verification ......................................................................
Patch Set 2: (1 inline comment)
.................................................... File vdsm_api/process-schema.py Line 177: """ Line 178: return "".join(html_escape_table.get(c, c) for c in text) Line 179: Line 180: Line 181: def strip_stars(items): If you do another iteration, please change to strip_optional_marker as the fact that it is an asterix is an implementation detail. Line 182: """ Line 183: A symbol prepended with '*' means the symbol is optional. Strip this Line 184: when looking up the symbol documentation. Line 185: """
-- To view, visit http://gerrit.ovirt.org/11397 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ia750e537fad9ad57d1163906b130033e896c36dd Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com
vdsm-patches@lists.fedorahosted.org