Commit Graph

23 Commits

Author SHA1 Message Date
Xing Zhang e0937b1f09
Use processutils to fix TypeError in subprocess
Calling processutils.execute() other than subprocess to
fix bytes-like and str issue in python3.

Closes-bug: #2029392
Change-Id: I16436aa19da2cf53951c9ad27bca14033194651a
2023-08-21 00:09:40 +08:00
Xing Zhang 2abe46ae21 Update json module to jsonutils
oslo project provide jsonutils, the others project use it
this PS to update the json moudule to oslo jsonutils.

Closes-bug: #1966401
Change-Id: I9cbe9f03c32e4f42822def727aa2871d502641f4
2022-03-28 09:59:26 +00:00
Sean McGinnis d949c970ad Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I5f86837c601eb64dff3c370decd2670f2a6276b6
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2021-01-13 09:05:59 +08:00
changyufei e1c62707d3 Using smtplib for Zaqar mail delivery
Add the new way which using smtplib for Zaqar email subscription
notification.

An example file for configure mail content and SMTP information
is added as well.

Change-Id: I4a1310b54bec38263981792ba0220ae516bea179
Implements: blueprint zaqar-email-delivery
2018-08-21 01:06:07 +00:00
gecong1973 ef8631899e Add more backoff functions
This patch introduces more retry backoff function the delivery 
retry policy into Zaqar. It will work when Zaqar failed to send 
the notification to the subscriber. Users can define the retry 
backoff function in the options of subscription or metadata 
of queue.

Change-Id: I0bffd9249f8a0d466ecea1ac36d8adc37b742238
Implement: blueprint support-more-backoff-functions
2017-10-24 01:01:47 +00:00
wanghao 900bdbe3d9 Notification Delivery Policy
This patch introduces the delivery retry policy into Zaqar.
It will work when the notification sent from Zaqar to the
subscriber failed.
User can define the retry policy in the options of subscription or
metadata of queue.

Change-Id: I1a74c2d5b69fb82826c303468099db34b3e41b5b
Implements: bp notification-delivery-policy
2017-08-09 08:58:39 +08:00
wanghao 4778f708fa Subscription Confirmation Support-3
This patch is the third part of subscription confirmation feature.
Support to send email to subscriber if confirmation is needed.

Change-Id: I230f5c7fbc9d19554bbcf34ce9b2f3b14230321b
Implements: blueprint subscription-confirmation-support
2017-02-15 18:03:41 +08:00
Fei Long Wang 8e32ee254a Fix wrong value of require_confirmation
Currently, Zaqar's notifier driver will be initialized without
any parameter when creating the subscription controller. As a
result, default value 'False' will be used instead of getting
the correct value from conf. This patch will fix this by getting
the option from conf.

Closes-Bug: #1655812

Change-Id: I31ac8c3d374b3ea38d035f1012571e6c49a18b87
2017-01-13 10:05:09 +13:00
Fei Long Wang c19d0a0153 Don't send confirmation notification if it's not enabled
Currently even though the 'require_confirmation' option is False,
Zaqar will send the confirmation notification anyway, which is
breaking the backward compatibility. This patch will fix it and
add a test for that.

Closes-Bug: #1633222

Change-Id: I2d6363feab90ff737684d5c1d903c2c2d7abe106
2016-11-08 17:25:36 +13:00
wangxiyuan 69c799734b Subscription Confirmation Support-1
The subscription confirmation feature will contain four patches:
1. webhook with mongoDB
2. email with mongoDB
3. webhook with redis
4. email with redis

This patch is the first part of subscription confirmation feature for
webhook with MongoDB. Others will be achieved in follow patches.

This patch did:
1. Add v2/queue/<queue_name>/subscription/<subscription_id>/confirm
endpoint.
2. Add a new config option: "require_confirmation".
3. Add a new property "confirmed" to subscription resource for
MongoDB driver.
4. Add a new policy "subscription: confirm".
5. Add a new property "message type" for notification.
6. Use the pre-signed url in confirm request.
8. Re-use POST subscription to allow re-confirm.
9. Update notification for webhook subscription with mongoDB.
10. Support unsubscrib the subscription
11. Add tests for the feature.
12. Add doc and sample.
Docimpact
APIimpact

Change-Id: Id38d4a5b4f9303b12e22e2b5c248facda4c00143
Implements: blueprint subscription-confirmation-support
2016-08-16 17:23:45 +08:00
Thomas Herve 51604b4954 Add a trust notifier task
This adds the ability to send keystone authentified notifications using
trusts. To do so, you specify the posted URL with the "trust+" prefix,
and Zaqar will create and store a trust when subscribing to a queue, if
the trust not provided in the subscription options

It also add a capability to the webhook task to be able to send more
structured data in the notification, allowing to include the Zaqar
message in the data.

blueprint mistral-notifications
DocImpact
Change-Id: I12b9c1b34cdd220fcf1bdc2720043d4a8f75dc85
2016-07-07 08:58:42 +02:00
Thomas Herve 61100fec33 Fix subscription limit per queue
Query for all subscriptions on a given queue by taking into account the
returned marker, if any.

Change-Id: I6b03dd93cabc76d1c91041a896fbb30ac08032f1
Closes-Bug: #1590173
2016-06-08 11:33:45 +02:00
Eva Balycheva 1a0e8e719a Add queue name to notifications
Currently notifications from Zaqar are very consise and simply represent
messages. Example:
{'body': 'somemessage', 'ttl': 60}

But subscribers are likely to want queue information inside
notifications, if they subscribe to multiple queues.

The only option for subscribers to know from which queue each
notification was sent is to listen on many ports, and make each port
correspond to each particular queue, but it's very inconvenient.

This patch adds queue name to each notification to make notifications
look like this:
{'body': 'somemessage', 'ttl': 60, 'queue_name': 'somequeue'}

Since we only add a new key to JSON dictionary, this patch is backward
compatible.

This patch adds new test case "test_proper_notification_data".
It also modifies "test_mailto" and "test_webhook" test cases, so they
consider undeterministic behavior of "json.dumps" function, which
often serializes dictionaries in different order, making test assertions
sometimes fail.

Closes-Bug: 1535811
Change-Id: Ied5fa24fd973043eda643e09aac1d6c0f1500892
2016-02-11 00:02:13 +03:00
MD NADEEM 6c89270d0e Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

This patch fix the issue in the modules zaqar/tests/unit/storage/
and zaqar/tests/unit/notification/ modules.
Partial-Bug: #1259292

Change-Id: Iac8987782d6a21a28a0503ea7cd4ec85622f7996
2015-09-29 17:18:51 +09:00
Fei Long Wang 8ce9d3eaef Add email driver for notification
DocImpact
blueprint email-notification

Change-Id: Ib09f7d3b47c3a4479da7fb9b9e2acceb691975ac
2015-09-03 11:46:00 +02:00
Thomas Herve a641baa978 Use thread executor all the time for notifier
Trying to use the greenlet executor doesn't work when we don't use
taskflow, as nothing is doing the monkeypatching. Let's use threads for
now.

Closes-Bug: #1491326

Change-Id: Ic59f75a883eff1d4f0e4683f9d8ea4d943ad7aac
2015-09-02 12:29:10 +02:00
Fei Long Wang a128dbc3ac Refactor notification framework
1. Using stevedore to load the task instance
2. Pass in messages list to task instead of single message

Change-Id: Ie8a475b8c2530bfd0fb2d39929c1611288c601fe
2015-08-06 21:22:31 +12:00
Jenkins 55f1e3dbd1 Merge "Skip tasks run when there is no subscriber" 2015-08-05 02:49:19 +00:00
Thomas Herve c4aad3b3e5 Skip tasks run when there is no subscriber
This skips taskflow launch when the notifier is called for a queue
without subscriber, preventing a traceback.

Change-Id: I63571a163efae523e52798fe4039f48859fa1fee
Closes-Bug: #1478841
2015-07-28 15:08:35 +02:00
Thomas Herve 2b0baccc50 Send message notifications as json
Force serialization in notifications to be JSON instead of letting
requests go with urlencoded payload.

Change-Id: Ia9647f9c370b94c822dae1a57cfc635e137e20db
Closes-Bug: #1477111
2015-07-22 14:39:06 +02:00
Thomas Herve 93734a4c14 Move all remaining unit tests out of tests/
This moves all unit tests out of the tests directory. It also fixies
notification tests which didn't run previously.

blueprint tests-refactoring

Change-Id: Ia69db76f06391f3db4a88565a589b0627bf17b85
2015-06-12 09:26:44 +02:00
Fei Long Wang b7a66c971a Fix duplicated test cases of notifier
Change-Id: I7a2da87e55fab50ffd2313b649cf4be3a7d50783
2015-04-27 23:20:40 +12:00
Fei Long Wang 99fe10e49c Implement webhook notifier driver
This patch adds a notifier driver for webhook and the basic
task management code with taskflow.

DocImpact
Partially-Implements blueprint: notifications

Change-Id: I2727726cc57f03fb94184653452223f00fcf3d0c
2015-04-01 14:27:35 +13:00