atlassian / localstack
- воскресенье, 26 марта 2017 г. в 03:12:51
Python
A fully functional local AWS cloud stack. Develop and test your cloud apps offline!
Please note: The main version of this repository is https://bitbucket.org/atlassian/localstack, please raise PRs against that repo.
LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications.
Currently, the focus is primarily on supporting the AWS cloud stack.
LocalStack spins up the following core Cloud APIs on your local machine:
Additionally, LocalStack provides a powerful set of tools to interact with the cloud services, including a fully featured KCL Kinesis client with Python binding, simple setup/teardown integration for nosetests, as well as an Environment abstraction that allows to easily switch between local and remote Cloud execution.
LocalStack builds on existing best-of-breed mocking/testing tools, most notably kinesalite/dynalite and moto. While these tools are awesome (!), they lack functionality for certain use cases. LocalStack combines the tools, makes them interoperable, and adds important missing functionality on top of them:
ProvisionedThroughputExceededException
which is thrown by Kinesis or DynamoDB if the amount of
read/write throughput is exceeded.@mock_sqs
. These client proxies
do not perform an actual REST call, but rather call a local mock service method that lives in the same process as
the test code.make
python
pip
(python package manager)npm
(node.js package manager)java
/javac
(Java runtime environment and compiler)The easiest way to install LocalStack is via pip
:
pip install localstack
You can also spin up LocalStack without any installation requirements, using Docker:
docker run -it -p 4567-4576:4567-4576 atlassianlabs/localstack
... or simply use the make
target which runs the same command:
make docker-run
If you pull the repo in order to extend/modify LocalStack, run this command to install all dependencies:
make install
This will install the required pip dependencies in a local Python virtualenv directory
.venv
(your global python packages will remain untouched), as well as some node modules
in ./localstack/node_modules/
. Depending in your system, some pip/npm modules may require
additional native libs installed.
The project comes with a set of unit and integration tests which can be kicked off via a make target:
make test
The Makefile contains a target to conveniently run the local infrastructure.
make infra
Then you can point your aws
CLI to use the local infrastructure, for example:
aws --endpoint-url=http://localhost:4568 kinesis list-streams
{
"StreamNames": []
}
If you are accessing the cloud APIs from within yout Python code, you can also use boto3
and use
the endpoint_url
parameter to connect to the respective service on localhost
.
See localstack.utils.aws.aws_stack
for convenience methods to connect to the local services.
If you want to use LocalStack in your integration tests (e.g., nosetests), simply fire up the infrastructure in your test setup method and then clean up everything in your teardown method:
from localstack.mock import infra
def setup():
infra.start_infra(async=True)
def teardown():
infra.stop_infra()
def my_app_test():
# here goes your test logic
See the example test file tests/test_integration.py
for more details.
In order to use LocalStack with Java, the project ships with a simple JUnit runner. Take a look
at the example JUnit test in ext/java
. When you run the test, all dependencies are automatically
downloaded and installed to a temporary directory in your system.
@RunWith(LocalstackTestRunner.class)
public class MyCloudAppTest {
@Test
public void testLocalS3API() {
AmazonS3 s3 = new AmazonS3Client(...);
s3.setEndpoint(LocalstackTestRunner.getEndpointS3());
List<Bucket> buckets = s3.listBuckets();
...
}
}
The projects also comes with a simple Web dashboard that allows to view the deployed AWS components and the relationship between them.
make install-web
make web
We welcome feedback, bug reports, and pull requests!
For pull requests, please stick to the following guidelines:
Please note that we need to collect a signed Contributors License Agreement from each individual developer who contributes code to this repository. Please refer to the following links:
Copyright (c) 2016 Atlassian and others.
LocalStack is released under the Apache License, Version 2.0 (see LICENSE.txt).
We build on a number of third-party software tools, with the following licenses:
Third-Party software | License |
---|---|
Python/pip modules: | |
airspeed | BSD License |
amazon_kclpy | Amazon Software License |
boto3 | Apache License 2.0 |
coverage | Apache License 2.0 |
docopt | MIT License |
elasticsearch | Apache License 2.0 |
flask | BSD License |
flask_swagger | MIT License |
jsonpath-rw | Apache License 2.0 |
moto | Apache License 2.0 |
nose | GNU LGPL |
pep8 | Expat license |
requests | Apache License 2.0 |
sh | MIT License |
subprocess32 | PSF License |
Node.js/npm modules: | |
dynalite | MIT License |
kinesalite | MIT License |
Other tools: | |
Elasticsearch | Apache License 2.0 |