Exemplo n.º 1
0
def test_config_section_contextless():
    config = ConfigClient()
    test_section_1 = generate_uuid()
    test_section_2 = generate_uuid()
    config.set_config_option(test_section_1, 'a', 'b')
    config.set_config_option(test_section_2, 'c', 'd')

    value = config.get_config(None, None)

    assert isinstance(value, dict)
    assert list(value.keys()) == [test_section_1, test_section_2]
Exemplo n.º 2
0
 def setUp(self):
     self.c = ConfigClient()
     self.test_section_1 = str(generate_uuid())
     self.test_section_2 = str(generate_uuid())
     self.test_option_s = 'string'
     self.test_option_b = 'bool'
     self.test_option_i = 'int'
     self.test_option_f = 'float'
     self.test_option_sv = 'iddqd'
     self.test_option_bv = 'True'
     self.test_option_iv = '543210'
     self.test_option_fv = '3.1415'
     self.c.set_config_option(self.test_section_1, self.test_option_s, self.test_option_sv)
     self.c.set_config_option(self.test_section_1, self.test_option_b, self.test_option_bv)
     self.c.set_config_option(self.test_section_2, self.test_option_i, self.test_option_iv)
     self.c.set_config_option(self.test_section_2, self.test_option_f, self.test_option_fv)
Exemplo n.º 3
0
class TestConfigClients(unittest.TestCase):

    def setUp(self):
        self.c = ConfigClient()
        self.test_section_1 = str(generate_uuid())
        self.test_section_2 = str(generate_uuid())
        self.test_option_s = 'string'
        self.test_option_b = 'bool'
        self.test_option_i = 'int'
        self.test_option_f = 'float'
        self.test_option_sv = 'iddqd'
        self.test_option_bv = 'True'
        self.test_option_iv = '543210'
        self.test_option_fv = '3.1415'
        self.c.set_config_option(self.test_section_1, self.test_option_s, self.test_option_sv)
        self.c.set_config_option(self.test_section_1, self.test_option_b, self.test_option_bv)
        self.c.set_config_option(self.test_section_2, self.test_option_i, self.test_option_iv)
        self.c.set_config_option(self.test_section_2, self.test_option_f, self.test_option_fv)

    def tearDown(self):
        self.c = None

    @pytest.mark.xfail(reason='ConfigClient bug https://github.com/rucio/rucio/issues/3916')
    def test_get_config_all(self):
        """ CONFIG (CLIENT): Retrieve configuration values and check for correctness """
        tmp = self.c.get_config(None, None)
        assert isinstance(tmp, dict)
        assert self.test_section_1 in tmp.keys()
        assert self.test_option_s in tmp[self.test_section_1]
        assert self.test_option_b in tmp[self.test_section_1]
        assert self.test_option_sv == tmp[self.test_section_1][self.test_option_s]
        assert tmp[self.test_section_1][self.test_option_b]
        assert self.test_option_i in tmp[self.test_section_2]
        assert self.test_option_f in tmp[self.test_section_2]
        assert 543210 == tmp[self.test_section_2][self.test_option_i]
        assert 3.1415 == tmp[self.test_section_2][self.test_option_f]

    def test_get_config_section(self):
        """ CONFIG (CLIENT): Retrieve configuration section only """
        tmp = self.c.get_config(self.test_section_1, None)
        assert isinstance(tmp, dict)
        assert self.test_option_s in tmp.keys()
        assert self.test_option_b in tmp.keys()

    def test_get_config_section_option(self):
        """ CONFIG (CLIENT): Retrieve configuration option only """
        tmp = self.c.get_config(self.test_section_1, self.test_option_s)
        assert tmp == self.test_option_sv

        with pytest.raises(exception.ConfigNotFound):
            self.c.get_config(self.test_section_1, 'no_option')
Exemplo n.º 4
0
 def setupClass(self):
     self.c = ConfigClient()
     self.test_section_1 = str(generate_uuid())
     self.test_section_2 = str(generate_uuid())
     self.test_option_s = 'string'
     self.test_option_b = 'bool'
     self.test_option_i = 'int'
     self.test_option_f = 'float'
     self.test_option_sv = 'iddqd'
     self.test_option_bv = 'True'
     self.test_option_iv = '543210'
     self.test_option_fv = '3.1415'
     self.c.set_config_option(self.test_section_1, self.test_option_s, self.test_option_sv)
     self.c.set_config_option(self.test_section_1, self.test_option_b, self.test_option_bv)
     self.c.set_config_option(self.test_section_2, self.test_option_i, self.test_option_iv)
     self.c.set_config_option(self.test_section_2, self.test_option_f, self.test_option_fv)
Exemplo n.º 5
0
class TestConfigClients:
    @classmethod
    def setupClass(self):
        self.c = ConfigClient()
        self.test_section_1 = str(generate_uuid())
        self.test_section_2 = str(generate_uuid())
        self.test_option_s = 'string'
        self.test_option_b = 'bool'
        self.test_option_i = 'int'
        self.test_option_f = 'float'
        self.test_option_sv = 'iddqd'
        self.test_option_bv = 'True'
        self.test_option_iv = '543210'
        self.test_option_fv = '3.1415'
        self.c.set_config_option(self.test_section_1, self.test_option_s,
                                 self.test_option_sv)
        self.c.set_config_option(self.test_section_1, self.test_option_b,
                                 self.test_option_bv)
        self.c.set_config_option(self.test_section_2, self.test_option_i,
                                 self.test_option_iv)
        self.c.set_config_option(self.test_section_2, self.test_option_f,
                                 self.test_option_fv)

    @classmethod
    def tearDownClass(self):
        self.c.delete_config_option(self.test_section_1, self.test_option_s)
        self.c.delete_config_option(self.test_section_1, self.test_option_b)
        self.c.delete_config_option(self.test_section_2, self.test_option_i)
        self.c.delete_config_option(self.test_section_2, self.test_option_f)

    def test_get_config_all(self):
        """ CONFIG (CLIENT): Retrieve configuration values and check for correctness """
        tmp = self.c.get_config(None, None)
        assert_is_instance(tmp, dict)
        assert_in(self.test_section_1, tmp.keys())
        assert_in(self.test_option_s, tmp[self.test_section_1])
        assert_in(self.test_option_b, tmp[self.test_section_1])
        assert_equal(self.test_option_sv,
                     tmp[self.test_section_1][self.test_option_s])
        assert_true(tmp[self.test_section_1][self.test_option_b])
        assert_in(self.test_option_i, tmp[self.test_section_2])
        assert_in(self.test_option_f, tmp[self.test_section_2])
        assert_equal(543210, tmp[self.test_section_2][self.test_option_i])
        assert_equal(3.1415, tmp[self.test_section_2][self.test_option_f])

    def test_get_config_section(self):
        """ CONFIG (CLIENT): Retrieve configuration section only """
        tmp = self.c.get_config(self.test_section_1, None)
        assert_is_instance(tmp, dict)
        assert_in(self.test_option_s, tmp.keys())
        assert_in(self.test_option_b, tmp.keys())

    def test_get_config_section_option(self):
        """ CONFIG (CLIENT): Retrieve configuration option only """
        tmp = self.c.get_config(self.test_section_1, self.test_option_s)
        assert_equal(tmp, self.test_option_sv)
Exemplo n.º 6
0
class TestConfigClients:

    @classmethod
    def setupClass(self):
        self.c = ConfigClient()
        self.test_section_1 = str(generate_uuid())
        self.test_section_2 = str(generate_uuid())
        self.test_option_s = 'string'
        self.test_option_b = 'bool'
        self.test_option_i = 'int'
        self.test_option_f = 'float'
        self.test_option_sv = 'iddqd'
        self.test_option_bv = 'True'
        self.test_option_iv = '543210'
        self.test_option_fv = '3.1415'
        self.c.set_config_option(self.test_section_1, self.test_option_s, self.test_option_sv)
        self.c.set_config_option(self.test_section_1, self.test_option_b, self.test_option_bv)
        self.c.set_config_option(self.test_section_2, self.test_option_i, self.test_option_iv)
        self.c.set_config_option(self.test_section_2, self.test_option_f, self.test_option_fv)

    @classmethod
    def tearDownClass(self):
        self.c.delete_config_option(self.test_section_1, self.test_option_s)
        self.c.delete_config_option(self.test_section_1, self.test_option_b)
        self.c.delete_config_option(self.test_section_2, self.test_option_i)
        self.c.delete_config_option(self.test_section_2, self.test_option_f)

    def test_get_config_all(self):
        """ CONFIG (CLIENT): Retrieve configuration values and check for correctness """
        tmp = self.c.get_config(None, None)
        assert_is_instance(tmp, dict)
        assert_in(self.test_section_1, tmp.keys())
        assert_in(self.test_option_s, tmp[self.test_section_1])
        assert_in(self.test_option_b, tmp[self.test_section_1])
        assert_equal(self.test_option_sv, tmp[self.test_section_1][self.test_option_s])
        assert_true(tmp[self.test_section_1][self.test_option_b])
        assert_in(self.test_option_i, tmp[self.test_section_2])
        assert_in(self.test_option_f, tmp[self.test_section_2])
        assert_equal(543210, tmp[self.test_section_2][self.test_option_i])
        assert_equal(3.1415, tmp[self.test_section_2][self.test_option_f])

    def test_get_config_section(self):
        """ CONFIG (CLIENT): Retrieve configuration section only """
        tmp = self.c.get_config(self.test_section_1, None)
        assert_is_instance(tmp, dict)
        assert_in(self.test_option_s, tmp.keys())
        assert_in(self.test_option_b, tmp.keys())

    def test_get_config_section_option(self):
        """ CONFIG (CLIENT): Retrieve configuration option only """
        tmp = self.c.get_config(self.test_section_1, self.test_option_s)
        assert_equal(tmp, self.test_option_sv)
Exemplo n.º 7
0
class TestConfigClients(unittest.TestCase):
    def setUp(self):
        self.c = ConfigClient()
        self.test_section_1 = str(generate_uuid())
        self.test_section_2 = str(generate_uuid())
        self.test_option_s = 'string'
        self.test_option_b = 'bool'
        self.test_option_i = 'int'
        self.test_option_f = 'float'
        self.test_option_sv = 'iddqd'
        self.test_option_bv = 'True'
        self.test_option_iv = '543210'
        self.test_option_fv = '3.1415'
        self.c.set_config_option(self.test_section_1, self.test_option_s,
                                 self.test_option_sv)
        self.c.set_config_option(self.test_section_1, self.test_option_b,
                                 self.test_option_bv)
        self.c.set_config_option(self.test_section_2, self.test_option_i,
                                 self.test_option_iv)
        self.c.set_config_option(self.test_section_2, self.test_option_f,
                                 self.test_option_fv)

    def tearDown(self):
        self.c = None

    def test_get_config_all(self):
        """ CONFIG (CLIENT): Retrieve configuration values and check for correctness """
        tmp = self.c.get_config(None, None)
        assert isinstance(tmp, dict)
        assert self.test_section_1 in tmp.keys()
        assert self.test_option_s in tmp[self.test_section_1]
        assert self.test_option_b in tmp[self.test_section_1]
        assert self.test_option_sv == tmp[self.test_section_1][
            self.test_option_s]
        assert tmp[self.test_section_1][self.test_option_b]
        assert self.test_option_i in tmp[self.test_section_2]
        assert self.test_option_f in tmp[self.test_section_2]
        assert 543210 == tmp[self.test_section_2][self.test_option_i]
        assert 3.1415 == tmp[self.test_section_2][self.test_option_f]

    def test_get_config_section(self):
        """ CONFIG (CLIENT): Retrieve configuration section only """
        tmp = self.c.get_config(self.test_section_1, None)
        assert isinstance(tmp, dict)
        assert self.test_option_s in tmp.keys()
        assert self.test_option_b in tmp.keys()

    def test_get_config_section_option(self):
        """ CONFIG (CLIENT): Retrieve configuration option only """
        tmp = self.c.get_config(self.test_section_1, self.test_option_s)
        assert tmp == self.test_option_sv

        with pytest.raises(exception.ConfigNotFound):
            self.c.get_config(self.test_section_1, 'no_option')

    def test_set_and_get_config_value_special_strings(self):
        for test_option_description, option_value in [
            ('dot', '.'),
            ('slash', '/'),
            ('aPath', 'a/b/c/../'),
            ('percentEncodedSpecialChar', '%2E'),
            ('urlParameters', 'a?x=y'),
        ]:
            self.c.set_config_option(self.test_section_1,
                                     test_option_description, option_value)
            retrieved_value = self.c.get_config(self.test_section_1,
                                                test_option_description)
            assert retrieved_value == option_value

    def test_set_config_option_via_deprecated_url(self):
        """
        The format of the /config endpoint was recently changed, but we still support the old
        format for API calls for the transition period.
        TODO: remove this test
        """
        self.c.set_config_option(self.test_section_1,
                                 self.test_option_s + 'ViaUrl',
                                 self.test_option_sv,
                                 use_body_for_params=False)
        self.c.set_config_option(self.test_section_1,
                                 self.test_option_b + 'ViaUrl',
                                 self.test_option_bv,
                                 use_body_for_params=False)
        self.c.set_config_option(self.test_section_2,
                                 self.test_option_i + 'ViaUrl',
                                 self.test_option_iv,
                                 use_body_for_params=False)
        self.c.set_config_option(self.test_section_2,
                                 self.test_option_f + 'ViaUrl',
                                 self.test_option_fv,
                                 use_body_for_params=False)
        tmp = self.c.get_config(None, None)
        assert self.test_option_s + 'ViaUrl' in tmp[self.test_section_1]
        assert self.test_option_b + 'ViaUrl' in tmp[self.test_section_1]
        assert self.test_option_i + 'ViaUrl' in tmp[self.test_section_2]
        assert self.test_option_f + 'ViaUrl' in tmp[self.test_section_2]