def build_and_deploy_graph(**kwargs):
    graph = BuildGraph(**kwargs)
    graph.build()

    LOGGER.info('Connection to {0}:{1}'.format(kwargs['host'], kwargs['port']))
    client = DataIslandManagerClient(kwargs['host'], kwargs['port'], timeout=30)

    client.create_session(graph.session_id)
    json_dumps = json.dumps(graph.drop_list, indent=2)
    LOGGER.info('json:\n{}'.format(json_dumps))
    client.append_graph(graph.session_id, json_dumps)
    client.deploy_session(graph.session_id, get_roots(graph.drop_list))
Exemple #2
0
    def test_get_roots(self):
        """
        Check that the get_roots method from the droputils module works as intended
        """

        """
        A --> B
        """
        pg_spec = [
            {
                "oid": "A",
                "type": "plain",
                "storage": Categories.MEMORY,
                "consumers": ["B"],
            },
            {"oid": "B", "type": "app", "app": "test.test_graph_loader.DummyApp"},
        ]
        roots = droputils.get_roots(pg_spec)
        self.assertEqual(1, len(roots))
        self.assertEqual("A", next(iter(roots)))

        """
        A --> B
        The same, but now B references A
        """
        pg_spec = [
            {"oid": "A", "type": "plain", "storage": Categories.MEMORY},
            {
                "oid": "B",
                "type": "app",
                "app": "test.test_graph_loader.DummyApp",
                "inputs": ["A"],
            },
        ]
        roots = droputils.get_roots(pg_spec)
        self.assertEqual(1, len(roots))
        self.assertEqual("A", next(iter(roots)))

        """
        A --> C --> D --|
                        |--> E --> F
        B --------------|
        """
        pg_spec = [
            {"oid": "A", "type": "plain", "storage": Categories.MEMORY},
            {"oid": "B", "type": "plain", "storage": Categories.MEMORY},
            {"oid": "C", "type": "app", "app": "dlg.apps.crc.CRCApp", "inputs": ["A"]},
            {
                "oid": "D",
                "type": "plain",
                "storage": Categories.MEMORY,
                "producers": ["C"],
            },
            {
                "oid": "E",
                "type": "app",
                "app": "test.test_drop.SumupContainerChecksum",
                "inputs": ["D"],
            },
            {
                "oid": "F",
                "type": "plain",
                "storage": Categories.MEMORY,
                "producers": ["E"],
            },
        ]
        roots = droputils.get_roots(pg_spec)
        self.assertEqual(2, len(roots))
        self.assertListEqual(["A", "B"], sorted(roots))

        # The same as before but using dropdicts
        pg_spec_dropdicts = [dropdict(dropspec) for dropspec in pg_spec]
        roots = droputils.get_roots(pg_spec_dropdicts)
        self.assertEqual(2, len(roots))
        self.assertListEqual(["A", "B"], sorted(roots))