Beispiel #1
0
def test_graph_builds_dags_correctly(stub_graph_set):
    shgraph = SnowShuGraph()
    _, vals = stub_graph_set

    full_catalog = [
        vals.iso_relation, vals.view_relation, vals.downstream_relation,
        vals.upstream_relation, vals.birelation_left, vals.birelation_right
    ]

    graph = nx.Graph()
    graph.add_nodes_from(full_catalog)
    shgraph.graph = graph

    for sub in shgraph.get_graphs():
        assert isinstance(sub, nx.DiGraph)
Beispiel #2
0
    def _execute(self,
                 barf: bool = False,
                 name: Union[str, None] = None) -> None:
        graph = SnowShuGraph()
        if name is not None:
            self.config.name = name

        graph.build_graph(self.config)
        graphs = graph.get_graphs()
        if len(graphs) < 1:
            return "No relations found per provided replica configuration, exiting."

        # TODO replica container should not be started for analyze commands
        self.config.target_profile.adapter.initialize_replica(
            self.config.source_profile.name)
        runner = GraphSetRunner()
        runner.execute_graph_set(graphs,
                                 self.config.source_profile.adapter,
                                 self.config.target_profile.adapter,
                                 threads=self.config.threads,
                                 analyze=self.run_analyze,
                                 barf=barf)
        if not self.run_analyze:
            relations = [
                relation for graph in graphs for relation in graph.nodes]
            if self.config.source_profile.adapter.SUPPORTS_CROSS_DATABASE:
                logger.info('Creating x-database links in target...')
                self.config.target_profile.adapter.enable_cross_database(
                    relations)
                logger.info('X-database enabled.')

            logger.info(
                'Applying %s emulation functions to target...',
                self.config.source_profile.adapter.name)
            for function in self.config.source_profile.adapter.SUPPORTED_FUNCTIONS:
                self.config.target_profile.adapter.create_function_if_available(
                    function, relations)
            logger.info('Emulation functions applied.')
            self.config.target_profile.adapter.finalize_replica()

        return printable_result(
            graph_to_result_list(graphs),
            self.run_analyze)
Beispiel #3
0
def test_no_duplicates(stub_graph_set):
    shgraph=SnowShuGraph()

    _,vals = stub_graph_set

    full_catalog=[  vals.iso_relation,
                    vals.view_relation,
                    vals.downstream_relation,
                    vals.upstream_relation,
                    vals.birelation_left,
                    vals.birelation_right]

    config_dict=copy.deepcopy(CONFIGURATION)

    config=ConfigurationParser().from_file_or_path(StringIO(yaml.dump(config_dict)))
    
    shgraph.build_graph(config,full_catalog)       
    graphs = shgraph.get_graphs()

    all_nodes=[node for graph in graphs for node in graph.nodes]
    assert len(set(all_nodes)) == len(all_nodes)
Beispiel #4
0
def test_no_duplicates(stub_graph_set):
    shgraph = SnowShuGraph()

    _, vals = stub_graph_set

    full_catalog = [
        vals.iso_relation, vals.view_relation, vals.downstream_relation,
        vals.upstream_relation, vals.birelation_left, vals.birelation_right
    ]

    config_dict = copy.deepcopy(CONFIGURATION)

    config = ConfigurationParser().from_file_or_path(
        StringIO(yaml.dump(config_dict)))

    with mock.MagicMock() as adapter_mock:
        adapter_mock.build_catalog.return_value = full_catalog
        config.source_profile.adapter = adapter_mock
        shgraph.build_graph(config)
        graphs = shgraph.get_graphs()

    all_nodes = [node for graph in graphs for node in graph.nodes]
    assert len(set(all_nodes)) == len(all_nodes)