Beispiel #1
0
class TestSyslogClient(TestCase):
    DEFAULT_SD_DICT = {
        'test_project': {
            'token': 'test-token',
            'tenant': 'test-tenant'
        }
    }

    SAMPLE_SD_DICT = {'origin': {'software': 'opencafe-rsyslog'}}

    def setUp(self):
        self.client = RSyslogClient(default_sd=self.DEFAULT_SD_DICT)
        self.client.connect()

    def tearDown(self):
        self.client.close()

    def test_conversion_between_sd_dict_to_syslog_str(self):
        result = MessageHandler.sd_dict_to_syslog_str(self.SAMPLE_SD_DICT)
        self.assertEqual(result, '[origin software="opencafe-rsyslog"]')

    def test_send_basic_message(self):
        result = self.client.send(priority=1,
                                  msg='bam',
                                  sd=self.SAMPLE_SD_DICT)

        # A socket should return None if it was successful.
        self.assertIsNone(result)
Beispiel #2
0
class TestSyslogClient(TestCase):
    DEFAULT_SD_DICT = {
        'test_project': {
            'token': 'test-token',
            'tenant': 'test-tenant'
        }
    }

    SAMPLE_SD_DICT = {
        'origin': {
            'software': 'opencafe-rsyslog'
        }
    }

    def setUp(self):
        self.client = RSyslogClient(default_sd=self.DEFAULT_SD_DICT)
        self.client.connect()

    def tearDown(self):
        self.client.close()

    def test_conversion_between_sd_dict_to_syslog_str(self):
        result = MessageHandler.sd_dict_to_syslog_str(self.SAMPLE_SD_DICT)
        self.assertEqual(result, '[origin software="opencafe-rsyslog"]')

    def test_send_basic_message(self):
        result = self.client.send(priority=1, msg='bam',
                                  sd=self.SAMPLE_SD_DICT)

        # A socket should return None if it was successful.
        self.assertIsNone(result)
Beispiel #3
0
class RSyslogPublishingFixture(PublishingFixture):
    def setUp(self):
        super(RSyslogPublishingFixture, self).setUp()
        syslog_endpoint = self.correlate_config.syslog_endpoint
        tenant_info = {
            'meniscus': {
                'token': self.tenant_token,
                'tenant': self.tenant_id
            }
        }

        self.rsyslog_client = RSyslogClient(host=syslog_endpoint,
                                            default_sd=tenant_info)
        self.rsyslog_client.connect()

    def tearDown(self):
        self.rsyslog_client.close()
Beispiel #4
0
class RSyslogPublishingFixture(PublishingFixture):

    def setUp(self):
        super(RSyslogPublishingFixture, self).setUp()
        syslog_endpoint = self.correlate_config.syslog_endpoint
        tenant_info = {
            'meniscus': {
                'token': self.tenant_token, 'tenant': self.tenant_id
            }
        }

        self.rsyslog_client = RSyslogClient(host=syslog_endpoint,
                                            default_sd=tenant_info)
        self.rsyslog_client.connect()

    def tearDown(self):
        self.rsyslog_client.close()