|
| 1 | +import __init__ |
| 2 | +from localstack.constants import ENV_DEV, LAMBDA_TEST_ROLE |
| 3 | +from localstack.utils.common import * |
| 4 | +from localstack.mock import infra |
| 5 | +from localstack.utils.kinesis import kinesis_connector |
| 6 | +from localstack.utils.aws import aws_stack |
| 7 | +from .lambdas import lambda_integration |
| 8 | + |
| 9 | +TEST_STREAM_NAME = lambda_integration.KINESIS_STREAM_NAME |
| 10 | + |
| 11 | +def start_test(env=ENV_DEV): |
| 12 | + try: |
| 13 | + # setup environment |
| 14 | + if env == ENV_DEV: |
| 15 | + infra.start_infra(async=True, apis=['kinesis']) |
| 16 | + time.sleep(6) |
| 17 | + kinesis = aws_stack.connect_to_service('kinesis', env=env) |
| 18 | + stream = aws_stack.create_kinesis_stream(TEST_STREAM_NAME) |
| 19 | + |
| 20 | + stream.put_records( |
| 21 | + [{ |
| 22 | + 'StreamName': 'test-stream-1' |
| 23 | + }] |
| 24 | + ) |
| 25 | + print 'This should return a response' |
| 26 | + response = infra.update_kinesis( |
| 27 | + 'POST', |
| 28 | + '/', |
| 29 | + {u'StreamName': u'test-stream-1'}, |
| 30 | + { |
| 31 | + 'Host': 'localhost:4568', |
| 32 | + 'Authorization': 'AWS4-HMAC-SHA256 Credential=LocalStackDummyAccessKey/20161223/us-east-1/kinesis/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date;x-amz-target, Signature=d9e43209de617fdf9716806c8ecac7370f0d341970855c86bbc02e6355f0e5b4', |
| 33 | + 'X-Amz-Date': '20161223T204016Z', |
| 34 | + 'User-Agent': 'amazon-kinesis-client-library-java-1.7.2 amazon-kinesis-multi-lang-daemon/1.0.1 python/2.7 /tmp/kclipy.0c9cf0f9.processor.py,amazon-kinesis-client-library-java-1.7.2, aws-sdk-java/1.11.14 Mac_OS_X/10.12.2 Java_HotSpot(TM)_64-Bit_Server_VM/25.112-b16/1.8.0_112', |
| 35 | + 'amz-sdk-invocation-id': 'bd347038-25b1-8658-8a25-241c44f6e6c0', |
| 36 | + 'amz-sdk-retry': '0/0/500', |
| 37 | + 'X-Amz-Target': 'Kinesis_20131202.PutRecords', |
| 38 | + 'Content-Type': 'application/x-amz-json-1.1', |
| 39 | + 'Content-Length': 238, |
| 40 | + 'Connection': 'Keep-Alive' |
| 41 | + } |
| 42 | + ) |
| 43 | + print 'Response:', response |
| 44 | + except KeyboardInterrupt, e: |
| 45 | + infra.KILLED = True |
| 46 | + finally: |
| 47 | + print("Shutdown") |
| 48 | + cleanup(files=True, env=env) |
| 49 | + infra.stop_infra() |
0 commit comments