Commit Graph

2107 Commits

Author SHA1 Message Date
Waldemar Hummer
a5727bf64a fix SQS message polling to abort after wait_seconds_timeout 2017-04-06 21:40:03 +10:00
Sean Marlow
8b9d685f1c
Add mfa device endpoints to iam backend.
- Add mfa device class
- Add mfa devices dictionary to user class
- Add responses, endpoints and tests
2017-03-27 13:13:40 -06:00
Valentín Gutiérrez
6e209bb14c Implement availability-zone filter for DescribeNetworkInterfaces 2017-03-22 14:36:20 +01:00
Steve Pulec
bba197e29f Make IAM ARNs more dynamic. Closes #663. 2017-03-19 11:58:24 -04:00
Steve Pulec
2d05f8a79a Add functionality for iam get-user with current user. Closes #480. 2017-03-19 11:09:30 -04:00
Steve Pulec
a0a205328d Cleanup SQS body encoding. Closes #458, #460. 2017-03-19 11:03:55 -04:00
Steve Pulec
f9b7a0a539 Merge pull request #872 from 2rs2ts/allow-updating-cf-tags
Allow CloudFormation stack tags to be updated
2017-03-18 14:49:48 -04:00
Andrew Garrett
6f4cb512ac Allow CloudFormation stack tags to be updated
Limitations:

* does not update the tags of the resources in the stack. that can be
implemented later.
* does not support the supposed feature of clearing tags by passing an
empty value that boto3 mentions in its documentation. I could not find
anything in the request body to indicate when an empty value was passed.
2017-03-17 23:57:57 +00:00
Steve Pulec
a6e762340d Merge pull request #867 from 2rs2ts/flexible-route53-hostedzoneid-lookup
Be flexible with Route53 Hosted Zone IDs with /hostedzone/ prefix
2017-03-16 22:55:13 -04:00
Andrew Garrett
f2b7ba03b4 Forgot that lstrip works on character sets, not substrings
I suppose this is one way to do it. I could have also split and taken
the last element. Not sure which is best. 🤔
2017-03-17 02:45:58 +00:00
Steve Pulec
c207963a86 Cleanup SNS exceptions. Closes #751. 2017-03-16 22:28:30 -04:00
Steve Pulec
e7a3f3408e Add Lambda header for invoking error. Closes #770. 2017-03-16 22:00:57 -04:00
Steve Pulec
e3bff8b926 Fix cloudformation NoValue parsing to not add attribute. Closes #870 2017-03-16 21:20:01 -04:00
Steve Pulec
042524fe80 Merge pull request #871 from mike-lerch/cpu-100-empty-queue
Prevent 100% cpu usage while SQS long polling on an empty queue
2017-03-16 20:05:18 -04:00
michael_lerch
83084bf2af Prevent 100% cpu usage while SQS long polling on an empty queue
While using moto server with a test SQS client, I noticed significant CPU usage while the client was long polling. I narrowed this down to the `receive_messages` call of the SQS service sitting in a `while True:` statement with no work to be done, thus looping forever.

To produce this issue, I do:
```
$ python3 -m venv venv
$ . ./venv/bin/activate
(venv) $ pip install moto moto[server] boto3
Collecting moto
  Downloading moto-0.4.31-py2.py3-none-any.whl (303kB)
  --snip--
(venv) $ moto_server sqs &
[1] 31727
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
(venv) $ python3
Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> client = boto3.client('sqs', region_name='us-east-1', endpoint_url='http://127.0.0.1:5000');
>>> client.create_queue(QueueName='testing')
127.0.0.1 - - [16/Mar/2017 13:34:20] "POST / HTTP/1.1" 200 -
{'QueueUrl': 'http://sqs.us-east-1.amazonaws.com/123456789012/testing', 'ResponseMetadata': {'RequestId': '7a62c49f-347e-4fc4-9331-6e8e7a96aa73', 'HTTPStatusCode': 200, 'HTTPHeaders': {'content-type': 'text/html; charset=utf-8', 'content-length': '343', 'server': 'Werkzeug/0.12.1 Python/3.6.0', 'date': 'Thu, 16 Mar 2017 20:34:20 GMT'}, 'RetryAttempts': 0}}
>>> client.receive_message(QueueUrl='http://sqs.us-east-1.amazonaws.com/123456789012/testing', MaxNumberOfMessages=10, WaitTimeSeconds=10)
```

At this point the moto server will run at 100% cpu for 10 seconds until the request times out waiting for a message. If multiple clients are continuously reconnected (as in mocking a normal sqs worker setup) the server will sit at 100% cpu indefinitely.

This pull request adds a simple sleep statement to the SQS `receive_messages` call when there are no messages to process. In doing so, the loop will be limited to executing once per 0.001 seconds when the queue is empty. The CPU usage is nearly 0% after this change.
2017-03-16 13:43:45 -07:00
Steve Pulec
a5da348fba Fix lint. 2017-03-15 23:43:48 -04:00
Steve Pulec
25e2af0320 Fix camelcase_to_underscore. Closes #767. 2017-03-15 23:39:36 -04:00
Steve Pulec
446843e756 Fix py3 s3 prefix decoding. 2017-03-15 23:13:09 -04:00
Steve Pulec
e25d1499c2 Update cloudformation for new list types. 2017-03-15 23:02:10 -04:00
Steve Pulec
3899eee648 Fix S3 filtering by unicode prefix. Closes #838 2017-03-15 22:53:27 -04:00
Steve Pulec
8a803cdbaf Better EC2 duplicate SG error. 2017-03-15 22:45:28 -04:00
Steve Pulec
5f3fbff627 Standardize on one account id (123456789012). 2017-03-15 22:21:04 -04:00
Steve Pulec
e9e49c5916 Fix py3 redshift encoding. 2017-03-15 22:12:16 -04:00
Steve Pulec
6666351757 Fix redshift server to default to xml. 2017-03-15 22:05:11 -04:00
Steve Pulec
3cdb4afad0 Fix redshift responses to work with json or xml. 2017-03-15 21:58:37 -04:00
Steve Pulec
09a4d177f5 Add kms boto3 test. 2017-03-14 23:42:52 -04:00
Steve Pulec
0df47574ab Merge pull request #865 from adamstauffer/master
update RDS responses to return DBInstanceArn
2017-03-14 23:28:30 -04:00
Steve Pulec
2bd4567801 Do not use flask outside of server mode. 2017-03-14 23:26:31 -04:00
Steve Pulec
7eb5b60620 Merge pull request #860 from 2rs2ts/add-list-hosted-zones-by-name
Add ListHostedZonesByName
2017-03-14 23:24:03 -04:00
Steve Pulec
ad743cb5e1 Merge pull request #861 from scawley-r7/master
Ensure SQS property WaitTimeSeconds is an integer
2017-03-14 23:22:41 -04:00
Steve Pulec
d0cde0218c Rearrange docs. 2017-03-14 23:20:17 -04:00
Andrew Garrett
6346e44c9d Be flexible with Route53 Hosted Zone IDs with /hostedzone/ prefix
We will continue to store just the unique ID, but since the AWS API
returns /hostedzone/<id>, we should accept attempts to pass that back.
For example, both just the ID as well as /hostedzone/<id> work for
specifying the HostedZoneId of a ResourceRecordSet in CloudFormation. So
we should support that too.

Signed-off-by: Scott Greene <scott.greene@getbraintree.com>
2017-03-14 19:52:36 +00:00
Steve Pulec
b81e427b99 Add moto apis. 2017-03-14 00:27:48 -04:00
Steve Pulec
4cf34cc113 Add docs for moto apis. 2017-03-14 00:17:56 -04:00
Steve Pulec
54c7e0bcf9 Update docs to newer sphinx. 2017-03-13 23:07:18 -04:00
Adam Stauffer
c5853b48da update RDS responses to return DBInstanceArn 2017-03-13 16:48:22 -04:00
Andrew Garrett
b9ea947aa0 Add ListHostedZonesByName 2017-03-13 15:27:45 +00:00
Seamus Cawley
bd2ff89bf1 Ensure SQS property WaitTimeSeconds is an integer 2017-03-13 13:56:55 +00:00
Steve Pulec
cda553abfb Change tests to use default server port of 5000. 2017-03-12 21:04:19 -04:00
Steve Pulec
689adf7dbc Add flake8 to dev dependencies. 2017-03-12 20:41:08 -04:00
Steve Pulec
1664e4412f Add lint to make test instead. 2017-03-12 20:37:23 -04:00
Steve Pulec
d2c56619cd Add lint to Travis. 2017-03-12 20:35:45 -04:00
Steve Pulec
5807a38092 Merge pull request #858 from spulec/dashboard
Add a dashboard
2017-03-12 20:26:42 -04:00
Steve Pulec
0e2fdf94f9 Cleanup lints. 2017-03-12 20:18:54 -04:00
Steve Pulec
3a01150154 Add about page. 2017-03-12 19:58:40 -04:00
Steve Pulec
24affc7a5f Fix py3 Model __new__. 2017-03-12 13:04:36 -04:00
Steve Pulec
4d5642ae33 Cleanup dashboard. 2017-03-12 12:59:30 -04:00
Christian Hellman
c271e31745 Fixed terraform deploy against moto fails (#857) 2017-03-12 12:40:49 -04:00
Steve Pulec
09ac3539b7 Sort dashboard attributes. 2017-03-12 12:34:54 -04:00
Steve Pulec
6d422d1f37 Add BaseModel to all models. 2017-03-11 23:41:12 -05:00