Commit Graph

5770 Commits

Author SHA1 Message Date
Brian Pandola
f7467164e4
Fix Race Condition in batch:SubmitJob (#3480)
* Extract Duplicate Code into Helper Method

DRY up the tests and replace the arbitrary `sleep()` calls with a more
explicit check before progressing.

* Improve Testing of batch:TerminateJob

The test now confirms that the job was terminated by sandwiching a `sleep`
command between two `echo` commands.  In addition to the original checks
of the terminated job status/reason, the test now asserts that only the
first echo command succeeded, confirming that the job was indeed terminated
while in progress.

* Fix Race Condition in batch:SubmitJob

The `test_submit_job` in `test_batch.py` kicks off a job, calls `describe_jobs`
in a loop until the job status returned is SUCCEEDED, and then asserts against
the logged events.

The backend code that runs the submitted job does so in a separate thread. If
the job was successful, the job status was being set to SUCCEEDED *before* the
event logs had been written to the logging backend.

As a result, it was possible for the primary thread running the test to detect
that the job was successful immediately after the secondary thread had updated
the job status but before the secondary thread had written the logs to the
logging backend.  Under the right conditions, this could cause the subsequent
logging assertions in the primary thread to fail.

Additionally, the code that collected the logs from the container was using
a "dodgy hack" of time.sleep() and a modulo-based conditional that was
ultimately non-deterministic and could result in log messages being dropped
or duplicated in certain scenarios.

In order to address these issues, this commit does the following:

* Carefully re-orders any code that sets a job status or timestamp
  to avoid any obvious race conditions.
* Removes the "dodgy hack" in favor of a much more straightforward
  (and less error-prone) method of collecting logs from the container.
* Removes arbitrary and unnecessary calls to time.sleep()

Before applying any changes, the flaky test was failing about 12% of the
time.  Putting a sleep() call between setting the `job_status` to SUCCEEDED
and collecting the logs, resulted in a 100% failure rate.  Simply moving
the code that sets the job status to SUCCEEDED to the end of the code block,
dropped the failure rate to ~2%.  Finally, removing the log collection
hack allowed the test suite to run ~1000 times without a single failure.

Taken in aggregate, these changes make the batch backend more deterministic
and should put the nail in the coffin of this flaky test.

Closes #3475
2020-11-18 10:49:25 +00:00
Oide Brett
83507fbc37
fixed issue in update_configuration for lambda when setting VPC config property (#3479) 2020-11-18 08:45:31 +00:00
Ayush Ghosh
7f73015f02
Fix XML encoding in Route53 JInja2 Templates #3469 (#3473)
* Use Jinja2 escape functionality to escape html attributes in value response

* Add tests

* fix formatting
2020-11-18 07:23:49 +00:00
Guillermo Arribas
62fd975da0
EventBridge: put_rule and list_rules should store and retrieve EventBusName property (#3472)
Co-authored-by: Guillermo Arribas <garribas@atlassian.com>
2020-11-17 15:36:17 +00:00
jweite
5fe921c2bc
Added support for EMR Security Configurations and Kerberos Attributes. (#3456)
* Added support for EMR Security Configurations and Kerberos Attributes.

* Revised exception-raising test to work with pytest api.

* Added htmlcov to .gitignore; upgrading botocore to 1.18.17, per commit d29475e.

Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
2020-11-17 10:54:34 +00:00
Rich Unger
f045af7e0a
Add support for empty strings in non-key dynamo attributes (#3467)
* Add support for empty strings in non-key attributes

https://github.com/spulec/moto/issues/3339

* Nose, not pytest

* Revert "Nose, not pytest"

This reverts commit 5a3cf6c887dd9fafa49096c82cfa3a3b7f91d224.

* PUT is default action
2020-11-17 09:12:39 +00:00
Oide Brett
62d382ff70
Fixed issue 3448 for DynamoDB update_item (#3463)
* Fixed issue 3448 for DynamoDB update_item

* Tidied up fix for issue 3448 for DynamoDB update_item

* Reformatted fix for issue 3448 for DynamoDB update_item

* removed use of f-strings in test case as it fails in Travis CI build due to Python 2.7 support of f strings
2020-11-17 07:41:54 +00:00
Brian Pandola
d29475ed19
Fix: TagList missing in rds:DescribeDBInstance response (#3459)
Previously, tags were only available via rds:ListTagsForResource, but are now
included in the Create/DescribeDBInstance responses as of Botocore 1.18.17[1]

[1]: f29d23c53e (diff-d10722c0e11ded323c8d240066d7ed31e93a1e6423d54e091b7d54b86e6bd4e0)

Fixes #3458
2020-11-16 09:30:53 +00:00
Brian Pandola
93453eba05
Improve ec2:DescribeSubnets filtering (#3457)
* Add response/model/test coverage for filtering by `state`
* Add explicit test case for filtering by `vpc-id`

Closes #801
2020-11-16 08:17:36 +00:00
Guillermo Arribas
7749c1f757
Fix failures with latest responses library (0.12.1) (#3466)
* Fix failures with latest responses library (0.12.1)

* Detect version of responses library and supply a compatible  monkey patch depending on version

* Seperate responses_mock._find_match monkey patchs depending on reponses lib version to improve readability

Co-authored-by: Guillermo Arribas <garribas@atlassian.com>
2020-11-16 07:20:33 +00:00
Steve Pulec
6107561717
Merge pull request #3451 from bpandola/fix-3450
Fix: Return `Tags` in iam:CreateUserResponse
2020-11-15 11:25:10 -06:00
gsamaras
d068653dea
dynamodb2 support for default Action ('Put') in update_item (#3454)
Co-authored-by: Georgios Samaras <gsamaras@amazon.com>
2020-11-14 11:10:38 +00:00
Steve Pulec
9db62d32bf
Merge pull request #3361 from mcepl/denose
Port test suite from nose to pytest
2020-11-13 17:55:14 -06:00
Bert Blommers
273ca63d59 Linting 2020-11-11 15:55:37 +00:00
Bert Blommers
cb6731f340 Convert fixtures/exceptions to Pytest 2020-11-11 15:54:01 +00:00
Matěj Cepl
6d364dc7aa Pytest model of exceptions uses 'value' attribute instead of 'exception'. 2020-11-11 12:21:04 +01:00
Matěj Cepl
2705698d83 Mark functions as requiring network 2020-11-10 14:12:38 +01:00
Matěj Cepl
5697ff87a8 Back to Black 2020-11-10 14:12:38 +01:00
Matěj Cepl
ea489bce6c Finish porting from nose to pytest. 2020-11-10 08:25:05 +01:00
Matěj Cepl
77dc60ea97 Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of
failures is left to the next commit.
2020-11-10 08:23:44 +01:00
Steve Pulec
47dbad291e
Merge pull request #3439 from bblommers/techdebt-remove-duplicate-awserrors
Tech Debt - Remove duplicate AWSError classes
2020-11-09 19:59:02 -06:00
Steve Pulec
e5adfd6f12
Merge pull request #3443 from bpandola/fix-2862
Add ssm:SendCommand support for instance tag Targets
2020-11-09 19:57:25 -06:00
Steve Pulec
12985a2067
Merge pull request #3447 from emendes28/master
adding docs for athena e glue
2020-11-09 19:54:17 -06:00
Steve Pulec
330eefb995
Merge pull request #3444 from bblommers/bugfix/3359
AWS Lambda - Only instantiate Docker when invoking functions
2020-11-09 19:53:14 -06:00
Brian Pandola
b8e08539e3 Fix: Return Tags in iam:CreateUserResponse
Fixes #3450
2020-11-09 14:59:06 -08:00
Bert Blommers
b5b1c45d68 Rename DockerUtilities to differentiate from docker-dependency 2020-11-09 16:31:18 +00:00
Isis Ohana
8adb1165f9 adding docs for athena e glue 2020-11-09 11:47:13 -03:00
Bert Blommers
8d3cc3ef32 #3359 - Reuse Docker-on-request for AWSLambda and Batch 2020-11-08 15:16:53 +00:00
Bert Blommers
f53a8f723c Travis: Use Focal-distribution, so we no longer have to downgrade Docker 2020-11-08 14:25:28 +00:00
Bert Blommers
390a4d5510 #3359 - Only initiate Docker when invoking Lambdas 2020-11-08 14:18:49 +00:00
Bert Blommers
c0700aa704 Revert "#3359 - Downgrade Docker-version to not break mock_lambda without Docker running"
This reverts commit 204fdabcc9.
2020-11-08 14:16:02 +00:00
Bert Blommers
204fdabcc9 #3359 - Downgrade Docker-version to not break mock_lambda without Docker running 2020-11-08 13:49:27 +00:00
Brian Pandola
2f70373c2e
Add CloudFormation Update support for AWS::StepFunctions::StateMachine (#3440)
Closes #3402
2020-11-08 12:44:23 +00:00
Brian Pandola
3b9635b3c7 Add ssm:SendCommand support for instance tag Targets
Replace the special-case code to handle Cloud Formation tags with a more
generic implementation that covers all instance tags.

Supersedes #2863
Closes #2862
2020-11-08 00:06:35 -08:00
Bert Blommers
3b6162de67 Refactor Forecast to also use shared AWSError class 2020-11-06 16:34:09 +00:00
Bert Blommers
1edb1e2e7e Merge branch 'master' into techdebt-remove-duplicate-awserrors 2020-11-06 16:27:59 +00:00
pwrmiller
725ad7571d
Adds some basic endpoints for Amazon Forecast (#3434)
* Adding some basic endpoints for Amazon Forecast, including all dataset group related endpoints

* Adds better testing around exception handling in forecast endpoint, removes some unused code, and cleans up validation code

* Fix unused imports, optimize imports, code style fixes

Co-authored-by: Paul Miller <pwmiller@amazon.com>
2020-11-06 08:23:47 +00:00
Peter Lithammer
b7cf2d4478
ecr: Fix "imageDigest" value in ecr.list_images() response (#3436) 2020-11-05 14:10:23 +00:00
Bert Blommers
032b9c4008 Tech Debt - Remove duplicate AWSError classes 2020-11-05 11:20:18 +00:00
Brian Pandola
574f46e212
Implement additional Step Functions endpoints (#3437)
* Implement tagging/untagging for State Machine resources

* Implement `stepfunctions:UpdateStateMachine` endpoint
2020-11-05 10:16:48 +00:00
Brian Pandola
76265576ac
Fix: describe/list attribute discrepancy in Secrets Manager (#3432)
`secretsmanager:DescribeSecret` returns `VersionIdsToStages`
`secretsmanager:ListSecrets` returns the same information in `SecretVersionsToStages`

* Verified fix against real AWS backend.

Fixes #3406
2020-11-03 14:18:56 +00:00
Brian Pandola
f584e16ab9
Fix: eventName for a deleted record should be REMOVE instead of DELETE (#3431)
Verified API documentation[1] against the real AWS backend.

[1]: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html#DDB-Type-streams_Record-eventName

Fixes #3400
2020-11-02 17:21:09 +00:00
usmangani1
f57a77451c
Fix:Added Tags for Network-ACL,RouteTable,InternetGateway (#3430)
* Fix:Added Tags for Network-ACL,RouteTable,InternetGateway

* Modified internet-gateway tags

* Lint

Co-authored-by: usmankb <usman@krazybee.com>
2020-11-02 13:30:02 +00:00
Brian Pandola
171130fe7b
Add support for CloudFormation resource AWS::StepFunctions::StateMachine (#3429)
Closes #3402

Co-authored-by: Bert Blommers <bblommers@users.noreply.github.com>
2020-11-02 11:53:03 +00:00
usmangani1
53c3eb6240
Fix:SecretsManager :Error on Invalid secretID (#3413)
* Fix:SecretsManager :Error on Invalid secretID

* Fixed tests

Co-authored-by: usmankb <usman@krazybee.com>
2020-11-02 10:15:40 +00:00
usmangani1
9970be2309
Fix: Adding alarm arn to describe alarms response (#3409)
* Fix: adding alarm arn to describe alarms response

* Fix:Delete subscriptions on delete topic

* modified tests

Co-authored-by: usmankb <usman@krazybee.com>
2020-11-02 08:56:18 +00:00
Brian Pandola
68e3d394ab
Stepfunctions improvements (#3427)
* Implement filtering for stepfunctions:ListExecutions

* Add pagination to Step Functions endpoints

Implements a generalized approach to pagination via a decorator method for the
Step Functions endpoints.  Modeled on the real AWS backend behavior, `nextToken`
is a dictionary of pagination information encoded in an opaque string.

With just a bit of metadata hard-coded (`utils.PAGINATION_MODEL`), backend `list`
methods need only be decorated with `@paginate` and ensure that their returned
entities are sorted to get full pagination support without any duplicated code
polluting the model.

Closes #3137
2020-11-01 10:16:41 +00:00
Eoin Shanaghy
a3880c4c35
Metric data query alarms (#3419)
* Add support for metric data query alarms (Metrics=[..])

* Fix trailing whitespace

* Allow for unordered metrics in Python 2.7

* Add describe_alarm assertions and support DatapointsToAlarm
2020-10-31 15:56:24 +00:00
jweite
f8d2ce2e6a
Notebook Lifecycle Config create, describe and delete (#3417)
* Notebook Lifecycle Config create, describe and delete

* PR3417 comment changes: raise on create with duplicate name, derive a ValidationException class and use it instead of RESTException, unit test for delete non-existing.

Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
2020-10-30 21:05:06 +00:00
jweite
cbd4efb42d
ApplicationAutoscaling: support autoscaling policies, deregister_scalable_target (#3350)
* ApplicationAutoscaling: support autoscaling policies, deregister_scalable_target.

* PR3350 comment changes: drop unnecessary pass statements, unit test three exception cases.

Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
2020-10-30 15:21:34 +00:00