Exemple #1
0
def test_Resource_instance_meta_render():
    hello = App()
    hello.appname = 'hello'
    hello.meta_version = REDIS_CLIENT_META_VERSION
    hello.meta = REDIS_CLIENT_META
    hello_config = hello.lain_config

    redis_resource = App()
    redis_resource.appname = 'redis'
    redis_resource.meta_version = REDIS_RESOURCE_META_VERSION

    meta_from_file = yaml.safe_load(REDIS_RESOURCE_META)
    meta_yaml = yaml.safe_dump(meta_from_file, default_style='"')
    redis_resource.meta = meta_yaml
    redis_instance = App()
    redis_instance.meta_version = REDIS_RESOURCE_META_VERSION
    redis_instance.meta = redis_resource.get_resource_instance_meta(
        'hello', hello_config.use_resources['redis']['context'])
    redis_instance.default_image = \
        "{}/redis:release-{}".format(PRIVATE_REGISTRY,
                                     REDIS_RESOURCE_META_VERSION)
    redis_instance_config = redis_instance.lain_config
    assert redis_instance_config.appname == 'resource.redis.hello'
    assert redis_instance_config.procs[
        'redis'].image == redis_instance.default_image
    assert redis_instance_config.procs['redis'].memory == '128M'
    assert redis_instance_config.procs['redis'].num_instances == 1
    assert redis_instance_config.procs[
        'portal-redis'].image == redis_instance.default_image
def test_Render_system_volumes():
    hello = App()
    hello.appname = 'hello'
    hello.meta_version = HELLO_META_VERSION
    hello.meta = HELLO_META
    conf = hello.app_spec
    for podg in conf.PodGroups:
        for container in podg.Pod.Containers:
            assert container.SystemVolumes == DEFAULT_SYSTEM_VOLUMES
def test_Render_system_volumes_registry(system_volumes):
    system_volumes.return_value = [REGISTRY_SYSTEM_VOLUME]
    registry = App()
    registry.appname = 'registry'
    registry.meta_version = REGISTRY_META_VERSION
    registry.meta = REGISTRY_META
    conf = registry.app_spec
    for podg in conf.PodGroups:
        for container in podg.Pod.Containers:
            assert container.SystemVolumes == DEFAULT_SYSTEM_VOLUMES + [REGISTRY_SYSTEM_VOLUME]
def test_Render_system_volumes_registry(system_volumes):
    system_volumes.return_value = [REGISTRY_SYSTEM_VOLUME]
    registry = App()
    registry.appname = 'registry'
    registry.meta_version = REGISTRY_META_VERSION
    registry.meta = REGISTRY_META
    conf = registry.app_spec
    for podg in conf.PodGroups:
        for container in podg.Pod.Containers:
            assert container.SystemVolumes == DEFAULT_SYSTEM_VOLUMES + \
                [REGISTRY_SYSTEM_VOLUME]
def test_Render_system_volumes_registry(etcd_operations):
    etcd_operations[
        'utils_read_from_etcd'].return_value = generate_etcd_app_key_result(
            REGISTRY_SYSTEM_VOLUME)
    registry = App()
    registry.appname = 'registry'
    registry.meta_version = REGISTRY_META_VERSION
    registry.meta = REGISTRY_META
    conf = registry.app_spec
    for podg in conf.PodGroups:
        for container in podg.Pod.Containers:
            assert container.SystemVolumes == DEFAULT_SYSTEM_VOLUMES + [
                REGISTRY_SYSTEM_VOLUME
            ]