Example #1
0
def test_parse_simple_raid():
    config = _parse_blockstore_params([
        "raid0:0:MOCKED",
        "raid0:1:POSTGRESQL",
        "raid0:2:s3:s3.example.com:region1:bucketA:key123:S3cr3t",
        "raid0:3:swift:swift.example.com:tenant2:containerB:user123:S3cr3t",
    ])
    assert config == RAID0BlockStoreConfig(blockstores=[
        MockedBlockStoreConfig(),
        PostgreSQLBlockStoreConfig(),
        S3BlockStoreConfig(
            s3_endpoint_url="s3.example.com",
            s3_region="region1",
            s3_bucket="bucketA",
            s3_key="key123",
            s3_secret="S3cr3t",
        ),
        SWIFTBlockStoreConfig(
            swift_authurl="swift.example.com",
            swift_tenant="tenant2",
            swift_container="containerB",
            swift_user="******",
            swift_password="******",
        ),
    ])
Example #2
0
def test_parse_swift():
    config = _parse_blockstore_params(["swift:swift.example.com:tenant2:containerB:user123:S3cr3t"])
    assert config == SWIFTBlockStoreConfig(
        swift_authurl="https://swift.example.com",
        swift_tenant="tenant2",
        swift_container="containerB",
        swift_user="******",
        swift_password="******",
    )
Example #3
0
def test_parse_s3_with_default_endpoint():
    config = _parse_blockstore_params(["s3::region1:bucketA:key123:S3cr3t"])
    assert config == S3BlockStoreConfig(
        s3_endpoint_url=None,
        s3_region="region1",
        s3_bucket="bucketA",
        s3_key="key123",
        s3_secret="S3cr3t",
    )
Example #4
0
def test_parse_s3():
    config = _parse_blockstore_params(["s3:s3.example.com:region1:bucketA:key123:S3cr3t"])
    assert config == S3BlockStoreConfig(
        s3_endpoint_url="https://s3.example.com",
        s3_region="region1",
        s3_bucket="bucketA",
        s3_key="key123",
        s3_secret="S3cr3t",
    )
Example #5
0
def test_parse_swift_custom_url_scheme():
    config = _parse_blockstore_params(
        ["swift:http\\://swift.example.com:tenant2:containerB:user123:\\:S3cr3t\\\\"]
    )
    assert config == SWIFTBlockStoreConfig(
        swift_authurl="http://swift.example.com",
        swift_tenant="tenant2",
        swift_container="containerB",
        swift_user="******",
        swift_password="******",  # Also test escaping in password
    )
Example #6
0
def test_parse_s3_with_custom_url_scheme():
    config = _parse_blockstore_params(
        ["s3:http\\://s3.example.com:region1:bucketA:key123:\\:S3cr3t\\\\"]
    )
    assert config == S3BlockStoreConfig(
        s3_endpoint_url="http://s3.example.com",
        s3_region="region1",
        s3_bucket="bucketA",
        s3_key="key123",
        s3_secret=":S3cr3t\\",  # Also test escaping in password
    )
Example #7
0
def test_bad_single_param(param):
    with pytest.raises(BadParameter):
        _parse_blockstore_params([param])
Example #8
0
def test_parse_postgresql():
    config = _parse_blockstore_params(["POSTGRESQL"])
    assert config == PostgreSQLBlockStoreConfig()
Example #9
0
def test_parse_mocked():
    config = _parse_blockstore_params(["MOCKED"])
    assert config == MockedBlockStoreConfig()
Example #10
0
def test_bad_raid_params(params):
    with pytest.raises(BadParameter):
        _parse_blockstore_params(params)
Example #11
0
def test_invalid_mix_raid_params(param):
    with pytest.raises(BadParameter):
        _parse_blockstore_params([param])