diff --git a/validation-script/README.md b/validation-script/README.md deleted file mode 100644 index 40b7bcb04..000000000 --- a/validation-script/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# ODE Regression Test Harness - -## Overview - -This folder contains the automated regression test harness application built for the ODE. The test harness sends a file to the ODE, listens for messages to be published to Kafka, then validates the output. - -## Usage - -``` -python test-harness.py -f -``` - -There are several _.ini_ configuration files provided in the `/config` folder for testing. For example to test the ODE's _bsmLogDuringEvent_ functionality, pass the configuration file as a runtime argument: - -``` -python test-harness.py -f config/bsmLogDuringEvent.ini -``` - -## Configuration - -Configuration is managed through .ini files passed as parameters during runtime. - -#### \_settings - -At a high level, the `_settings` section outlines the following properties: - -``` -KafkaTopic = topic.OdeBsmJson # Kafka topic to listen to for output messages -InputFilePath = ../data/bsmLogDuringEvent.gz # Source data file for input -OutputFilePath = bsmLogDuringEvent_results.log # Output file path for validation results -ExpectedMessages = 222 # Number of messages in the source data file -``` - -Then each field to be validated should be created. - -- `Path` - - Required: Yes - - Summary: Identifies the field location within the message - - Value: JSON path to the field, separated using periods -- `Type` - - Required: Yes - - Summary: Identifies the type of the field - - Value: One of `enum`, `decimal`, `string`, or `timestamp` - - enum - - Specifies that the field must be one of a certain set of values - - decimal - - Specifies that the field is a number - - string - - Specifies that the field is a string - - timestamp - - Values of this type will be validated by testing for parsability -- `EqualsValue` - - Required: Optional - - Summary: Sets the expected value of this field, will fail if the value does not match this - - Value: Expected value: `EqualsValue = us.dot.its.jpo.ode.model.OdeBsmPayload` -- `Values` - - Required: Optional - - Summary: Used with enum types to specify the list of possible values that this field must be - - Value: JSON array with values in quotes: `Values = ["OptionA", "OptionB", ]` -- `LowerLimit` - - Required: Optional - - Summary: Used with decimal types to specify the lowest acceptable value for this field - - Value: decimal number: `LowerLimit = 2` -- `UpperLimit` - - Required: Optional - - Summary: Used with decimal types to specify the highest acceptable value for this field - - Value: decimal number: `UpperLimit = 150.43` diff --git a/validation-script/config/bsmLogDuringEvent.ini b/validation-script/config/bsmLogDuringEvent.ini deleted file mode 100644 index fcb371a22..000000000 --- a/validation-script/config/bsmLogDuringEvent.ini +++ /dev/null @@ -1,133 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeBsmJson -InputFilePath = ../data/bsmLogDuringEvent.gz -OutputFilePath = bsmLogDuringEvent_results.log -ExpectedMessages = 222 - -[bsmSource] -Path = metadata.bsmSource -Type = enum -Values = ["RV", "EV", "unknown"] - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeBsmPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = bsmLogDuringEvent.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = NA - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = OBU - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = bsmLogDuringEvent - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/bsmTx.ini b/validation-script/config/bsmTx.ini deleted file mode 100644 index b12c53b57..000000000 --- a/validation-script/config/bsmTx.ini +++ /dev/null @@ -1,133 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeBsmJson -InputFilePath = ../data/bsmTx.gz -OutputFilePath = bsmTx_results.log -ExpectedMessages = 16 - -[bsmSource] -Path = metadata.bsmSource -Type = enum -Values = ["RV", "EV", "unknown"] - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeBsmPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = bsmTx.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = NA - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = OBU - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = bsmTx - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/dnMsg.ini b/validation-script/config/dnMsg.ini deleted file mode 100644 index 662f7c645..000000000 --- a/validation-script/config/dnMsg.ini +++ /dev/null @@ -1,128 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeDNMsgJson -InputFilePath = ../data/dnMsg.gz -OutputFilePath = dnMsg_results.log -ExpectedMessages = 1 - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeTimPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = dnMsg.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = NA - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = OBU - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = dnMsg - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/driverAlert.ini b/validation-script/config/driverAlert.ini deleted file mode 100644 index d9e31e32d..000000000 --- a/validation-script/config/driverAlert.ini +++ /dev/null @@ -1,128 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeDriverAlertJson -InputFilePath = ../data/driverAlert.gz -OutputFilePath = driverAlert_results.log -ExpectedMessages = 50 - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeDriverAlertPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = driverAlert.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = NA - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = OBU - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = driverAlert - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -#[securityResultCode] -#Path = metadata.securityResultCode -#Type = enum -#Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -#EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-bsmcheck.ini b/validation-script/config/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-bsmcheck.ini deleted file mode 100644 index 056b4e104..000000000 --- a/validation-script/config/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-bsmcheck.ini +++ /dev/null @@ -1,133 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeBsmJson -InputFilePath = ../data/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP.gz -OutputFilePath = rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-bsmcheck_results.log -ExpectedMessages = 187 - -[bsmSource] -Path = metadata.bsmSource -Type = enum -Values = ["RV", "EV", "unknown"] - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeBsmPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = RV - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = OBU - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = rxMsg - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-timcheck.ini b/validation-script/config/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-timcheck.ini deleted file mode 100644 index 44b619593..000000000 --- a/validation-script/config/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-timcheck.ini +++ /dev/null @@ -1,128 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeTimRxJson -InputFilePath = ../data/rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP.gz -OutputFilePath = rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP-timcheck_results.log -ExpectedMessages = 109 - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeTimPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = rxMsg_TIM_GeneratedBy_TMC_VIA_SNMP.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = SNMP - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = TMC_VIA_SNMP - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = rxMsg - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/rxMsg_TIM_and_BSM-bsmcheck.ini b/validation-script/config/rxMsg_TIM_and_BSM-bsmcheck.ini deleted file mode 100644 index b07ee5188..000000000 --- a/validation-script/config/rxMsg_TIM_and_BSM-bsmcheck.ini +++ /dev/null @@ -1,134 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeBsmJson -InputFilePath = ../data/rxMsg_BSM_and_TIM.gz -OutputFilePath = rxMsg_BSM_and_TIM-bsmcheck_results.log -ExpectedMessages = 243 - -[bsmSource] -Path = metadata.bsmSource -Type = enum -Values = ["RV", "EV", "unknown"] - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeBsmPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = rxMsg_BSM_and_TIM.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = RV - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = OBU - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = rxMsg - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -### EqualsValue commented out because 2 messages in this file have value: spduParsingCertificateNotFound -#EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/config/rxMsg_TIM_and_BSM-timcheck.ini b/validation-script/config/rxMsg_TIM_and_BSM-timcheck.ini deleted file mode 100644 index e0bd13f71..000000000 --- a/validation-script/config/rxMsg_TIM_and_BSM-timcheck.ini +++ /dev/null @@ -1,128 +0,0 @@ -[_settings] -KafkaTopic = topic.OdeTimRxJson -InputFilePath = ../data/rxMsg_BSM_and_TIM.gz -OutputFilePath = rxMsg_BSM_and_TIM-timcheck_results.log -ExpectedMessages = 150 - -[payloadType] -Path = metadata.payloadType -Type = string -EqualsValue = us.dot.its.jpo.ode.model.OdeTimPayload - -[logFileName] -Path = metadata.logFileName -Type = string -EqualsValue = rxMsg_BSM_and_TIM.gz - -[odeReceivedAt] -Path = metadata.odeReceivedAt -Type = timestamp - -[receivedMessageDetails] -Path = metadata.receivedMessageDetails -Type = string - -[locationData] -Path = metadata.receivedMessageDetails.locationData -Type = string - -[latitude] -Path = metadata.receivedMessageDetails.locationData.latitude -Type = decimal -LowerLimit = -90.0 -UpperLimit = 90.0 - -[longitude] -Path = metadata.receivedMessageDetails.locationData.longitude -Type = decimal -LowerLimit = -180.0 -UpperLimit = 180.0 - -[elevation] -Path = metadata.receivedMessageDetails.locationData.elevation -Type = decimal -LowerLimit = -409.6 -UpperLimit = 6143.9 - -[speed] -Path = metadata.receivedMessageDetails.locationData.speed -Type = decimal -LowerLimit = 0 -UpperLimit = 163.82 - -[heading] -Path = metadata.receivedMessageDetails.locationData.heading -Type = decimal -LowerLimit = 0 -UpperLimit = 359.9875 - -[rxSource] -Path = metadata.receivedMessageDetails.rxSource -Type = enum -Values = ["RSU", "SAT", "RV", "SNMP", "NA", "unknown"] -EqualsValue = SNMP - -[recordGeneratedAt] -Path = metadata.recordGeneratedAt -Type = timestamp - -[recordGeneratedBy] -Path = metadata.recordGeneratedBy -Type = enum -Values = ["TMC", "OBU", "RSU", "TMC_VIA_SAT", "TMC_VIA_SNMP"] -EqualsValue = TMC_VIA_SNMP - -[recordType] -Path = metadata.recordType -Type = enum -Values = ["bsmLogDuringEvent", "rxMsg", "dnMsg", "bsmTx", "driverAlert", "unsupported"] -EqualsValue = rxMsg - -[sanitized] -Path = metadata.sanitized -Type = enum -Values = ["True", "False"] - -[schemaVersion] -Path = metadata.schemaVersion -Type = decimal -EqualsValue = 6 - -[securityResultCode] -Path = metadata.securityResultCode -Type = enum -Values = ["success", "unknown", "inconsistentInputParameters", "spduParsingInvalidInput", "spduParsingUnsupportedCriticalInformationField", "spduParsingCertificateNotFound", "spduParsingGenerationTimeNotAvailable", "spduParsingGenerationLocationNotAvailable", "spduCertificateChainNotEnoughInformationToConstructChain", "spduCertificateChainChainEndedAtUntrustedRoot", "spduCertificateChainChainWasTooLongForImplementation", "spduCertificateChainCertificateRevoked", "spduCertificateChainOverdueCRL", "spduCertificateChainInconsistentExpiryTimes", "spduCertificateChainInconsistentStartTimes", "spduCertificateChainInconsistentChainPermissions", "spduCryptoVerificationFailure", "spduConsistencyFutureCertificateAtGenerationTime", "spduConsistencyExpiredCertificateAtGenerationTime", "spduConsistencyExpiryDateTooEarly", "spduConsistencyExpiryDateTooLate", "spduConsistencyGenerationLocationOutsideValidityRegion", "spduConsistencyNoGenerationLocation", "spduConsistencyUnauthorizedPSID", "spduInternalConsistencyExpiryTimeBeforeGenerationTime", "spduInternalConsistencyextDataHashDoesntMatch", "spduInternalConsistencynoExtDataHashProvided", "spduInternalConsistencynoExtDataHashPresent", "spduLocalConsistencyPSIDsDontMatch", "spduLocalConsistencyChainWasTooLongForSDEE", "spduRelevanceGenerationTimeTooFarInPast", "spduRelevanceGenerationTimeTooFarInFuture", "spduRelevanceExpiryTimeInPast", "spduRelevanceGenerationLocationTooDistant", "spduRelevanceReplayedSpdu", "spduCertificateExpired"] -EqualsValue = success - -[serialId] -Path = metadata.serialId -Type = string - -[streamId] -Path = metadata.serialId -Type = string - -[bundleSize] -Path = metadata.serialId.bundleSize -Type = decimal -UpperLimit = 2147483648 -LowerLimit = 1 - -[bundleId] -Path = metadata.serialId.bundleId -Type = decimal -UpperLimit = 9223372036854775807 -LowerLimit = 0 - -[recordId] -Path = metadata.serialId.recordId -Type = decimal -UpperLimit = 2147483647 -LowerLimit = 0 - -[serialNumber] -Path = metadata.serialId.serialNumber -Type = serial -#Increment = 1 -UpperLimit = 9223372036854775807 -LowerLimit = 0 diff --git a/validation-script/test-harness.py b/validation-script/test-harness.py deleted file mode 100644 index 94fb9124b..000000000 --- a/validation-script/test-harness.py +++ /dev/null @@ -1,101 +0,0 @@ -import json -import logging -import os -import queue -import requests -import threading -import time -from argparse import ArgumentParser -from kafka import KafkaConsumer -from pathlib import Path -from validator import TestCase - -KAFKA_CONSUMER_TIMEOUT = 10000 -KAFKA_PORT = '9092' -ODE_PORT = '8080' -ODE_REST_ENDPOINT = '/upload/bsmlog' - -DOCKER_HOST_IP=os.getenv('DOCKER_HOST_IP') -assert DOCKER_HOST_IP != None, "Failed to get DOCKER_HOST_IP from environment variable" - -def upload_file(filepath): - destination_url = 'http://' + DOCKER_HOST_IP + ':' + ODE_PORT + ODE_REST_ENDPOINT - with open(filepath, 'rb') as file: - return requests.post(destination_url, files={'name':'file', 'file':file}, timeout=2) - -def listen_to_kafka_topic(topic, msg_queue): - consumer=KafkaConsumer(topic, bootstrap_servers=DOCKER_HOST_IP+':'+KAFKA_PORT, consumer_timeout_ms=KAFKA_CONSUMER_TIMEOUT) - for msg in consumer: - msg_queue.put(msg.value) - -# main function using old functionality -def main(): - parser = ArgumentParser() - parser.add_argument("-f", "--file", dest="filepath", help="Path to ini configuration file used for testing.", metavar="FILEPATH", required=True) - args = parser.parse_args() - assert Path(args.filepath).is_file(), "File '%s' could not be found" % args.filepath - - # Parse test config and create test case - validator = TestCase(args.filepath) - - print("[START] Beginning test routine referencing configuration file '%s'." % args.filepath) - - # Create file logger for printing results - fileh = logging.FileHandler(validator.output_file_path, 'w') - logger = logging.getLogger('test-harness') - logger.setLevel(logging.INFO) - logger.addHandler(fileh) - - # Create a kafka consumer and wait for it to connect - print("[INFO] Creating Kafka consumer...") - msg_queue = queue.Queue() - kafkaListenerThread=threading.Thread(target=listen_to_kafka_topic,args=(validator.kafka_topic, msg_queue,)) - kafkaListenerThread.start() - time.sleep(3) - print("[INFO] Kafka consumer preparation complete.") - - # Upload the test file with known data to the ODE - print("[INFO] Uploading test file to ODE...") - try: - upload_response = upload_file(validator.input_file_path) - if upload_response.status_code == 200: - print("[INFO] Test file uploaded successfully.") - else: - print("[ERROR] Aborting test routine! Test file failed to upload, response code %d" % upload_response.status_code) - raise SystemExit - except requests.exceptions.ConnectTimeout as e: - print("[ERROR] Aborting test routine! Test file upload failed (unable to reach to ODE). Error: '%s'" % str(e)) - return - - # Wait for as many messages as possible to be collected and verify it matches expected count - print("[INFO] Waiting for all messages to be received...") - kafkaListenerThread.join() - msgs_received = msg_queue.qsize() - print("[INFO] Found %d messages in file (expected %d)." % (msgs_received, validator.expected_messages)) - if validator.expected_messages != msgs_received: - print("[FAILED] Expected %d messages but received %d." % (validator.expected_messages, msgs_received)) - return - - # After all messages were received, iterate and validate them - num_errors = 0 - num_validations = 0 - while not msg_queue.empty(): - current_msg = json.loads(msg_queue.get()) - logger.info("======") - logger.info("RECORD_ID: %s" % str(current_msg['metadata']['serialId']['recordId'])) - validation_results = validator.validate(current_msg, logger) - num_errors += validation_results.num_errors - num_validations += validation_results.num_validations - - if num_errors > 0: - print('[FAILED] ============================================================================') - print('[FAILED] Validation has failed! Detected %d errors out of %d total validation checks.' % (num_errors, num_validations)) - print('[FAILED] ============================================================================') - else: - print('[SUCCESS] ===========================================================================') - print('[SUCCESS] Validation has passed. Detected no errors out of %d total validation checks.' % (num_validations)) - print('[SUCCESS] ===========================================================================') - print("[END] File validation complete. Results logged to '%s'." % validator.output_file_path) - -if __name__ == '__main__': - main() diff --git a/validation-script/validator.py b/validation-script/validator.py deleted file mode 100644 index f3486dfa3..000000000 --- a/validation-script/validator.py +++ /dev/null @@ -1,117 +0,0 @@ -import configparser -import dateutil.parser -import json -import logging -from decimal import Decimal - -TYPE_DECIMAL = 'decimal' -TYPE_ENUM = 'enum' -TYPE_TIMESTAMP = 'timestamp' -TYPE_STRING = 'string' - -class ValidationResult: - def __init__(self, valid, error): - self.valid = valid - self.error = error - -class RecordValidationSummary: - def __init__(self, num_errors, num_validations): - self.num_errors = num_errors - self.num_validations = num_validations - -class Field: - def __init__(self, field): - # extract required settings - self.path = field.get('Path') - if self.path is None: - raise ValueError("Missing required configuration property 'Path' for field '%s'" % field) - self.type = field.get('Type') - if self.type is None: - raise ValueError("Missing required configuration property 'Type' for field '%s'" % field) - - # extract constraints - upper_limit = field.get('UpperLimit') - if upper_limit is not None: - self.upper_limit = Decimal(upper_limit) - lower_limit = field.get('LowerLimit') - if lower_limit is not None: - self.lower_limit = Decimal(lower_limit) - values = field.get('Values') - if values is not None: - self.values = json.loads(values) - increment = field.get('Increment') - if increment is not None: - self.increment = int(increment) - equals_value = field.get('EqualsValue') - if equals_value is not None: - self.equals_value = str(equals_value) - - def _get_field_value(self, data): - try: - path_keys = self.path.split(".") - value = data - for key in path_keys: - value = value.get(key) - return value - except AttributeError as e: - print("[ERROR] Could not find field with path '%s' in message: '%s'" % (self.path, data)) - raise SystemExit - - def validate(self, data): - field_value = self._get_field_value(data) - if field_value is None: - return ValidationResult(False, "Field '%s' missing" % self.path) - if field_value == "": - return ValidationResult(False, "Field '%s' empty" % self.path) - if hasattr(self, 'upper_limit') and Decimal(field_value) > self.upper_limit: - return ValidationResult(False, "Field '%s' value '%d' is greater than upper limit '%d'" % (self.path, Decimal(field_value), self.upper_limit)) - if hasattr(self, 'lower_limit') and Decimal(field_value) < self.lower_limit: - return ValidationResult(False, "Field '%s' value '%d' is less than lower limit '%d'" % (self.path, Decimal(field_value), self.lower_limit)) - if hasattr(self, 'values') and str(field_value) not in self.values: - return ValidationResult(False, "Field '%s' value '%s' not in list of known values: [%s]" % (self.path, str(field_value), ', '.join(map(str, self.values)))) - if hasattr(self, 'equals_value') and str(field_value) != str(self.equals_value): - return ValidationResult(False, "Field '%s' value '%s' did not equal expected value '%s'" % (self.path, field_value, self.equals_value)) - if hasattr(self, 'increment'): - if not hasattr(self, 'previous_value'): - self.previous_value = field_value - else: - if field_value != (self.previous_value + self.increment): - result = ValidationResult(False, "Field '%s' successor value '%d' did not match expected value '%d', increment '%d'" % (self.path, field_value, self.previous_value+self.increment, self.increment)) - self.previous_value = field_value - return result - if self.type == TYPE_TIMESTAMP: - try: - dateutil.parser.parse(field_value) - except Exception as e: - return ValidationResult(False, "Field '%s' value could not be parsed as a timestamp, error: %s" % (self.path, str(e))) - return ValidationResult(True, "") - -class TestCase: - def __init__(self, filepath): - config = configparser.ConfigParser() - config.read(filepath) - if not config.has_section('_settings'): - print("[ERROR] Configuration file missing required section '_settings'!") - raise SystemExit - - self.kafka_topic = config['_settings']['KafkaTopic'] - self.input_file_path = config['_settings']['InputFilePath'] - self.output_file_path = config['_settings']['OutputFilePath'] - self.expected_messages = int(config['_settings']['ExpectedMessages']) - self.field_list = [] - for key in config.sections(): - if key == "_settings": - continue - else: - self.field_list.append(Field(config[key])) - - def validate(self, data, logger): - validations_failed = 0 - for field in self.field_list: - result = field.validate(data) - if result.valid == True: - logger.info('[PASSED] Field: %s' % field.path) - else: - validations_failed += 1 - logger.info('[-FAILED-] Field: %s; Failure: %s' % (field.path, result.error)) - return RecordValidationSummary(validations_failed, len(self.field_list))