Exemplo n.º 1
0
def with_auklet_and_mqtt(get_certs_mock, update_limits_mock):
    """
    With a little help from mock, this test will push data that
    would normally go to the front end, to a MQTT container created locally.
    """
    print("\n\nStarting benchmark tests with the Auklet Agent and MQTT...")

    def _load_conf(self):
        self.brokers = "mqtt"
        self.port = 1883

    def create_producer(self):
        # Make non SSL producer for testing
        self.producer = mqtt.Client()
        self.producer.on_disconnect = self.on_disconnect
        self.producer.connect_async("mqtt", 1883)
        self.producer.loop_start()

    def _get_conf(self):
        return True

    def register_device(self):
        return True

    update_limits_mock.return_value = 10000
    get_certs_mock.return_value = True

    conf_patcher = patch('auklet.broker.MQTTClient._read_from_conf',
                         new=_load_conf)
    producer_patcher = patch('auklet.broker.MQTTClient.create_producer',
                             new=create_producer)
    get_conf_patcher = patch('auklet.broker.MQTTClient._get_conf',
                             new=_get_conf)
    register_device_patcher = patch(
        'auklet.monitoring.processing.Client._register_device',
        new=register_device)
    conf_patcher.start()
    producer_patcher.start()
    get_conf_patcher.start()
    register_device_patcher.start()

    auklet_monitoring = Monitoring("", "")
    auklet_monitoring.start()
    base.start(state="WithAukletMQTT")
    auklet_monitoring.stop()

    conf_patcher.stop()
    producer_patcher.stop()
Exemplo n.º 2
0
def without_auklet():
    """
    Runs tests for a baseline number on how long the tests should take.
    """
    print("\n\nStarting benchmark tests without the Auklet Agent...")
    base.start(state="WithoutAuklet")