Esempio n. 1
0
def analyze(replica_file: click.Path,
            barf: bool):
    """Perform a "dry run" of the replica creation without actually executing, and return the expected results."""

    replica = ReplicaFactory()
    replica.load_config(replica_file)
    click.echo(replica.analyze(barf))
Esempio n. 2
0
def create(replica_file: click.Path,
           name: str,
           barf: bool):
    """Generate a new replica from a replica.yml file.
    """
    replica = ReplicaFactory()
    replica.load_config(replica_file)
    click.echo(replica.create(name, barf))
Esempio n. 3
0
def test_analyze_unsampled(docker_flush):

    replica = ReplicaFactory()

    config = os.path.join(PACKAGE_ROOT, "snowshu", "templates", "replica.yml")
    replica.load_config(config)
    result = replica.analyze(barf=False).split('\n')
    result.reverse()
    for line in result:
        if "ORDERS" in line:
            assert '\x1b[0;32m100 %\x1b[0m' in line
            break
def test_loading_specified_replica_file(tmpdir, stub_creds, stub_configs):
    """ Verify that a different named config file is loaded properly. """
    replica_file = Path(tmpdir / 'my_custom_name.yml')
    cred_file = Path(tmpdir / 'my_cred_file.yml')
    stub_creds = stub_creds()
    stub_configs = stub_configs()
    stub_configs["credpath"] = str(cred_file.absolute())

    cred_file.write_text(json.dumps(stub_creds))
    replica_file.write_text(json.dumps(stub_configs))

    replica = ReplicaFactory()
    assert not replica.config  # no config in new obj
    replica.load_config(replica_file)
    assert replica.config  # config should now be loaded
Esempio n. 5
0
def tests_incremental_flag(graph, stub_configs):
    graph.return_value.graph = mock.Mock()
    replica = ReplicaFactory()
    replica.load_config(stub_configs())
    test_name = rand_string(10)
    replica.incremental = rand_string(10)
    adapter = replica.config.target_profile.adapter = mock.Mock(
        spec=BaseTargetAdapter)
    result = replica.create(test_name, False)
    adapter.initialize_replica.assert_called_once_with('default',
                                                       replica.incremental)
    adapter.build_catalog.assert_called()
    assert 'image up-to-date' in result
Esempio n. 6
0
def tests_replica_rename(_, build_graph, get_graphs, stub_configs):
    replica = ReplicaFactory()
    replica.load_config(stub_configs())
    test_name = rand_string(10)
    replica.create(test_name, False)
    assert build_graph.call_args[0][0].name == test_name