Exemplo n.º 1
0
    def __init__(self, host, port,
                 failed_tests_counter='failed',
                 passed_tests_counter='passed',
                 prefix='alarmageddon',
                 priority_threshold=None,
                 environment=None):
        if not host:
            raise ValueError("host parameter is required")

        logger.debug("Constructing publisher with host:{}, port:{}, failed counter:{},"
                "passed counter:{}, prefix:{}, priority_threshold:{}, environment:{}"
                .format(host, port, failed_tests_counter, passed_tests_counter,
                    prefix, priority_threshold, environment))

        Publisher.__init__(self, "Graphite",
                           priority_threshold=priority_threshold,
                           environment=environment)

        self._prefix = prefix
        self._host = host
        if port is not None:
            self._port = int(port)
        else:
            self._port = None

        self._failed_tests_counter = failed_tests_counter
        self._passed_tests_counter = passed_tests_counter

        self._graphite = statsd.StatsClient(
            host=self._host, prefix=self._prefix, port=self._port)
Exemplo n.º 2
0
    def __init__(self,
                 api_end_point,
                 api_token,
                 environment,
                 room_name,
                 priority_threshold=None):

        logger.debug(
            "Constructing publisher with endpoint:{}, token:{}, room name:{},"
            "priority_threshold:{}, environment:{}".format(
                api_end_point, api_token, room_name, priority_threshold,
                environment))

        if not api_end_point:
            raise ValueError("api_end_point parameter is required")
        if not api_token:
            raise ValueError("api_token parameter is required")
        if not environment:
            raise ValueError("environment parameter is required")
        if not room_name:
            raise ValueError("room_name parameter is required")

        Publisher.__init__(self,
                           "HipChat: {0}".format(room_name),
                           priority_threshold=priority_threshold,
                           environment=environment)

        self._api_token = api_token
        self._api_end_point = api_end_point
        self._room_name = room_name
Exemplo n.º 3
0
    def __init__(self, url=None, success_url=None, failure_url=None,
                 method="POST", headers=None, auth=None, attempts=1,
                 retry_after_seconds=2, timeout_seconds=5,
                 publish_successes=False, expected_status_code=200,
                 name=None, priority_threshold=None):

        Publisher.__init__(self, name or "HttpPublisher", priority_threshold)

        self._success_url = success_url or url
        if not self._success_url:
            raise ValueError("either success_url or url parameter is required")

        self._failure_url = failure_url or url
        if not self._failure_url:
            raise ValueError("either failure_url or url parameter is required")

        self._publish_successes = (success_url is not None) or publish_successes

        self._method = method
        if not self._method:
            raise ValueError("method parameter is requried")

        self._headers = headers
        self._auth = auth

        self._attempts = attempts
        if self._attempts <= 0:
            raise ValueError("attempts parameter must be at least one")

        self._retry_after_seconds = retry_after_seconds
        if self._retry_after_seconds < 0:
            raise ValueError("retry_after_seconds parameter must be positive")

        self._timeout_seconds = timeout_seconds
        self._expected_status_code = expected_status_code
Exemplo n.º 4
0
    def __init__(self, filename, priority_threshold=None):
        if not filename:
            raise ValueError("filename parameter is required")

        Publisher.__init__(self, "JUnit", priority_threshold)

        self.filename = filename
Exemplo n.º 5
0
    def __init__(self,
                 sender_address,
                 recipient_addresses,
                 host=None,
                 port=None,
                 name='EmailPublisher',
                 priority_threshold=None,
                 connect_timeout_seconds=10,
                 environment=None):

        Publisher.__init__(self,
                           name,
                           priority_threshold=priority_threshold,
                           environment=environment)

        # Set the initial replacement context to the defaults.
        # Overrides will be applied to this dictionary individually.
        self._connect_timeout = connect_timeout_seconds
        self.sender_address = None
        self.recipient_addresses = []
        if sender_address:
            self.sender_address = self.configure_sender(sender_address)
        if recipient_addresses:
            self.recipient_addresses =\
                self.configure_recipients(recipient_addresses)
        self.host = host
        self.port = port
Exemplo n.º 6
0
def test_dry_run():
    validations = [Validation("low", Priority.LOW),
                   Validation("normal", Priority.NORMAL),
                   Validation("critical", Priority.CRITICAL)]

    publishers = [Publisher("low_pub", priority_threshold=Priority.LOW),
                  Publisher("norm_pub", priority_threshold=Priority.NORMAL),
                  Publisher("crit_pub", priority_threshold=Priority.CRITICAL)]

    associations = run._compute_dry_run(validations, publishers)
    lows = associations[publishers[0]]
    norms = associations[publishers[1]]
    crits = associations[publishers[2]]
    assert len(lows) == 3
    assert len(norms) == 2
    assert len(crits) == 1

    assert validations[0] in lows
    assert validations[1] in lows
    assert validations[2] in lows

    assert validations[0] not in norms
    assert validations[1] in norms
    assert validations[2] in norms

    assert validations[0] not in crits
    assert validations[1] not in crits
    assert validations[2] in crits
Exemplo n.º 7
0
    def __init__(self, api_end_point, api_key, priority_threshold=None):
        if not api_end_point:
            raise ValueError("api_end_point parameter is required")
        if not api_key:
            raise ValueError("api_key parameter is required")

        Publisher.__init__(self, "PagerDuty", priority_threshold)

        self._api_key = api_key
        self._api_end_point = api_end_point
Exemplo n.º 8
0
    def __init__(self, hook_url, environment, priority_threshold=None):
        if not hook_url:
            raise ValueError("hook_url parameter is required")
        if not environment:
            raise ValueError("environment parameter is required")

        Publisher.__init__(self, "Slack", priority_threshold)

        self._hook_url = hook_url
        self._environment = environment
Exemplo n.º 9
0
    def __init__(self, hook_url, environment=None, priority_threshold=None):

        logger.debug("Constructing publisher with url:{}, priority_threshold:{}, environment:()"
                .format(hook_url, priority_threshold, environment))

        if not hook_url:
            raise ValueError("hook_url parameter is required")

        Publisher.__init__(self, "Teams", priority_threshold=priority_threshold)

        self._hook_url = hook_url
Exemplo n.º 10
0
    def __init__(self, filename, priority_threshold=None,
                 environment=None):
        if not filename:
            raise ValueError("filename parameter is required")

        logger.debug("Constructing publisher with filename:{},"
                "priority_threshold:{}, environment:{}"
                .format(filename, priority_threshold, environment))

        Publisher.__init__(self, "JUnit",
                           priority_threshold=priority_threshold,
                           environment=environment)

        self.filename = filename
Exemplo n.º 11
0
    def __init__(self,
                 url=None,
                 success_url=None,
                 failure_url=None,
                 method="POST",
                 headers=None,
                 auth=None,
                 attempts=1,
                 retry_after_seconds=2,
                 timeout_seconds=5,
                 publish_successes=False,
                 expected_status_code=200,
                 name=None,
                 priority_threshold=None,
                 environment=None):

        Publisher.__init__(self,
                           name or "HttpPublisher",
                           priority_threshold=priority_threshold,
                           environment=environment)

        self._success_url = success_url or url
        if not self._success_url:
            raise ValueError("either success_url or url parameter is required")

        self._failure_url = failure_url or url
        if not self._failure_url:
            raise ValueError("either failure_url or url parameter is required")

        self._publish_successes = (success_url
                                   is not None) or publish_successes

        self._method = method
        if not self._method:
            raise ValueError("method parameter is requried")

        self._headers = headers
        self._auth = auth

        self._attempts = attempts
        if self._attempts <= 0:
            raise ValueError("attempts parameter must be at least one")

        self._retry_after_seconds = retry_after_seconds
        if self._retry_after_seconds < 0:
            raise ValueError("retry_after_seconds parameter must be positive")

        self._timeout_seconds = timeout_seconds
        self._expected_status_code = expected_status_code
Exemplo n.º 12
0
    def __init__(self, hook_url, environment, priority_threshold=None):
        logger.debug(
            "Constructing publisher with url:{}, priority_threshold:{}, environment:{}"
            .format(hook_url, priority_threshold, environment))

        if not hook_url:
            raise ValueError("hook_url parameter is required")
        if not environment:
            raise ValueError("environment parameter is required")

        Publisher.__init__(self,
                           "Slack",
                           priority_threshold=priority_threshold,
                           environment=environment)

        self._hook_url = hook_url
Exemplo n.º 13
0
    def __init__(self, api_end_point, api_key, priority_threshold=None,
                 environment=None):
        if not api_end_point:
            raise ValueError("api_end_point parameter is required")
        if not api_key:
            raise ValueError("api_key parameter is required")

        logger.debug("Constructing publisher with endpoint:{}, key:{}, priority_threshold:{}, environment:{}"
                .format(api_end_point, api_key[:5]+'...', priority_threshold, environment))

        Publisher.__init__(self, "PagerDuty",
                           priority_threshold=priority_threshold,
                           environment=environment or 'unknown')

        self._api_key = api_key
        self._api_end_point = api_end_point
Exemplo n.º 14
0
    def __init__(self, sender_address, recipient_addresses,
                 host=None, port=None, name='EmailPublisher',
                 priority_threshold=None, connect_timeout_seconds=10):

        Publisher.__init__(self, name, priority_threshold)

        # Set the initial replacement context to the defaults.
        # Overrides will be applied to this dictionary individually.
        self._connect_timeout = connect_timeout_seconds
        self.sender_address = None
        self.recipient_addresses = []
        if sender_address:
            self.sender_address = self.configure_sender(sender_address)
        if recipient_addresses:
            self.recipient_addresses =\
                self.configure_recipients(recipient_addresses)
        self.host = host
        self.port = port
Exemplo n.º 15
0
    def __init__(self, api_end_point, api_token, environment, room_name,
                 priority_threshold=None):

        if not api_end_point:
            raise ValueError("api_end_point parameter is required")
        if not api_token:
            raise ValueError("api_token parameter is required")
        if not environment:
            raise ValueError("environment parameter is required")
        if not room_name:
            raise ValueError("room_name parameter is required")

        Publisher.__init__(self, "HipChat: {0}".format(room_name),
                           priority_threshold)

        self._api_token = api_token
        self._api_end_point = api_end_point
        self._room_name = room_name
        self._environment = environment
Exemplo n.º 16
0
    def __init__(self, host, port,
                 failed_tests_counter='failed',
                 passed_tests_counter='passed',
                 prefix='alarmageddon',
                 priority_threshold=None):
        if not host:
            raise ValueError("host parameter is required")

        Publisher.__init__(self, "Graphite", priority_threshold)

        self._prefix = prefix
        self._host = host
        if port is not None:
            self._port = int(port)
        else:
            self._port = None

        self._failed_tests_counter = failed_tests_counter
        self._passed_tests_counter = passed_tests_counter

        self._graphite = statsd.StatsClient(
            host=self._host, prefix=self._prefix, port=self._port)
Exemplo n.º 17
0
    def __init__(self,
                 api_end_point,
                 api_key,
                 priority_threshold=None,
                 environment=None):
        if not api_end_point:
            raise ValueError("api_end_point parameter is required")
        if not api_key:
            raise ValueError("api_key parameter is required")

        logger.debug(
            "Constructing publisher with endpoint:{}, key:{}, priority_threshold:{}, environment:{}"
            .format(api_end_point, api_key[:5] + '...', priority_threshold,
                    environment))

        Publisher.__init__(self,
                           "PagerDuty",
                           priority_threshold=priority_threshold,
                           environment=environment or 'unknown')

        self._api_key = api_key
        self._api_end_point = api_end_point
Exemplo n.º 18
0
    def __init__(self, api_end_point, api_token, environment, room_name,
                 priority_threshold=None):

        logger.debug("Constructing publisher with endpoint:{}, token:{}, room name:{},"
                "priority_threshold:{}, environment:{}"
                .format(api_end_point, api_token, room_name,
                    priority_threshold, environment))

        if not api_end_point:
            raise ValueError("api_end_point parameter is required")
        if not api_token:
            raise ValueError("api_token parameter is required")
        if not environment:
            raise ValueError("environment parameter is required")
        if not room_name:
            raise ValueError("room_name parameter is required")

        Publisher.__init__(self, "HipChat: {0}".format(room_name),
                           priority_threshold=priority_threshold,
                           environment=environment)

        self._api_token = api_token
        self._api_end_point = api_end_point
        self._room_name = room_name