From 02f1b1868a76849c474addf378238a64e2ef86a8 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 3 May 2016 01:25:46 -0400 Subject: [PATCH] Fix for EC2.Waiter.InstanceExists raising JMESPathTypeError Reverted the "success" acceptor for that waiter to an earlier version that checks only the response code, not the response body. Added a unit test that reproduces the issue and passes with the change to the JSON file. Bug: https://github.com/boto/botocore/issues/906 --- botocore/data/ec2/2015-10-01/waiters-2.json | 5 ++--- tests/integration/test_ec2.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/botocore/data/ec2/2015-10-01/waiters-2.json b/botocore/data/ec2/2015-10-01/waiters-2.json index 54c0b6eac0..43d5050b80 100644 --- a/botocore/data/ec2/2015-10-01/waiters-2.json +++ b/botocore/data/ec2/2015-10-01/waiters-2.json @@ -7,9 +7,8 @@ "operation": "DescribeInstances", "acceptors": [ { - "matcher": "path", - "expected": true, - "argument": "length(Reservations[]) > `0`", + "matcher": "status", + "expected": 200, "state": "success" }, { diff --git a/tests/integration/test_ec2.py b/tests/integration/test_ec2.py index 2a23b854fd..e83ddf7eb7 100644 --- a/tests/integration/test_ec2.py +++ b/tests/integration/test_ec2.py @@ -16,7 +16,7 @@ from nose.plugins.attrib import attr import botocore.session -from botocore.exceptions import ClientError +from botocore.exceptions import ClientError, WaiterError class TestEC2(unittest.TestCase): @@ -38,6 +38,20 @@ def test_get_console_output_handles_error(self): self.client.get_console_output(InstanceId='i-12345') +class TestEC2Waiter(unittest.TestCase): + def setUp(self): + self.session = botocore.session.get_session() + self.client = self.session.create_client( + 'ec2', region_name='us-west-2') + + def test_instance_wait_error(self): + """Test that InstanceExists can handle a nonexistent instance.""" + waiter = self.client.get_waiter('instance_exists') + waiter.config.max_attempts = 1 + with self.assertRaises(WaiterError): + waiter.wait(InstanceIds=['i-12345']) + + class TestEC2Pagination(unittest.TestCase): def setUp(self): self.session = botocore.session.get_session()