コード例 #1
0
    def __validate_contain_group( self, oper_resp, orig_DOM, exp_contain = True ):
        xml_resp_stream = ( oper_resp.text ).encode( 'utf-8', 'ignore' )
        xml_resp_DOM = md.parseString( xml_resp_stream )
        nodeListOperGroup = xml_resp_DOM.getElementsByTagName( 'group-desc' )
        if ( nodeListOperGroup.length > 1 ) :
            err_msg = '\n !!! Operational Data Store has more groups as one \n'
            self.log.error( self._paint_msg_red( err_msg ) )
            raise AssertionError( err_msg )

        origDict = XMLtoDictParserTools.parseDOM_ToDict( orig_DOM._get_documentElement(),
                                                        ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
        origDict['group-desc'] = origDict.pop( 'group' )
        nodeDict = {}
        for node in nodeListOperGroup :
            nodeDict = XMLtoDictParserTools.parseDOM_ToDict( node,
                                                            ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
        if exp_contain :
            if nodeDict != origDict :
                err_msg = '\n !!! Loaded operation statistics doesn\'t contain expected group \n' \
                            ' expected:      %s\n found:         %s\n differences:   %s\n' \
                            '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
                self.log.error( self._paint_msg_red( err_msg ) )
                raise AssertionError( err_msg )

        else :
            if nodeDict == origDict :
                err_msg = '\n !!! Loaded operation statistics contains expected group, delete fail \n' \
                            ' found:         %s\n' % ( nodeDict )
                self.log.error( self._paint_msg_red( err_msg ) )
                raise AssertionError( err_msg )
コード例 #2
0
    def __validate_contain_group(self, oper_resp, orig_DOM, exp_contain=True):
        xml_resp_stream = (oper_resp.text).encode('utf-8', 'ignore')
        xml_resp_DOM = md.parseString(xml_resp_stream)
        nodeListOperGroup = xml_resp_DOM.getElementsByTagName('group-desc')
        if (nodeListOperGroup.length > 1):
            err_msg = '\n !!! Operational Data Store has more groups as one \n'
            self.log.error(self._paint_msg_red(err_msg))
            raise AssertionError(err_msg)

        origDict = XMLtoDictParserTools.parseDOM_ToDict(
            orig_DOM._get_documentElement(),
            ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
        origDict['group-desc'] = origDict.pop('group')
        nodeDict = {}
        for node in nodeListOperGroup:
            nodeDict = XMLtoDictParserTools.parseDOM_ToDict(
                node, ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
        if exp_contain:
            if nodeDict != origDict:
                err_msg = '\n !!! Loaded operation statistics doesn\'t contain expected group \n' \
                            ' expected:      %s\n found:         %s\n differences:   %s\n' \
                            '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
                self.log.error(self._paint_msg_red(err_msg))
                raise AssertionError(err_msg)

        else:
            if nodeDict == origDict:
                err_msg = '\n !!! Loaded operation statistics contains expected group, delete fail \n' \
                            ' found:         %s\n' % ( nodeDict )
                self.log.error(self._paint_msg_red(err_msg))
                raise AssertionError(err_msg)
コード例 #3
0
 def __validate_contain_flow( self, oper_resp, orig_DOM, exp_contain = True ):
     xml_resp_stream = ( oper_resp.text ).encode( 'utf-8', 'ignore' )
     xml_resp_DOM = md.parseString( xml_resp_stream )
     nodeListOperFlows = xml_resp_DOM.getElementsByTagName( 'flow-statistics' )
     origDict = XMLtoDictParserTools.parseDOM_ToDict( orig_DOM._get_documentElement(),
                                                     ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
     origDict['flow-statistics'] = origDict.pop( 'flow' )
     nodeDict = {}
     for node in nodeListOperFlows :
         if self.__is_wanted_flow( orig_DOM, node ) :
             nodeDict = XMLtoDictParserTools.parseDOM_ToDict( node,
                                                             ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
             break
     if exp_contain :
         if nodeDict != origDict :
             err_msg = '\n!!!!! Loaded operation statistics doesn\'t contain expected flow \n' \
                         ' expected:      %s\n found:         %s\n differences:   %s\n' \
                         '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
             self.log.error( self._paint_msg_red( err_msg ) )
             raise AssertionError( err_msg )
     else :
         if nodeDict == origDict :
             err_msg = '\n !!! Loaded operation statistics contains expected flow, delete fail \n' \
                         ' found:         %s\n' % ( nodeDict )
             self.log.error( self._paint_msg_red( err_msg ) )
             raise AssertionError( err_msg )
コード例 #4
0
ファイル: odl_flow_test.py プロジェクト: Offo11/OpenDaylight
 def __validate_contain_flow(self, oper_resp, orig_DOM, exp_contain=True):
     xml_resp_stream = (oper_resp.text).encode('utf-8', 'ignore')
     xml_resp_DOM = md.parseString(xml_resp_stream)
     nodeListOperFlows = xml_resp_DOM.getElementsByTagName(
         'flow-statistics')
     origDict = XMLtoDictParserTools.parseDOM_ToDict(
         orig_DOM._get_documentElement(),
         ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
     origDict['flow-statistics'] = origDict.pop('flow')
     nodeDict = {}
     for node in nodeListOperFlows:
         if self.__is_wanted_flow(orig_DOM, node):
             nodeDict = XMLtoDictParserTools.parseDOM_ToDict(
                 node, ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
             break
     if exp_contain:
         if nodeDict != origDict:
             err_msg = '\n!!!!! Loaded operation statistics doesn\'t contain expected flow \n' \
                         ' expected:      %s\n found:         %s\n differences:   %s\n' \
                         '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
             self.log.error(self._paint_msg_red(err_msg))
             raise AssertionError(err_msg)
     else:
         if nodeDict == origDict:
             err_msg = '\n !!! Loaded operation statistics contains expected flow, delete fail \n' \
                         ' found:         %s\n' % ( nodeDict )
             self.log.error(self._paint_msg_red(err_msg))
             raise AssertionError(err_msg)
コード例 #5
0
 def __is_wanted_flow( self, orig_flow_DOM, resp_flow_DOM ):
     identif_list = ['priority', 'cookie', 'match']
     for ident in identif_list :
         orig_ident_node = orig_flow_DOM.getElementsByTagName( ident )[0]
         resp_ident_node = resp_flow_DOM.getElementsByTagName( ident )[0]
         orig_ident_dict = XMLtoDictParserTools.parseDOM_ToDict( orig_ident_node,
                                                                 ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
         resp_ident_dict = XMLtoDictParserTools.parseDOM_ToDict( resp_ident_node,
                                                                 ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
         if ( orig_ident_dict != resp_ident_dict ) :
             return False
     return True
コード例 #6
0
ファイル: odl_flow_test.py プロジェクト: Offo11/OpenDaylight
 def __is_wanted_flow(self, orig_flow_DOM, resp_flow_DOM):
     identif_list = ['priority', 'cookie', 'match']
     for ident in identif_list:
         orig_ident_node = orig_flow_DOM.getElementsByTagName(ident)[0]
         resp_ident_node = resp_flow_DOM.getElementsByTagName(ident)[0]
         orig_ident_dict = XMLtoDictParserTools.parseDOM_ToDict(
             orig_ident_node,
             ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
         resp_ident_dict = XMLtoDictParserTools.parseDOM_ToDict(
             resp_ident_node,
             ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
         if (orig_ident_dict != resp_ident_dict):
             return False
     return True
コード例 #7
0
 def assertDataDOM( self, orig_DOM_Doc, resp_DOM_Doc ):
     """
     assertDataDOM - help method for assertion the two DOM data representation
                       e.g. the request xml and the config Data Store result
                       has to be same always
     @param orig_DOM_Doc: DOM Document sends to controller (e.g. from file input)
     @param resp_DOM_Doc: DOM Document returns from response 
     @raise AssertionError: if response has not the expected 404 code
     """
     origDict = XMLtoDictParserTools.parseDOM_ToDict( orig_DOM_Doc._get_documentElement() )
     respDict = XMLtoDictParserTools.parseDOM_ToDict( resp_DOM_Doc._get_documentElement() )
     if ( respDict != origDict ) :
         err_msg = '\n !!! Uploaded and stored xml, are not the same\n' \
             ' uploaded:      %s\n stored:        %s\n differences:   %s\n' \
             '' % ( origDict, respDict, XMLtoDictParserTools.getDifferenceDict( origDict, respDict ) )
         self.log.error( self._paint_msg_red( err_msg ) )
         raise AssertionError( err_msg )