Exemplo n.º 1
0
    def test_network_ad_load(self):

        cbm = Neo4jCBMGraph(importer=self.n4j_imp)

        ad = 'Network-ad.graphml'

        plain_neo4j = self.n4j_imp.import_graph_from_file_direct(graph_file=ad)
        print(f"Validating ARM graph {ad}")
        plain_neo4j.validate_graph()

        site_arm = Neo4jARMGraph(graph=Neo4jPropertyGraph(
            graph_id=plain_neo4j.graph_id, importer=self.n4j_imp))
        print(f'ARM Graph {site_arm.graph_id}')

        # generate a dict of ADMs from site graph ARM
        site_adms = site_arm.generate_adms()
        print('ADMS ' + str(site_adms.keys()))

        # desired ADM is under 'primary'
        site_adm = site_adms['primary']
        cbm.merge_adm(adm=site_adm)

        print('Deleting ADM and ARM graphs')
        for adm in site_adms.values():
            adm.delete_graph()
        site_arm.delete_graph()

        cbm.validate_graph()
        print('CBM ID is ' + cbm.graph_id)

        self.n4j_imp.delete_all_graphs()
Exemplo n.º 2
0
    def generate_adms() -> list:
        # these are produced by substrate tests
        site_ads = [
            '../../../neo4j/RENCI-ad.graphml', '../../../neo4j/UKY-ad.graphml',
            '../../../neo4j/LBNL-ad.graphml',
            '../../../neo4j/Network-ad.graphml'
        ]

        result = []

        for ad in site_ads:
            plain_neo4j = FimTestHelper.n4j_imp.import_graph_from_file_direct(
                graph_file=ad)
            print(f"Validating ARM graph {ad}")
            plain_neo4j.validate_graph()

            site_arm = Neo4jARMGraph(graph=Neo4jPropertyGraph(
                graph_id=plain_neo4j.graph_id, importer=FimTestHelper.n4j_imp))
            # generate a dict of ADMs from site graph ARM
            site_adms = site_arm.generate_adms()
            print('ADMS' + str(site_adms.keys()))

            # desired ADM is under 'primary'
            site_adm = site_adms['primary']
            result.append(site_adm)
        return result
Exemplo n.º 3
0
    def get_arm_graph(*, graph_id: str) -> ABCARMPropertyGraph:
        """
        Load arm graph from fim
        :param graph_id: graph_id
        :return: Neo4jARMGraph
        """
        neo4j_graph_importer = FimHelper.get_neo4j_importer()
        arm_graph = Neo4jARMGraph(graph=Neo4jPropertyGraph(
            graph_id=graph_id, importer=neo4j_graph_importer))
        if arm_graph.graph_exists():
            arm_graph.validate_graph()

        return arm_graph
Exemplo n.º 4
0
    def generate_renci_adm():
        renci_ad = '../../../neo4j/RENCI-ad.graphml'
        cbm = Neo4jCBMGraph(importer=FimTestHelper.n4j_imp)
        plain_neo4j = FimTestHelper.n4j_imp.import_graph_from_file_direct(
            graph_file=renci_ad)
        print(f"Validating ARM graph {renci_ad}")
        plain_neo4j.validate_graph()

        site_arm = Neo4jARMGraph(graph=Neo4jPropertyGraph(
            graph_id=plain_neo4j.graph_id, importer=FimTestHelper.n4j_imp))
        # generate a dict of ADMs from site graph ARM
        site_adms = site_arm.generate_adms()
        print('ADMS' + str(site_adms.keys()))

        # desired ADM is under 'primary'
        site_adm = site_adms['primary']

        return site_arm, site_adm
Exemplo n.º 5
0
    def get_arm_graph_from_file(*,
                                filename: str,
                                graph_id: str = None) -> ABCARMPropertyGraph:
        """
        Load specified file directly with no manipulations or validation
        :param filename:
        :param graph_id:
        :return:
        """
        neo4j_graph_importer = FimHelper.get_neo4j_importer()
        neo4_graph = neo4j_graph_importer.import_graph_from_file(
            graph_file=filename, graph_id=graph_id)
        site_arm = Neo4jARMGraph(graph=Neo4jPropertyGraph(
            graph_id=neo4_graph.graph_id, importer=neo4j_graph_importer))

        site_arm.validate_graph()

        return site_arm
Exemplo n.º 6
0
    def test_3_site_load(self):

        # these are produced by substrate tests
        site_ads = [
            'RENCI-ad.graphml', 'UKY-ad.graphml', 'LBNL-ad.graphml',
            'Network-ad.graphml'
        ]

        cbm = Neo4jCBMGraph(importer=self.n4j_imp)

        adm_ids = dict()
        site_arms = dict()

        for ad in site_ads:
            plain_neo4j = self.n4j_imp.import_graph_from_file_direct(
                graph_file=ad)
            print(f"Validating ARM graph {ad} with id {plain_neo4j.graph_id}")
            plain_neo4j.validate_graph()

            site_arms[ad] = Neo4jARMGraph(graph=Neo4jPropertyGraph(
                graph_id=plain_neo4j.graph_id, importer=self.n4j_imp))
            # generate a dict of ADMs from site graph ARM
            site_adms = site_arms[ad].generate_adms()
            print('ADMS ' + str(site_adms.keys()))
            for adm_id in site_adms.keys():
                print(f'  ADM id {site_adms[adm_id].graph_id}')

            # desired ADM is under 'primary'
            site_adm = site_adms['primary']
            cbm.merge_adm(adm=site_adm)

            print('Deleting ADM and ARM graphs')
            for adm in site_adms.values():
                adm_ids[ad] = adm.graph_id
                adm.delete_graph()
            #site_arms[ad].delete_graph()

        cbm.validate_graph()
        print('CBM ID is ' + cbm.graph_id)

        print('Finding intersite links')
        links = cbm.get_intersite_links()
        print(links)
        assert (len(links) == 3)
        ls = set()
        for l in links:
            ls.add(l[1])
        assert ('port+renc-data-sw:HundredGigE0/0/0/26-Wave' in ls
                and 'port+renc-data-sw:HundredGigE0/0/0/27-Wave' in ls
                and 'port+uky-data-sw:HundredGigE0/0/0/27-Wave' in ls)
        print('Done')

        ad = 'Network-ad.graphml'
        print(f"Unmerging graph {adm_ids[ad]}")
        cbm.unmerge_adm(graph_id=adm_ids[ad])
        print(f"Merging back")
        site_adms = site_arms[ad].generate_adms()
        site_adm = site_adms['primary']
        cbm.merge_adm(adm=site_adm)

        ad = 'RENCI-ad.graphml'
        print(f"Unmerging graph {adm_ids[ad]}")
        cbm.unmerge_adm(graph_id=adm_ids[ad])
        print(f"Merging back")
        site_adms = site_arms[ad].generate_adms()
        site_adm = site_adms['primary']
        cbm.merge_adm(adm=site_adm)

        self.n4j_imp.delete_all_graphs()
Exemplo n.º 7
0
    def test_arm_load(self):
        """
        Load an ARM, transform to ADM, then merge into BQM
        :return:
        """

        plain_neo4j = self.n4j_imp.import_graph_from_file_direct(
            graph_file='RENCI-ad.graphml')

        print("Validating ARM graph")
        plain_neo4j.validate_graph()

        cbm = Neo4jCBMGraph(importer=self.n4j_imp)

        site_arm = Neo4jARMGraph(graph=Neo4jPropertyGraph(
            graph_id=plain_neo4j.graph_id, importer=self.n4j_imp))
        # generate a dict of ADMs from site graph ARM
        site_adms = site_arm.generate_adms()
        print('ADMS' + str(site_adms.keys()))

        # desired ADM is under 'primary'
        site_adm = site_adms['primary']
        cbm.merge_adm(adm=site_adm)

        cbm.validate_graph()
        print('CBM ID is ' + cbm.graph_id)

        # test delegation format
        list_of_nodes = cbm.get_matching_nodes_with_components(
            label=ABCPropertyGraphConstants.CLASS_NetworkNode,
            props={'Name': 'renc-w3'})

        print('Deleting ADM and ARM graphs')
        for adm in site_adms.values():
            adm.delete_graph()
        site_arm.delete_graph()

        #print("Printing component models")
        #for n in cbm.get_all_nodes_by_class(label=ABCPropertyGraphConstants.CLASS_Component):
        #    _, prop = cbm.get_node_properties(node_id=n)
        #    if prop.get(ABCPropertyGraphConstants.PROP_MODEL, None) is not None:
        #        print(prop[ABCPropertyGraphConstants.PROP_MODEL])

        # test CBM querying
        node_props = {'Site': 'RENC', 'Type': 'Server'}
        list_of_nodes = cbm.get_matching_nodes_with_components(
            label=ABCPropertyGraphConstants.CLASS_NetworkNode,
            props=node_props)
        self.assertEqual(len(list_of_nodes), 3)

        # construct some components
        c1 = ComponentSliver()
        c1.resource_name = 'c1'
        c1.resource_type = ComponentType.GPU
        c1.resource_model = 'Tesla T4'
        c2 = ComponentSliver()
        c2.resource_name = 'c2'
        c2.resource_type = ComponentType.SharedNIC
        c3 = ComponentSliver()
        c3.resource_name = 'c3'
        c3.resource_type = ComponentType.SmartNIC
        c3.resource_model = 'ConnectX-5'
        c4 = ComponentSliver()
        c4.resource_name = 'c4'
        c4.resource_type = ComponentType.SmartNIC
        c4.resource_model = 'ConnectX-5'

        ci = AttachedComponentsInfo()
        ci.add_device(c1)
        ci.add_device(c2)
        ci.add_device(c3)
        ci.add_device(c4)
        list_of_nodes = cbm.get_matching_nodes_with_components(
            label=ABCPropertyGraphConstants.CLASS_NetworkNode,
            props=node_props,
            comps=ci)
        print(f'Testing a mix of components #1 {list_of_nodes=}')
        self.assertEqual(len(list_of_nodes), 1)

        c5 = ComponentSliver()
        c5.resource_name = 'c5'
        c5.resource_type = ComponentType.SmartNIC
        c5.resource_model = 'ConnectX-5'
        ci.add_device(c5)
        list_of_nodes = cbm.get_matching_nodes_with_components(
            label=ABCPropertyGraphConstants.CLASS_NetworkNode,
            props=node_props,
            comps=ci)
        print(
            f'Testing a mix of components #2 {list_of_nodes=} (expected empty)'
        )
        self.assertEqual(len(list_of_nodes), 0)

        # test for SR-IOV shared cards
        ci = AttachedComponentsInfo()
        c6 = ComponentSliver()
        c6.resource_name = 'c6'
        c6.resource_type = ComponentType.SharedNIC
        c6.resource_model = 'ConnectX-6'
        ci.add_device(c6)

        c7 = ComponentSliver()
        c7.resource_name = 'c7'
        c7.resource_type = ComponentType.SharedNIC
        c7.resource_model = 'ConnectX-6'
        ci.add_device(c7)

        list_of_nodes = cbm.get_matching_nodes_with_components(
            label=ABCPropertyGraphConstants.CLASS_NetworkNode,
            props=node_props,
            comps=ci)
        print(f'Testing a mix of components #3 {list_of_nodes=}')
        self.assertEqual(len(list_of_nodes), 3)

        self.n4j_imp.delete_all_graphs()
Exemplo n.º 8
0
    def test_abqm(self):
        self.n4j_imp.delete_all_graphs()
        # these are produced by substrate tests
        site_ads = [
            '../../../neo4j/Network-ad.graphml',
            '../../../neo4j/LBNL-ad.graphml',
            '../../../neo4j/RENCI-ad.graphml', '../../../neo4j/UKY-ad.graphml'
        ]

        cbm = Neo4jCBMGraph(importer=self.n4j_imp)

        adm_ids = dict()

        for ad in site_ads:
            plain_neo4j = self.n4j_imp.import_graph_from_file_direct(
                graph_file=ad)
            print(f"Validating ARM graph {ad}")
            plain_neo4j.validate_graph()

            site_arm = Neo4jARMGraph(graph=Neo4jPropertyGraph(
                graph_id=plain_neo4j.graph_id, importer=self.n4j_imp))
            # generate a dict of ADMs from site graph ARM
            site_adms = site_arm.generate_adms()
            print('ADMS' + str(site_adms.keys()))

            # desired ADM is under 'primary'
            site_adm = site_adms['primary']
            cbm.merge_adm(adm=site_adm)

            print('Deleting ADM and ARM graphs')
            for adm in site_adms.values():
                adm_ids[ad] = adm.graph_id
                adm.delete_graph()
            site_arm.delete_graph()

        cbm.validate_graph()
        print('CBM ID is ' + cbm.graph_id)

        cbm_graph_id = cbm.graph_id
        # turn on debug so we can test formation of ABQM without querying
        # actor for reservations
        AggregatedBQMPlugin.DEBUG_FLAG = True

        n4j_pg = Neo4jPropertyGraph(graph_id=cbm_graph_id,
                                    importer=self.n4j_imp)

        cbm = Neo4jCBMFactory.create(n4j_pg)

        plugin = AggregatedBQMPlugin(actor=None, logger=None)

        abqm = plugin.plug_produce_bqm(cbm=cbm, query_level=1)

        abqm.validate_graph()

        abqm_string = abqm.serialize_graph()

        print('Writing ABQM to abqm.graphml')
        with open('abqm.graphml', 'w') as f:
            f.write(abqm_string)

        abqm_json = abqm.serialize_graph(format=GraphFormat.JSON_NODELINK)
        print('Writing ABQM to abqm.json')
        with open('abqm.json', 'w') as f:
            f.write(abqm_json)

        print('Writing CBM to cbm.graphml')
        cbm_string = cbm.serialize_graph()
        with open('cbm.graphml', 'w') as f:
            f.write(cbm_string)

        self.n4j_imp.delete_all_graphs()