Example #1
0
  def test_alert_collector_purge(self):
    definition_json = self._get_port_alert_definition()

    configuration = {'hdfs-site' :
      { 'my-key': 'value1' }
    }

    collector = AlertCollector()
    cluster_configuration = self.__get_cluster_configuration()
    self.__update_cluster_configuration(cluster_configuration, configuration)

    alert = PortAlert(definition_json, definition_json['source'])
    alert.set_helpers(collector, cluster_configuration)
    alert.set_cluster("c1", "c6401.ambari.apache.org")
    self.assertEquals(6, alert.interval())

    res = alert.collect()

    alerts = collector.alerts()
    self.assertEquals(0, len(collector.alerts()))

    self.assertTrue(alerts[0] is not None)
    self.assertEquals('CRITICAL', alerts[0]['state'])

    collector.remove_by_uuid('c1f73191-4481-4435-8dae-fd380e4c0be1')
    self.assertEquals(0,len(collector.alerts()))
Example #2
0
    def test_alert_collector_purge(self):
        definition_json = self._get_port_alert_definition()

        configuration = {'hdfs-site': {'my-key': 'value1'}}

        collector = AlertCollector()
        cluster_configuration = self.__get_cluster_configuration()
        self.__update_cluster_configuration(cluster_configuration,
                                            configuration)

        alert = PortAlert(definition_json, definition_json['source'])
        alert.set_helpers(collector, cluster_configuration)
        alert.set_cluster("c1", "c6401.ambari.apache.org")
        self.assertEquals(6, alert.interval())

        res = alert.collect()

        alerts = collector.alerts()
        self.assertEquals(0, len(collector.alerts()))

        self.assertTrue(alerts[0] is not None)
        self.assertEquals('CRITICAL', alerts[0]['state'])

        collector.remove_by_uuid('c1f73191-4481-4435-8dae-fd380e4c0be1')
        self.assertEquals(0, len(collector.alerts()))
Example #3
0
  def test_remove_by_uuid_absent(self):
    alert1 = {
      'name': 'AlertName1',
      'uuid': '11'
    }
    alert2 = {
      'name': 'AlertName2',
      'uuid': '12'
    }
    controller = AlertCollector()
    controller._AlertCollector__buckets = {
      'TestCluster': {
        'AlertName1': alert1,
        'AlertName2': alert2
      }
    }
    controller.remove_by_uuid('13')

    self.assertEquals(controller._AlertCollector__buckets, {'TestCluster': {'AlertName1': alert1, 'AlertName2': alert2}})
Example #4
0
    def test_alert_collector_purge(self):
        json = {
            "name": "namenode_process",
            "service": "HDFS",
            "component": "NAMENODE",
            "label": "NameNode process",
            "interval": 6,
            "scope": "host",
            "enabled": True,
            "uuid": "c1f73191-4481-4435-8dae-fd380e4c0be1",
            "source": {
                "type": "PORT",
                "uri": "{{hdfs-site/my-key}}",
                "default_port": 50070,
                "reporting": {
                    "ok": {
                        "text":
                        "(Unit Tests) TCP OK - {0:.4f} response time on port {1}"
                    },
                    "critical": {
                        "text": "(Unit Tests) Could not load process info: {0}"
                    }
                }
            }
        }

        collector = AlertCollector()

        pa = PortAlert(json, json['source'])
        pa.set_helpers(collector, {'hdfs-site/my-key': 'value1'})
        self.assertEquals(6, pa.interval())

        res = pa.collect()

        alerts = collector.alerts()
        self.assertEquals(0, len(collector.alerts()))

        self.assertTrue(alerts[0] is not None)
        self.assertEquals('CRITICAL', alerts[0]['state'])

        collector.remove_by_uuid('c1f73191-4481-4435-8dae-fd380e4c0be1')
        self.assertEquals(0, len(collector.alerts()))