示例#1
0
def test_create_core_default():
    """Test `create_core` with factory defaults."""
    with temporary_config_file() as cfgfile:
        # std factory params
        core = create_core(cfgfile.name)
        assert isinstance(core, Core)
        assert core.auto_enable_auth == True
示例#2
0
def _setup_flavor_selection_tests(extra_conf=''):
    # FIXME: the test does not run if this is not in the environment!
    os.environ['OS_AUTH_URL'] = 'http://localhost:5000/v2/'
    env = ['username', 'password', 'tenant_name', 'auth_url']
    for name in env:
        os.environ['OS_' + name.upper()] = name

    with temporary_config_file(_const.SSH_AUTH_STANZA +
                               _const.CLOUD_AUTH_STANZA_FULL +
                               _const.RESOURCE_STANZA + extra_conf) as cfgfile:
        cfg = gc3libs.config.Configuration(cfgfile.name)
        resources = cfg.make_resources()
        cloud = resources['hobbes']

    # mock novaclient's `Flavor` type using a namedtuple
    _Flavor = namedtuple('_Flavor', 'name vcpus ram disk'.split())
    flavors = (
        _Flavor(name='1cpu-4ram-hpc', vcpus=1, ram=4000, disk=100),
        _Flavor(name='4cpu-16ram-hpc', vcpus=4, ram=16000, disk=100),
        _Flavor(name='8cpu-8ram-server', vcpus=8, ram=7680, disk=100),
    )

    cloud.client = MagicMock()
    cloud.client.flavors.list.return_value = flavors
    # `_connect` fills the flavor list
    cloud._connect()

    return cloud, flavors
示例#3
0
文件: test_core.py 项目: fliem/gc3pie
def test_create_core_default():
    """Test `create_core` with factory defaults."""
    with temporary_config_file() as cfgfile:
        # std factory params
        core = create_core(cfgfile.name)
        assert_is_instance(core, Core)
        assert_equal(core.auto_enable_auth, True)
示例#4
0
def _setup_flavor_selection_tests(extra_conf=''):
    # FIXME: the test does not run if this is not in the environment!
    os.environ['OS_AUTH_URL'] = 'http://localhost:5000/v2/'
    env = ['username', 'password', 'tenant_name', 'auth_url']
    for name in env:
        os.environ['OS_' + name.upper()] = name

    with temporary_config_file(
        _const.SSH_AUTH_STANZA
        + _const.CLOUD_AUTH_STANZA_FULL
        + _const.RESOURCE_STANZA + extra_conf
    ) as cfgfile:
        cfg = gc3libs.config.Configuration(cfgfile.name)
        resources = cfg.make_resources()
        cloud = resources['hobbes']

    # mock novaclient's `Flavor` type using a namedtuple
    _Flavor = namedtuple('_Flavor', 'name vcpus ram disk'.split())
    flavors = (
        _Flavor(name='1cpu-4ram-hpc', vcpus=1, ram=4000, disk=100),
        _Flavor(name='4cpu-16ram-hpc', vcpus=4, ram=16000, disk=100),
        _Flavor(name='8cpu-8ram-server', vcpus=8, ram=7680, disk=100),
    )

    cloud.client = MagicMock()
    cloud.client.flavors.list.return_value = flavors
    # `_connect` fills the flavor list
    cloud._connect()

    return cloud, flavors
示例#5
0
文件: test_core.py 项目: fliem/gc3pie
def test_create_core_non_default():
    """Test `create_core` with non-default arguments."""
    with temporary_config_file() as cfgfile:
        # use a specific MatchMaker instance for equality testing
        mm = MatchMaker()
        core = create_core(cfgfile.name, matchmaker=mm)
        assert_equal(core.auto_enable_auth, True)
        assert_equal(core.matchmaker, mm)
示例#6
0
def test_create_engine_non_default2():
    """Test `create_engine` with several non-default arguments."""
    with temporary_config_file() as cfgfile:
        engine = create_engine(cfgfile.name,
                               can_submit=False,
                               max_in_flight=1234)
        assert engine.can_submit == False
        assert engine.max_in_flight == 1234
示例#7
0
def test_create_engine_non_default2():
    """Test `create_engine` with several non-default arguments."""
    with temporary_config_file() as cfgfile:
        engine = create_engine(cfgfile.name,
                               can_submit=False,
                               max_in_flight=1234)
        assert_equal(engine.can_submit, False)
        assert_equal(engine.max_in_flight, 1234)
示例#8
0
def test_create_core_non_default():
    """Test `create_core` with non-default arguments."""
    with temporary_config_file() as cfgfile:
        # use a specific MatchMaker instance for equality testing
        mm = MatchMaker()
        core = create_core(cfgfile.name, matchmaker=mm)
        assert core.auto_enable_auth == True
        assert core.matchmaker == mm
示例#9
0
def test_create_engine_with_core_options():
    """Test `create_engine` with a mix of Engine and Core options."""
    with temporary_config_file() as cfgfile:
        # use a specific MatchMaker instance for equality testing
        mm = MatchMaker()
        engine = create_engine(cfgfile.name,
                               can_submit=False,
                               matchmaker=mm,
                               auto_enable_auth=False)
        assert engine.can_submit == False
        assert engine._core.matchmaker == mm
        assert engine._core.auto_enable_auth == False
示例#10
0
def test_create_engine_with_core_options():
    """Test `create_engine` with a mix of Engine and Core options."""
    with temporary_config_file() as cfgfile:
        # use a specific MatchMaker instance for equality testing
        mm = MatchMaker()
        engine = create_engine(cfgfile.name,
                               can_submit=False,
                               matchmaker=mm,
                               auto_enable_auth=False)
        assert_equal(engine.can_submit, False)
        assert_equal(engine._core.matchmaker, mm)
        assert_equal(engine._core.auto_enable_auth, False)
示例#11
0
def test_openstack_variables_are_optional():
    with temporary_config_file(_const.SSH_AUTH_STANZA +
                               _const.CLOUD_AUTH_STANZA_USE_ENV +
                               _const.RESOURCE_STANZA) as cfgfile:
        # set up fake environment
        env = ['username', 'password', 'tenant_name', 'auth_url']
        for name in env:
            os.environ['OS_' + name.upper()] = name

        # check that resource has been correctly created
        cfg = gc3libs.config.Configuration(cfgfile.name)
        resources = cfg.make_resources()
        assert 'hobbes' in resources

        cloud = resources['hobbes']
        assert isinstance(cloud, OpenStackLrms)

        # check that values have been inherited from the environment
        for name in env:
            attr = ('os_' + name)
            assert hasattr(cloud, attr)
            assert getattr(cloud, attr) == name
示例#12
0
    def test_openstack_variables_are_optional(self):
        with temporary_config_file(
            self._const.SSH_AUTH_STANZA
            + self._const.CLOUD_AUTH_STANZA_USE_ENV
            + self._const.RESOURCE_STANZA
        ) as cfgfile:
            # set up fake environment
            env = ['username', 'password', 'tenant_name', 'auth_url']
            for name in env:
                os.environ['OS_' + name.upper()] = name

            # check that resource has been correctly created
            cfg = gc3libs.config.Configuration(cfgfile.name)
            resources = cfg.make_resources()
            assert 'hobbes' in resources

            cloud = resources['hobbes']
            assert isinstance(cloud, OpenStackLrms)

            # check that values have been inherited from the environment
            for name in env:
                attr = ('os_' + name)
                assert hasattr(cloud, attr)
                assert_equal(getattr(cloud, attr), name)
示例#13
0
文件: test_core.py 项目: fliem/gc3pie
def test_create_core_no_auto_enable_auth():
    """Test `create_core` without the "auto enable" feature."""
    with temporary_config_file() as cfgfile:
        # std factory params
        core = create_core(cfgfile.name, auto_enable_auth=False)
        assert_equal(core.auto_enable_auth, False)
示例#14
0
def test_create_engine_default():
    """Test `create_engine` with factory defaults."""
    with temporary_config_file() as cfgfile:
        # std factory params
        engine = create_engine(cfgfile.name)
        assert_is_instance(engine, Engine)
示例#15
0
def test_create_engine_default():
    """Test `create_engine` with factory defaults."""
    with temporary_config_file() as cfgfile:
        # std factory params
        engine = create_engine(cfgfile.name)
        assert isinstance(engine, Engine)
示例#16
0
def test_create_engine_non_default1():
    """Test `create_engine` with one non-default argument."""
    with temporary_config_file() as cfgfile:
        engine = create_engine(cfgfile.name, can_submit=False)
        assert_equal(engine.can_submit, False)
示例#17
0
def test_create_core_no_auto_enable_auth():
    """Test `create_core` without the "auto enable" feature."""
    with temporary_config_file() as cfgfile:
        # std factory params
        core = create_core(cfgfile.name, auto_enable_auth=False)
        assert core.auto_enable_auth == False
示例#18
0
def test_create_engine_non_default1():
    """Test `create_engine` with one non-default argument."""
    with temporary_config_file() as cfgfile:
        engine = create_engine(cfgfile.name, can_submit=False)
        assert engine.can_submit == False