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

        tags1 = {"global": "version1", "core-site": "version2"}
        tags2 = {"global": "version33", "core-site": "version33"}
        clientsToUpdateConfigs1 = ["*"]
        handler = ActualConfigHandler(config, {})
        handler.write_actual_component('HDFS_CLIENT', tags1)
        handler.write_actual_component('HBASE_CLIENT', tags1)
        self.assertEquals(tags1, handler.read_actual_component('HDFS_CLIENT'))
        self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))
        handler.write_actual_component('DATANODE', tags2)
        self.assertEquals(tags2, handler.read_actual_component('DATANODE'))
        self.assertEquals(tags1, handler.read_actual_component('HDFS_CLIENT'))
        handler.write_client_components('HDFS', tags2, clientsToUpdateConfigs1)
        self.assertEquals(tags2, handler.read_actual_component('HDFS_CLIENT'))
        self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))

        os.remove(
            os.path.join(tmpdir,
                         "DATANODE_" + ActualConfigHandler.CONFIG_NAME))
        os.remove(
            os.path.join(tmpdir,
                         "HBASE_CLIENT_" + ActualConfigHandler.CONFIG_NAME))
        os.remove(
            os.path.join(tmpdir,
                         "HDFS_CLIENT_" + ActualConfigHandler.CONFIG_NAME))
Exemplo n.º 2
0
    def test_write_empty_client_components(self, write_file_mock):
        config = AmbariConfig().getConfig()
        tmpdir = tempfile.gettempdir()
        config.set('agent', 'prefix', tmpdir)

        tags0 = {"global": "version0", "core-site": "version0"}
        tags1 = {"global": "version1", "core-site": "version2"}
        tags2 = {"global": "version33", "core-site": "version33"}
        clientsToUpdateConfigs1 = []
        configTags = {'HDFS_CLIENT': tags0, 'HBASE_CLIENT': tags1}
        handler = ActualConfigHandler(config, configTags)
        self.assertEquals(tags0, handler.read_actual_component('HDFS_CLIENT'))
        self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))
        handler.write_client_components('HDFS', tags2, clientsToUpdateConfigs1)
        self.assertEquals(tags0, handler.read_actual_component('HDFS_CLIENT'))
        self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))
        self.assertFalse(write_file_mock.called)
  def test_write_empty_client_components(self, write_file_mock):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)

    tags0 = {"global": "version0", "core-site": "version0"}
    tags1 = {"global": "version1", "core-site": "version2"}
    tags2 = {"global": "version33", "core-site": "version33"}
    clientsToUpdateConfigs1 = []
    configTags = {'HDFS_CLIENT': tags0, 'HBASE_CLIENT': tags1}
    handler = ActualConfigHandler(config, configTags)
    self.assertEquals(tags0, handler.read_actual_component('HDFS_CLIENT'))
    self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))
    handler.write_client_components('HDFS', tags2, clientsToUpdateConfigs1)
    self.assertEquals(tags0, handler.read_actual_component('HDFS_CLIENT'))
    self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))
    self.assertFalse(write_file_mock.called)
Exemplo n.º 4
0
  def test_write_actual_component_and_client_components(self):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)

    tags1 = { "global": "version1", "core-site": "version2" }
    tags2 = { "global": "version33", "core-site": "version33" }
    handler = ActualConfigHandler(config, {})
    handler.write_actual_component('HDFS_CLIENT', tags1)
    handler.write_actual_component('HBASE_CLIENT', tags1)
    self.assertEquals(tags1, handler.read_actual_component('HDFS_CLIENT'))
    self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))
    handler.write_actual_component('DATANODE', tags2)
    self.assertEquals(tags2, handler.read_actual_component('DATANODE'))
    self.assertEquals(tags1, handler.read_actual_component('HDFS_CLIENT'))
    handler.write_client_components('HDFS', tags2)
    self.assertEquals(tags2, handler.read_actual_component('HDFS_CLIENT'))
    self.assertEquals(tags1, handler.read_actual_component('HBASE_CLIENT'))

    os.remove(os.path.join(tmpdir, "DATANODE_" + ActualConfigHandler.CONFIG_NAME))
    os.remove(os.path.join(tmpdir, "HBASE_CLIENT_" + ActualConfigHandler.CONFIG_NAME))
    os.remove(os.path.join(tmpdir, "HDFS_CLIENT_" + ActualConfigHandler.CONFIG_NAME))