def update_message_visibility_timeout(queuename, receipt_handle, visibility_timeout):
    """
    Delete a message in given queue using the given receipt_handle, which must match the currently outstanding handle for the message.

    :param queuename:
    :param receipt_handle:
    :return:
    """
    request_inputs = anchore_engine.apis.do_request_prep(
        connexion.request, default_params={}
    )
    try:
        result = simplequeue.update_visibility_timeout(
            queuename, receipt_handle, visibility_timeout
        )
        if result:
            return_object = result
            httpcode = 200
        else:
            httpcode = 400
            return_object = None
    except Exception as err:
        return_object = str(err)
        httpcode = 500

    return return_object, httpcode
Ejemplo n.º 2
0
    def test_visibility_timeout(self):
        simplequeue.enqueue(self.multi_queue, {'key00001': 'value0001'})

        msg = simplequeue.dequeue(self.multi_queue, visibility_timeout=5)
        approx_timeout = datetime.datetime.utcnow() + datetime.timedelta(
            seconds=5)

        self.assertLessEqual(msg['visible_at'], approx_timeout)
        self.assertGreaterEqual(
            msg['visible_at'], approx_timeout + datetime.timedelta(seconds=-1))

        print('Updating timeout: {}'.format(msg['visible_at'].isoformat()))
        ts = simplequeue.update_visibility_timeout(
            self.multi_queue,
            receipt_handle=msg['receipt_handle'],
            visibility_timeout=20)
        print('Updated timeout: {}'.format(ts))
        self.assertIsNotNone(ts)
        simplequeue.delete_msg(self.multi_queue,
                               receipt_handle=msg['receipt_handle'])
Ejemplo n.º 3
0
def test_visibility_timeout(test_qs):
    simplequeue.enqueue(multi_queue, {'key00001': 'value0001'})

    msg = simplequeue.dequeue(multi_queue, visibility_timeout=5)
    max_approx_timeout = datetime.datetime.utcnow() + datetime.timedelta(
        seconds=5)

    min_approx_timeout = max_approx_timeout + datetime.timedelta(seconds=-1)
    assert min_approx_timeout <= msg[
        'visible_at'] <= max_approx_timeout, 'Msg visible time, {}, outside expected range {} - {}'.format(
            msg.get('visible_at'), min_approx_timeout, max_approx_timeout)

    logger.info('Updating timeout: {}'.format(msg['visible_at'].isoformat()))
    ts = simplequeue.update_visibility_timeout(
        multi_queue,
        receipt_handle=msg['receipt_handle'],
        visibility_timeout=20)

    logger.info('Updated timeout: {}'.format(ts))
    assert ts is not None, 'Expected a non-None value, got None for updated timeout after viz timeout update'

    simplequeue.delete_msg(multi_queue, receipt_handle=msg['receipt_handle'])
Ejemplo n.º 4
0
def test_visibility_timeout(test_qs):
    simplequeue.enqueue(multi_queue, {"key00001": "value0001"})

    msg = simplequeue.dequeue(multi_queue, visibility_timeout=5)
    max_approx_timeout = datetime.datetime.utcnow() + datetime.timedelta(
        seconds=5)

    min_approx_timeout = max_approx_timeout + datetime.timedelta(seconds=-1)
    assert (min_approx_timeout <= msg["visible_at"] <= max_approx_timeout
            ), "Msg visible time, {}, outside expected range {} - {}".format(
                msg.get("visible_at"), min_approx_timeout, max_approx_timeout)

    logger.info("Updating timeout: {}".format(msg["visible_at"].isoformat()))
    ts = simplequeue.update_visibility_timeout(
        multi_queue,
        receipt_handle=msg["receipt_handle"],
        visibility_timeout=20)

    logger.info("Updated timeout: {}".format(ts))
    assert (
        ts is not None
    ), "Expected a non-None value, got None for updated timeout after viz timeout update"

    simplequeue.delete_msg(multi_queue, receipt_handle=msg["receipt_handle"])