Skip to content

rackerlabs/mimic

Repository files navigation

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 https://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"}}}' https://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 https://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:

  • Rema