Esempio n. 1
0
    def test_read_write_component(self):
        config = AmbariConfig().getConfig()
        tmpdir = tempfile.gettempdir()
        config.set('agent', 'prefix', tmpdir)

        tags1 = {"global": "version1", "core-site": "version2"}
        handler = ActualConfigHandler(config, {})
        handler.write_actual(tags1)
        handler.write_actual_component('FOO', tags1)

        output1 = handler.read_actual_component('FOO')
        output2 = handler.read_actual_component('GOO')

        self.assertEquals(tags1, output1)
        self.assertEquals(None, output2)

        tags2 = {"global": "version1", "core-site": "version2"}
        handler.write_actual(tags2)

        output3 = handler.read_actual()
        output4 = handler.read_actual_component('FOO')
        self.assertEquals(tags2, output3)
        self.assertEquals(tags1, output4)
        os.remove(
            os.path.join(tmpdir, "FOO_" + ActualConfigHandler.CONFIG_NAME))
        os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
  def test_read_write_component(self):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)

    tags1 = { "global": "version1", "core-site": "version2" }
    handler = ActualConfigHandler(config, {})
    handler.write_actual(tags1)
    handler.write_actual_component('FOO', tags1)

    output1 = handler.read_actual_component('FOO')
    output2 = handler.read_actual_component('GOO')

    self.assertEquals(tags1, output1)
    self.assertEquals(None, output2)
    
    tags2 = { "global": "version1", "core-site": "version2" }
    handler.write_actual(tags2)

    output3 = handler.read_actual()
    output4 = handler.read_actual_component('FOO')
    self.assertEquals(tags2, output3)
    self.assertEquals(tags1, output4)
    os.remove(os.path.join(tmpdir, "FOO_" + ActualConfigHandler.CONFIG_NAME))
    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
Esempio n. 3
0
    def test_read_write(self):
        config = AmbariConfig().getConfig()
        tmpdir = tempfile.gettempdir()
        config.set('agent', 'prefix', tmpdir)

        tags = {"global": "version1", "core-site": "version2"}
        handler = ActualConfigHandler(config, tags)
        handler.write_actual(tags)
        output = handler.read_actual()
        self.assertEquals(tags, output)
        os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
  def test_read_write(self):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)

    tags = { "global": "version1", "core-site": "version2" }
    handler = ActualConfigHandler(config, tags)
    handler.write_actual(tags)
    output = handler.read_actual()
    self.assertEquals(tags, output)
    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
  def test_read_empty(self):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)
    handler = ActualConfigHandler(config, {})

    conf_file = open(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME), 'w')
    conf_file.write("")
    conf_file.close()
    
    output = handler.read_actual()
    self.assertEquals(None, output)
    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))