mimic

An API mock service

https://github.com/rackerlabs/mimic

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.9%) to scientific vocabulary

Keywords from Contributors

attributes classes fuzzing ssl tls
Last synced: 10 months ago · JSON representation

Repository

An API mock service

Basic Info
  • Host: GitHub
  • Owner: rackerlabs
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 2.85 MB
Statistics
  • Stars: 169
  • Watchers: 197
  • Forks: 57
  • Open Issues: 113
  • Releases: 0
Created almost 13 years ago · Last pushed almost 3 years ago
Metadata Files
Readme License

README.md

MIMIC

Mimic is an API-compatible mock service for Openstack Compute and Rackspace's implementation of Identity and Cloud Load balancers. It is backed by in-memory data structure rather than a potentially expensive database.

Mimic helps with: * fast set-up * instant response * cost efficient * enables offline development * enables ability to test unusual behaviors/errors of an api * acts as a central repository for mocked responses from services

Quick start

The fastest way to install and start Mimic is:

pip install mimic
twistd -n mimic

You can test the server started successfully by sending this request and checking for the welcome message:

curl http://localhost:8900
>> To get started with Mimic, POST an authentication request to:
>> /identity/v2.0/tokens

You can use the command below to test authentication and see your service catalog. The service catalog contains the endpoints for other available APIs.

curl -s -XPOST -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"mimic","apiKey":"12345"}}}' http://localhost:8900/identity/v2.0/tokens | python -m json.tool

In order to use Mimic with most other projects you just need to override the Authentication Endpoint. In many projects, including the OpenStack Client CLI or the OpenStack Keystone client you can do that by setting the OS_AUTH_URL environment variable or the --os-auth-url option. For example:

keystone --os-username mimic --os-password 1235 --os-auth-url http://localhost:8900/identity/v2.0/ catalog

Come join us develop Mimic! Talk to us at ##mimic on irc.freenode.net

Build status:

Build Status

codecov.io

Compute

Calls supported:

https://github.com/rackerlabs/mimic/blob/master/mimic/rest/nova_api.py

  1. LIST servers - Lists servers on the tenant, in mimic
  2. POST server - Creates a server in mimic (look at the 'Errors or unusual behaviors supported for compute' below)
  3. GET server - Returns the server, if it exists in mimic else returns a 404
  4. DELETE server - Deletes the server, if it exists in mimic else returns 404
  5. LIST addresses - Lists the private and public Ips for the given server. 404 if not found.
  6. GET image - If the image ID is anything but what is listed in the mimic presets, invalid_image_ref returns 200. Else returns a 400.
  7. GET flavor - If the flavor ID is anything but what is listed in the mimic presets, invalid_flavor_ref returns 200. Else returns a 400.
  8. GET limits - Returns only the absolute limits for compute

Errors or unusual behaviors supported for compute:

Based on the metadata (mimic_presets) provided when a server is being created, a server can be made to behave as follows: * Fail with the given response message and response code * Go into an error state on creation * Remain in building state for the specified amount of time * Fails to delete the server, with the specified response code for the number of times specified * Returns 'image not found' or 'flavor not found' responses for specified IDs

Eg: Request for create server that remains in building for 120 seconds:

{ "server" : { "name" : "api-test-server-1", "imageRef" : "3afe97b2-26dc-49c5-a2cc-a2fc8d80c001", "flavorRef" : "2", "metadata": {"server_building": 120} } }

Rackspace Auth

Calls supported:

https://github.com/rackerlabs/mimic/blob/master/mimic/rest/identity_api.py

  1. Authenticate - Given a tenant id, username and password, returns the service catalog with links to compute and load balancer links within mimic, and a test token.
  2. Impersonate user (Admin call) - Given a token created by mimic in the header, returns a test token for the username.
  3. GET endpoints - Given token created by mimic, returns the service catalog for that user.

Cloud Load Balancer

Calls supported:

https://github.com/rackerlabs/mimic/blob/master/mimic/rest/loadbalancer_api.py

  1. LIST load balancers - Lists the load balancers created in mimic
  2. POST load balancer - Creates a load balancer (look at the 'Errors or unusual behaviors supported for cloud load balancers' below)
  3. GET load balancer - Returns the load balancer if it exists, else 404
  4. DELETE load balancer - Deletes the load balancer if it exists, else returns 404
  5. LIST nodes - Lists the nodes on the load balancer
  6. POST node - Creates a node on the load balancer
  7. GET node - Returns the node if it exists, else returns 404
  8. DELETE node - Deletes the node if it exists, else returns 404

Errors or unusual behaviors supported for cloud load balancers:

Based on key and value of the metadata (mimic_presets) provided when a load balancer is being created, a load balancer can be made to behave as follows: * Remain in 'BUILD' state for the specified amount of time * Load balancer goes into 'PENDING-UPDATE' state on every add/delete node for the specified amout of time * Load balancer goes into 'PENDING-DELETE' state on delete load balancer for the specified amout of time * Load balancer goes into an error state on creation

Eg: Request for create load balancer that is expected to go into 'PENDING-UPDATE' state on every add/delete node, for 20 seconds:

{"loadBalancer": {"name": "a-new-loadbalancer2", "protocol": "HTTP", "virtualIps": [{"type": "PUBLIC"}], "metadata": [{"key": "lb_pending_update", "value": 20}], "nodes": []}}

Fastly CDN

Fastly is one of the leading CDN providers with great API support. Fastly is also one of the CDN providers, supported by the Openstack Poppy project. Mimic supports all Fastly API calls needed by Openstack Poppy in its Fastly implementation. See below for the complete list.

Calls supported:

https://github.com/rackerlabs/mimic/blob/master/mimic/rest/fastly_api.py

  1. GET /current_customer
  2. POST /service
  3. POST /service/{service_id}/version
  4. GET /service/search
  5. POST /service/{serviceid}/version/{versionid}/domain
  6. GET /service/{serviceid}/version/{versionid}/domain/check_all
  7. POST /service/{serviceid}/version/{versionid}/backend
  8. GET /service/{service_id}/version
  9. PUT /service/{serviceid}/version/{versionnumber}/activate
  10. DELETE /service/{service_id}
  11. GET /service/{service_id}/details
  12. GET / (health check)

Mimic Control APIs

When any of Mimic's included plugins schedule a timeout, you will need to cause Mimic's internal clock to advance for any of those timeouts to fire.

You can do this with the tick endpoint, like so:

curl -s -XPOST -d '{"amount": 1.0}' http://localhost:8900/mimic/v1.1/tick | python -m json.tool

which should result in output like this:

{
    "advanced": 1.0,
    "now": "1970-01-01T00:00:04.000000Z"
}

Note that Mimic begins its timekeeping when all time began, in 1970. If you would prefer to advance Mimic to something resembling the present day instead, a command like this right after Mimic starts up will do that:

curl -s -XPOST -d '{"amount": '"$(date +%s)"'}' http://localhost:8900/mimic/v1.1/tick | python -m json.tool

Mimic does not:

  • support XML
  • validate the auth token

Running Mimic on a cloud server

  1. create a cloud server with an image that by default comes with python 2.7 (eg: ubuntu 14.04) and ssh into it
  2. install virtualenv; for ubuntu, sudo apt-get install python-virtualenv
  3. virtualenv my-mimic-install
  4. . my-mimic-install/bin/activate
  5. pip install mimic
  6. twistd -n mimic

Running Mimic on Docker

The repository root has a Dockerfile that does what you want. It exposes Mimic on port 8900 by default.

To play around with Mimic locally, try:

docker build -t mimic . && docker run --restart=no --rm=true -p 8900:8900 mimic

This will expose Mimic on port 8900, so you can access it directly from the host. The default port exposure is intended for communication between containers; see the Docker documentation for more information. If you're using boot2docker, run boot2docker ip to find the right IP.

Owner

  • Name: Rackerlabs
  • Login: rackerlabs
  • Kind: organization
  • Location: San Antonio, TX

Rackspace rackerlabs public git repositories

GitHub Events

Total
  • Watch event: 4
Last Year
  • Watch event: 4

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 2,130
  • Total Committers: 35
  • Avg Commits per committer: 60.857
  • Development Distribution Score (DDS): 0.76
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Glyph g****h@t****m 512
requires.io s****t@r****o 371
lekhajee l****n@r****m 260
derwolfe c****e@g****m 231
cyli c****i@t****m 206
Tommy Walton t****n@R****M 97
Ken Sheedlo k****o@r****m 87
BenjamenMeyer b****r@r****m 83
Samuel A. Falvo II s****o@r****m 60
Tokunbo t****e@r****m 44
Lindsay K l****k@g****m 22
Laurens Van Houtven _@l****o 20
Manish Tomar m****c@g****m 19
Manish Tomar m****r@r****m 19
Drago Rosson d****o@r****e 15
Gabriel C G****e@R****M 13
Christopher Armstrong r****x@t****m 11
Malini Kamalambal m****l@r****m 11
Tim Boudreau t****u@r****m 7
benjamin.grassart b****t@t****m 6
mikael.gibert m****t@n****m 5
Richard Wall r****l@c****m 5
kaustav haldar hi@k****e 4
Steve Peak s****e@c****o 4
amitgandhinz a****i@r****m 4
raghav3259 r****l@g****m 2
Max Lincoln m****n@t****m 2
Paul Kehrer p****r@g****m 2
Jesse Zoldak z****k@e****g 2
nyasukun n@y****g 1
and 5 more...

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 9
  • Total pull requests: 96
  • Average time to close issues: 2 days
  • Average time to close pull requests: 2 months
  • Total issue authors: 7
  • Total pull request authors: 10
  • Average comments per issue: 1.22
  • Average comments per pull request: 1.49
  • Merged pull requests: 67
  • Bot issues: 0
  • Bot pull requests: 22
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • manishtomar (3)
  • paddyvgc (1)
  • glyph (1)
  • nyasukun (1)
  • derwolfe (1)
  • BenjamenMeyer (1)
  • wallrj (1)
Pull Request Authors
  • ryandub (45)
  • dependabot[bot] (22)
  • stavxyz (11)
  • wallrj (4)
  • glyph (4)
  • manishtomar (4)
  • BenjamenMeyer (2)
  • jzoldak (2)
  • rillip3 (1)
  • ghost (1)
Top Labels
Issue Labels
Cloud Feeds Plugin (2) enhancement (2) needed by: autoscale (1) new contributors: look at this (1)
Pull Request Labels
dependencies (22) enhancement (2) work in progress (1) needed by: cloud control panel (1) ready for review (1) good to land (with minor changes) (1) needed by: cloud backup (1) good to land (if tests pass) (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 114 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 7
  • Total versions: 15
  • Total maintainers: 2
pypi.org: mimic

An API-compatible mock service

  • Versions: 15
  • Dependent Packages: 0
  • Dependent Repositories: 7
  • Downloads: 114 Last month
Rankings
Stargazers count: 5.5%
Forks count: 5.5%
Dependent repos count: 5.6%
Dependent packages count: 10.0%
Average: 12.5%
Downloads: 35.9%
Maintainers (2)
Last synced: 11 months ago

Dependencies

requirements/common.txt pypi
  • wheel ==0.29.0
requirements/documentation-only.txt pypi
  • Babel ==2.3.4
  • Jinja2 ==2.9.5
  • MarkupSafe ==0.23
  • Pygments ==2.2.0
  • Sphinx ==1.5.2
  • alabaster ==0.7.9
  • chardet ==2.3.0
  • doc8 ==0.7.0
  • docutils ==0.13.1
  • pbr ==1.10.0
  • pytz ==2016.10
  • restructuredtext-lint ==0.17.2
  • six ==1.10.0
  • snowballstemmer ==1.2.1
  • sphinx-rtd-theme ==0.1.9
  • stevedore ==1.20.0
requirements/lint-only.txt pypi
  • flake8 ==3.3.0
  • mccabe ==0.6.1
  • pep257 ==0.7.0
  • pep8 ==1.7.0
  • pyflakes ==1.5.0
requirements/mac-app.txt pypi
  • altgraph ==0.13
  • macholib ==1.8
  • modulegraph ==0.13
  • py2app ==0.11
  • pyobjc-core ==3.2.1
  • pyobjc-framework-CFNetwork ==3.2.1
  • pyobjc-framework-Cocoa ==3.2.1
  • setuptools ==34.1.1
requirements/production.txt pypi
  • Twisted ==16.6.0
  • Werkzeug ==0.11.15
  • attrs ==16.3.0
  • cffi ==1.9.1
  • coverage ==4.3.4
  • cryptography ==1.7.2
  • ddt ==1.1.1
  • enum34 ==1.1.6
  • extras ==1.0.0
  • idna ==2.2
  • ipaddress ==1.0.18
  • iso8601 ==0.1.11
  • klein ==16.12.0
  • linecache2 ==1.0.0
  • pyOpenSSL ==16.2.0
  • pyasn1 ==0.2.2
  • pyasn1-modules ==0.0.8
  • pycparser ==2.17
  • python-mimeparse ==1.6.0
  • requests ==2.13.0
  • service-identity ==16.0.0
  • six ==1.10.0
  • testtools ==1.7.1
  • traceback2 ==1.4.0
  • treq ==16.12.0
  • unittest2 ==1.1.0
  • wheel ==0.29.0
  • xmltodict ==0.10.2
  • zope.interface ==4.3.3
requirements/spellcheck.txt pypi
  • pyenchant ==1.6.8
  • sphinxcontrib-spelling ==2.3.0
requirements/toolchain.txt pypi
  • coverage ==4.3.4
  • detox ==0.10.0
  • eventlet ==0.20.1
  • greenlet ==0.4.12
  • pip >=7.1.2
  • pluggy ==0.4.0
  • py ==1.4.32
  • tox ==2.6.0
  • virtualenv ==15.1.0
setup.py pypi
  • attrs >=15.1.0
  • iso8601 >=0.1.10
  • klein >=15.3.1
  • six >=1.6.0
  • testtools >=1.7.1,<1.8.0
  • treq >=15.1.0
  • twisted >=15.5.0
  • xmltodict >=0.9.1
Dockerfile docker
  • python 2.7 build
requirements/development.txt pypi
requirements/documentation.txt pypi
requirements/lint.txt pypi