示例#1
0
def test_handle_bigip_config_missing_partitions(request):
    handler = None
    try:
        bigip = MockBigIp()
        config_template = Template('/tmp/config.$pid')
        config_file = config_template.substitute(pid=os.getpid())

        handler = bigipconfigdriver.ConfigHandler(config_file, bigip, 0)

        obj = {}
        obj['bigip'] = {
            'username': '******',
            'password': '******',
            'url': 'http://10.10.10.10:443',
            'partitions': []
        }

        with open(config_file, 'w+') as f:

            def fin():
                os.unlink(config_file)

            request.addfinalizer(fin)
            json.dump(obj, f)

        r = bigipconfigdriver._parse_config(config_file)
        with pytest.raises(bigipconfigdriver.ConfigError):
            bigipconfigdriver._handle_bigip_config(r)
    finally:
        assert handler is not None

        handler.stop()
        handler._thread.join(30)
        assert handler._thread.is_alive() is False
示例#2
0
def test_handle_bigip_config_missing_bigip(request):
    handler = None
    try:
        bigip = MockBigIp()
        config_template = Template('/tmp/config.$pid')
        config_file = config_template.substitute(pid=os.getpid())

        handler = bigipconfigdriver.ConfigHandler(config_file, bigip, 0)

        obj = {}

        with open(config_file, 'w+') as f:

            def fin():
                os.unlink(config_file)

            request.addfinalizer(fin)
            json.dump(obj, f)

        r = bigipconfigdriver._parse_config(config_file)
        with pytest.raises(bigipconfigdriver.ConfigError):
            bigipconfigdriver._handle_bigip_config(r)
    finally:
        assert handler is not None

        handler.stop()
        handler._thread.join(30)
        assert handler._thread.is_alive() is False