Skip to content

Commit

Permalink
Fixed functionality for HBT Absent test cases
Browse files Browse the repository at this point in the history
Updated code when HBT absent is triggered.   Should not impact other
test cases.

Note:  works for 1 CBSD, but not for more than 1.  Since v1.1 test cases
only call for 1 CBSD for HBT absent, this is a partial fix.  Should be
revisited as an enhancement in future to fix multiple-CBSD test case
  • Loading branch information
cwilliams-ericsson committed Nov 9, 2017
1 parent b11f4d6 commit f321a34
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .pydevproject
Expand Up @@ -2,4 +2,7 @@
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}/CBRS_Mock_SAS_Python_Master/cbrsPython-master/cbrsPython</path>
</pydev_pathproperty>
</pydev_project>
Expand Up @@ -24,7 +24,7 @@ def startStep(self,json_dict,typeOfCalling,ipRequestAddress=None):

def finishStep(self,response,typeOfCalling,stepStatus):
if stepStatus==StepStatus.PASSED:
self.print_To_Terminal(consts.VALIDATION_PASSED_MESSAGE + str(typeOfCalling) + " " + consts.RESPONSE_NODE_NAME.title())
self.print_To_Terminal(datetime.utcnow().replace(microsecond=0).isoformat()+'Z: '+consts.VALIDATION_PASSED_MESSAGE + str(typeOfCalling) + " " + consts.RESPONSE_NODE_NAME.title())
else:
self.print_To_Terminal(response)

Expand Down
Expand Up @@ -31,6 +31,7 @@ def __init__(self, cbsdSerialNumber,testDefinition,EnviormentConfFile,dirPath,cu
self.oldHttpReq = None
self.validDurationTime = 0
self.lastHeartBeatTime = None
self.secondLastHeartBeatTime = None
self.grantBeforeHeartBeat = False
self.validationErrorAccuredInEngine = False
self.isLastStepInCSV = False
Expand All @@ -47,7 +48,8 @@ def __init__(self, cbsdSerialNumber,testDefinition,EnviormentConfFile,dirPath,cu
self.cbsdId = None
self.grantId = 0
self.expectedRelBeforeDeragistration = False
self.isDelayTriggered = False
self.isDelayTriggered = False
self.delayEndTime = DT.datetime.utcnow()
self.secondsForDelay = 0
self.isMeasRepRequested = False
self.stopGrantRenew = False
Expand Down Expand Up @@ -93,8 +95,14 @@ def set_Current_Json_Steps(self,testDefinition,confFile,dirPath):
def handle_Http_Req(self,httpRequest,typeOfCalling):

req = httpRequest
if(self.isDelayTriggered==True and typeOfCalling!=consts.HEART_BEAT_SUFFIX_HTTP):
sleep(2*(self.secondsForDelay))
if(self.isDelayTriggered==True):
current_time = DT.datetime.utcnow()
deltaT = self.delayEndTime - current_time
remainingTimeToSleep = int(deltaT.total_seconds()) + 5 # sleep until HBT absent is over, plus extra 5 sec
if remainingTimeToSleep <= 0:
remainingTimeToSleep = 1
self.loggerHandler.print_to_Logs_Files('request message received while HBT is absent, sleep '+str(remainingTimeToSleep)+' sec before responding', False)
sleep(remainingTimeToSleep)

if(bool(self.assertion.get_Attribute_Value_From_Json(self.get_Expected_Json_File_Name(),"noMoreStep"))==True):
self.isLastStepInCSV = True
Expand Down Expand Up @@ -177,7 +185,8 @@ def handle_Http_Req(self,httpRequest,typeOfCalling):
return consts.GRANT_BEFORE_HEARTBEAT_ERROR
self.Initialize_Repeats_Type_Allowed(consts.HEART_BEAT_SUFFIX_HTTP,httpRequest, typeOfCalling)
self.numberOfHearbeatRequests=1
self.lastHeartBeatTime = DT.datetime.now()
self.lastHeartBeatTime = DT.datetime.now()
self.secondLastHeartBeatTime = self.lastHeartBeatTime
else:
if(typeOfCalling==consts.GRANT_SUFFIX_HTTP):
self.grantBeforeHeartBeat = True
Expand Down Expand Up @@ -235,7 +244,9 @@ def returnSpectInquieryInCaseOfRepeatsAllowedAlwaysValidationSucceed(self,expect
def is_Absent_Response_Set(self,expectedJsonName):
theFlag = (bool(self.assertion.get_Attribute_Value_From_Json(expectedJsonName,"isAbsentResponse")))
if theFlag == True:
self.isDelayTriggered = True
self.isDelayTriggered = True
self.delayEndTime = DT.datetime.utcnow() + DT.timedelta(seconds = self.secondsForDelay)
self.loggerHandler.print_to_Logs_Files('LAST HBT RESPONSE THAT SET TRANSMIT_EXPIRE_TIME WAS AT: '+str(self.secondLastHeartBeatTime), True)
return True

def Is_Repeats_Available(self,expectedJsonName,typeOfCalling):
Expand Down Expand Up @@ -286,9 +297,10 @@ def is_Valid_Heart_Beat_Time(self):
'''
currentTime = DT.datetime.utcnow()
timeBetween = (currentTime-self.lastHeartBeatTime).total_seconds()
self.loggerHandler.print_to_Logs_Files("The time interval between two heartbeat request messages is " + str(timeBetween), True)
self.loggerHandler.print_to_Logs_Files("The time interval between two heartbeat request messages is " + str(timeBetween), False)
if(float(timeBetween)>float(self.validDurationTime)):
return False
self.secondLastHeartBeatTime= self.lastHeartBeatTime
self.lastHeartBeatTime = DT.datetime.utcnow()
return True

Expand Down
Expand Up @@ -6,7 +6,7 @@
DEFAULT_CHANNEL_TYPE = "GAA"
SECONDS_TO_ADD_FOR_GRANT_EXPIRE_TIME = 604800 # seconds ahead for grantExpireTime - 1 week
SECONDS_TO_ADD_FOR_TX_EXPIRE_TIME = 200 # seconds ahead for transmitExpireTime
SECONDS_FOR_DELAY_RESPONSE = 40 # seconds to delay response, if flagged in jsonExpected
SECONDS_FOR_DELAY_RESPONSE = SECONDS_TO_ADD_FOR_TX_EXPIRE_TIME # Worst-case value
CPI_SIGNATURE_VALID_TYPES = ['RS256', 'ES256']

### Other Constants
Expand Down

0 comments on commit f321a34

Please sign in to comment.