diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 7238ca3..0000000 --- a/.dockerignore +++ /dev/null @@ -1,13 +0,0 @@ -.eggs -.tox -.idea -.gitreview -.gitignore -*.egg-info -AUTHORS -ChangeLog -devstack -doc -Dockerfile -Dockerfile.integration-tests -docker-compose.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f0c53ab..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM python:3.5 - -ADD . /usr/local/src/ -RUN cd /usr/local/src && \ - pip install -r requirements.txt && \ - python setup.py install && \ - mkdir -p /etc/almanach && \ - cp /usr/local/src/etc/almanach/almanach.docker.conf /etc/almanach/almanach.conf - -USER nobody diff --git a/Dockerfile.integration-tests b/Dockerfile.integration-tests deleted file mode 100644 index f30b981..0000000 --- a/Dockerfile.integration-tests +++ /dev/null @@ -1,6 +0,0 @@ -FROM themattrix/tox - -COPY tox-integration.ini /app/tox.ini -COPY tests /app/tests -COPY integration_tests /app/integration_tests -COPY integration-test-requirements.txt /app/integration-test-requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index ac23625..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '2' -services: - api: - build: - context: . - dockerfile: Dockerfile - command: almanach-api --config-file /etc/almanach/almanach.conf - depends_on: - - messaging - - database - ports: - - "80:8000" - collector: - build: - context: . - dockerfile: Dockerfile - command: almanach-collector --config-file /etc/almanach/almanach.conf - depends_on: - - database - - messaging - messaging: - image: rabbitmq - ports: - - "5672:5672" - database: - image: mongo - ports: - - "27017:27017" - test: - build: - context: . - dockerfile: Dockerfile.integration-tests - args: - SKIP_TOX: "true" - environment: - TEST_CONTAINER: "true" - depends_on: - - api - - collector - - database - - messaging diff --git a/etc/almanach/almanach.docker.conf b/etc/almanach/almanach.docker.conf deleted file mode 100644 index 22fcce8..0000000 --- a/etc/almanach/almanach.docker.conf +++ /dev/null @@ -1,81 +0,0 @@ -[DEFAULT] - - -[api] - -# -# From almanach -# - -# IP address to listen on (IP address value) -bind_ip = 0.0.0.0 - -# TCP port number to listen on (port value) -# Minimum value: 0 -# Maximum value: 65535 -bind_port = 8000 - - -[auth] - -# -# From almanach -# - -# Authentication driver for the API (string value) -#strategy = private_key - -# Private key for private key authentication (string value) -#private_key = secret - -# Keystone service username (string value) -#keystone_username = - -# Keystone service password (string value) -#keystone_password = - -# Keystone URL (string value) -#keystone_url = http://keystone_url:5000/v2.0 - - -[collector] - -# -# From almanach -# - -# RabbitMQ connection URL (string value) -transport_url = rabbit://guest:guest@messaging:5672 - -# Maximal number of message retries (integer value) -max_retries = 5 - -# Delay in seconds between retries -retry_delay = 10 - -[database] - -# -# From almanach -# - -# Database driver (string value) -#driver = mongodb - -# Database connection URL (string value) -connection_url = mongodb://database:27017/almanach - - -[resources] - -# -# From almanach -# - -# Volume existence threshold (integer value) -#volume_existence_threshold = 60 - -# DEPRECATED: Metadata to include in entity (string value) -# This option is deprecated for removal. -# Its value may be silently ignored in the future. -device_metadata_whitelist = metering.billing_mode diff --git a/integration-test-requirements.txt b/integration-test-requirements.txt deleted file mode 100644 index a530925..0000000 --- a/integration-test-requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -nose==1.2.1 -requests==2.10.0 -kombu>=3.0.21 -python-dateutil==2.2 -pymongo==3.2.2 -pytz>=2014.10 -PyHamcrest==1.8.5 -retry>=0.9.2 \ No newline at end of file diff --git a/integration_tests/__init__.py b/integration_tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/integration_tests/base_api_testcase.py b/integration_tests/base_api_testcase.py deleted file mode 100644 index f7dc539..0000000 --- a/integration_tests/base_api_testcase.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from retry import retry - -from helpers.almanach_helper import AlmanachHelper -from helpers.rabbit_mq_helper import RabbitMqHelper - - -class BaseApiTestCase(unittest.TestCase): - rabbitMqHelper = RabbitMqHelper() - almanachHelper = AlmanachHelper() - - def _create_instance_entity(self): - project_id = "my_test_project_id" - instance_id = str(uuid4()) - data = { - 'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'FreeBSD', - 'os_distro': 'Stable', - 'os_version': '10', - } - response = self.almanachHelper.post(url="{url}/project/{project}/instance", data=data, project=project_id) - assert_that(response.status_code, equal_to(201)) - return instance_id - - @classmethod - @retry(exceptions=AssertionError, delay=10, max_delay=300) - def _wait_until_volume_type_is_created(cls, volume_type_id): - assert_that(cls._get_volume_types(volume_type_id), - has_entry("volume_type_id", volume_type_id)) - - @classmethod - def _get_volume_types(cls, type_id): - query = "{url}/volume_type/{type_id}" - response = cls.almanachHelper.get(url=query, type_id=type_id) - return response.json() diff --git a/integration_tests/base_api_volume_testcase.py b/integration_tests/base_api_volume_testcase.py deleted file mode 100644 index f86a11e..0000000 --- a/integration_tests/base_api_volume_testcase.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from base_api_testcase import BaseApiTestCase -from builders import messages -from helpers.mongo_helper import MongoHelper - - -class BaseApiVolumeTestCase(BaseApiTestCase): - @classmethod - def setUpClass(cls): - cls.setup_volume_type() - - @classmethod - def tearDownClass(cls): - MongoHelper().drop_database() - - @classmethod - def setup_volume_type(cls): - cls.rabbitMqHelper.push( - message=messages.get_volume_type_create_sample(volume_type_id=messages.DEFAULT_VOLUME_TYPE, - volume_type_name=messages.DEFAULT_VOLUME_TYPE), - ) - cls._wait_until_volume_type_is_created(volume_type_id=messages.DEFAULT_VOLUME_TYPE) diff --git a/integration_tests/builders/__init__.py b/integration_tests/builders/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/integration_tests/builders/messages.py b/integration_tests/builders/messages.py deleted file mode 100644 index d695dbf..0000000 --- a/integration_tests/builders/messages.py +++ /dev/null @@ -1,346 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import pytz - -from datetime import datetime -from datetime import timedelta -import dateutil.parser - -DEFAULT_VOLUME_TYPE = "my_block_storage_type" -DEFAULT_VOLUME_NAME = "my_block_storage_name" - - -def get_instance_create_end_sample(instance_id=None, tenant_id=None, flavor_name=None, - creation_timestamp=None, name=None, os_distro=None, os_version=None, metadata={}): - kwargs = { - "instance_id": instance_id or "e7d44dea-21c1-452c-b50c-cbab0d07d7d3", - "tenant_id": tenant_id or "0be9215b503b43279ae585d50a33aed8", - "hostname": name or "to.to", - "display_name": name or "to.to", - "instance_type": flavor_name or "myflavor", - "os_distro": os_distro or "CentOS", - "os_version": os_version or "6.4", - "created_at": creation_timestamp if creation_timestamp else datetime(2014, 2, 14, 16, 29, 58, tzinfo=pytz.utc), - "launched_at": creation_timestamp + timedelta(seconds=1) if creation_timestamp else datetime(2014, 2, 14, 16, - 30, 2, - tzinfo=pytz.utc), - "terminated_at": None, - "deleted_at": None, - "state": "active", - "metadata": metadata - } - kwargs["timestamp"] = kwargs["launched_at"] + timedelta(microseconds=200000) - return _get_instance_payload("compute.instance.create.end", **kwargs) - - -def get_instance_delete_end_sample(instance_id=None, tenant_id=None, flavor_name=None, os_distro=None, os_version=None, - creation_timestamp=None, deletion_timestamp=None, name=None): - kwargs = { - "instance_id": instance_id, - "tenant_id": tenant_id, - "hostname": name, - "display_name": name, - "instance_type": flavor_name, - "os_distro": os_distro or "centos", - "os_version": os_version or "6.4", - "created_at": creation_timestamp if creation_timestamp else datetime(2014, 2, 14, 16, 29, 58, tzinfo=pytz.utc), - "launched_at": creation_timestamp + timedelta(seconds=1) if creation_timestamp else datetime(2014, 2, 14, 16, - 30, 2, - tzinfo=pytz.utc), - "terminated_at": deletion_timestamp if deletion_timestamp else datetime(2014, 2, 18, 12, 5, 23, - tzinfo=pytz.utc), - "deleted_at": deletion_timestamp if deletion_timestamp else datetime(2014, 2, 18, 12, 5, 23, tzinfo=pytz.utc), - "state": "deleted" - } - kwargs["timestamp"] = kwargs["terminated_at"] + timedelta(microseconds=200000) - return _get_instance_payload("compute.instance.delete.end", **kwargs) - - -def get_volume_create_end_sample(volume_id=None, tenant_id=None, volume_type=None, volume_size=None, - creation_timestamp=None, name=None): - kwargs = { - "volume_id": volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed", - "tenant_id": tenant_id or "46eeb8e44298460899cf4b3554bfe11f", - "display_name": name or "mytenant-0001-myvolume", - "volume_type": volume_type or DEFAULT_VOLUME_TYPE, - "volume_size": volume_size or 50, - "created_at": creation_timestamp if creation_timestamp else datetime(2014, 2, 14, 17, 18, 35, tzinfo=pytz.utc), - "launched_at": creation_timestamp + timedelta(seconds=1) if creation_timestamp else datetime(2014, 2, 14, 17, - 18, 40, - tzinfo=pytz.utc), - "status": "available" - } - kwargs["timestamp"] = kwargs["launched_at"] + timedelta(microseconds=200000) - return _get_volume_icehouse_payload("volume.create.end", **kwargs) - - -def get_volume_delete_end_sample(volume_id=None, tenant_id=None, volume_type=None, volume_size=None, - creation_timestamp=None, deletion_timestamp=None, name=None): - kwargs = { - "volume_id": volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed", - "tenant_id": tenant_id or "46eeb8e44298460899cf4b3554bfe11f", - "display_name": name or "mytenant-0001-myvolume", - "volume_type": volume_type or DEFAULT_VOLUME_TYPE, - "volume_size": volume_size or 50, - "created_at": creation_timestamp if creation_timestamp else datetime(2014, 2, 14, 17, 18, 35, tzinfo=pytz.utc), - "launched_at": deletion_timestamp if deletion_timestamp else datetime(2014, 2, 14, 17, 18, 40, tzinfo=pytz.utc), - "timestamp": deletion_timestamp if deletion_timestamp else datetime(2014, 2, 23, 8, 1, 58, tzinfo=pytz.utc), - "status": "deleting" - } - return _get_volume_icehouse_payload("volume.delete.end", **kwargs) - - -def get_volume_attach_kilo_end_sample(volume_id=None, tenant_id=None, volume_type=None, volume_size=None, - timestamp=None, name=None, attached_to=None): - kwargs = { - "volume_id": volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed", - "tenant_id": tenant_id or "46eeb8e44298460899cf4b3554bfe11f", - "display_name": name or "mytenant-0001-myvolume", - "volume_type": volume_type or DEFAULT_VOLUME_TYPE, - "volume_size": volume_size or 50, - "attached_to": attached_to, - "timestamp": timestamp + timedelta(seconds=1) if timestamp else datetime(2014, 2, 14, 17, 18, 40, - tzinfo=pytz.utc), - } - return _get_volume_kilo_payload("volume.attach.end", **kwargs) - - -def get_volume_detach_kilo_end_sample(volume_id=None, tenant_id=None, volume_type=None, volume_size=None, - timestamp=None, name=None, attached_to=None): - kwargs = { - "volume_id": volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed", - "tenant_id": tenant_id or "46eeb8e44298460899cf4b3554bfe11f", - "display_name": name or "mytenant-0001-myvolume", - "volume_type": volume_type or DEFAULT_VOLUME_TYPE, - "volume_size": volume_size or 50, - "attached_to": attached_to, - "timestamp": timestamp + timedelta(seconds=1) if timestamp else datetime(2014, 2, 14, 17, 18, 40, - tzinfo=pytz.utc), - } - return _get_volume_kilo_payload("volume.detach.end", **kwargs) - - -def get_volume_resize_end_sample(volume_id=None, tenant_id=None, volume_type=None, volume_size=None, - timestamp=None, name=None, attached_to=None): - kwargs = { - "volume_id": volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed", - "tenant_id": tenant_id or "46eeb8e44298460899cf4b3554bfe11f", - "display_name": name or "mytenant-0001-myvolume", - "volume_type": volume_type or DEFAULT_VOLUME_TYPE, - "volume_size": volume_size or 50, - "attached_to": attached_to, - "timestamp": timestamp + timedelta(seconds=1) if timestamp else datetime(2014, 2, 14, 17, 18, 40, - tzinfo=pytz.utc), - } - return _get_volume_kilo_payload("volume.resize.end", **kwargs) - - -def _format_date(datetime_obj): - return datetime_obj.strftime("%Y-%m-%dT%H:%M:%S.%fZ") - - -def _get_instance_payload(event_type, instance_id=None, tenant_id=None, hostname=None, display_name=None, - instance_type=None, - instance_flavor_id=None, timestamp=None, created_at=None, launched_at=None, - deleted_at=None, terminated_at=None, state=None, os_type=None, os_distro=None, - os_version=None, metadata={}): - instance_id = instance_id or "e7d44dea-21c1-452c-b50c-cbab0d07d7d3" - os_type = os_type or "linux" - os_distro = os_distro or "centos" - os_version = os_version or "6.4" - hostname = hostname or "to.to" - display_name = display_name or "to.to" - tenant_id = tenant_id or "0be9215b503b43279ae585d50a33aed8" - instance_type = instance_type or "myflavor" - instance_flavor_id = instance_flavor_id or "201" - timestamp = timestamp if timestamp else "2014-02-14T16:30:10.453532Z" - created_at = _format_date(created_at) if created_at else "2014-02-14T16:29:58.000000Z" - launched_at = _format_date(launched_at) if launched_at else "2014-02-14T16:30:10.221171Z" - deleted_at = _format_date(deleted_at) if deleted_at else "" - terminated_at = _format_date(terminated_at) if terminated_at else "" - state = state or "active" - - if not isinstance(timestamp, datetime): - timestamp = dateutil.parser.parse(timestamp) - - return { - "event_type": event_type, - "payload": { - "state_description": "", - "availability_zone": None, - "terminated_at": terminated_at, - "ephemeral_gb": 0, - "instance_type_id": 12, - "message": "Success", - "deleted_at": deleted_at, - "memory_mb": 1024, - "user_id": "2525317304464dc3a03f2a63e99200c8", - "reservation_id": "r-7e68nhfk", - "hostname": hostname, - "state": state, - "launched_at": launched_at, - "node": "mynode.domain.tld", - "ramdisk_id": "", - "access_ip_v6": None, - "disk_gb": 50, - "access_ip_v4": None, - "kernel_id": "", - "image_name": "CentOS 6.4 x86_64", - "host": "node02", - "display_name": display_name, - "root_gb": 50, - "tenant_id": tenant_id, - "created_at": created_at, - "instance_id": instance_id, - "instance_type": instance_type, - "vcpus": 1, - "image_meta": { - "min_disk": "50", - "container_format": "bare", - "min_ram": "256", - "disk_format": "qcow2", - "build_version": "68", - "version": os_version, - "architecture": "x86_64", - "auto_disk_config": "True", - "os_type": os_type, - "base_image_ref": "ea0d5e26-a272-462a-9333-1e38813bac7b", - "distro": os_distro - }, - "architecture": "x86_64", - "os_type": "linux", - "instance_flavor_id": instance_flavor_id, - "metadata": metadata - }, - "_context_timestamp": timestamp.strftime("%Y-%m-%dT%H:%M:%S.%fZ"), - "updated_at": _format_date(timestamp - timedelta(seconds=10)), - "priority": "INFO", - } - - -def _get_volume_icehouse_payload(event_type, volume_id=None, tenant_id=None, display_name=None, volume_type=None, - volume_size=None, timestamp=None, created_at=None, launched_at=None, status=None, - attached_to=None): - volume_id = volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed" - tenant_id = tenant_id or "46eeb8e44298460899cf4b3554bfe11f" - display_name = display_name or "mytenant-0001-myvolume" - volume_type = volume_type or DEFAULT_VOLUME_TYPE - volume_size = volume_size or 50 - timestamp = timestamp if timestamp else "2014-02-14T17:18:40.888401Z" - created_at = _format_date(created_at) if created_at else "2014-02-14T17:18:35.000000Z" - launched_at = _format_date(launched_at) if launched_at else "2014-02-14T17:18:40.765844Z" - status = status or "available" - attached_to = attached_to or "e7d44dea-21c1-452c-b50c-cbab0d07d7d3" - - if not isinstance(timestamp, datetime): - timestamp = dateutil.parser.parse(timestamp) - - return { - "event_type": event_type, - "_context_timestamp": launched_at, - "publisher_id": "volume.cinder01", - "payload": { - "instance_uuid": attached_to, - "status": status, - "display_name": display_name, - "availability_zone": "nova", - "tenant_id": tenant_id, - "created_at": created_at, - "snapshot_id": None, - "volume_type": volume_type, - "volume_id": volume_id, - "user_id": "ebc0d5a5ecf3417ca0d4f8c90d682f6e", - "launched_at": launched_at, - "size": volume_size, - }, - "priority": "INFO", - "updated_at": _format_date(timestamp - timedelta(seconds=10)), - } - - -def _get_volume_kilo_payload(event_type, volume_id=None, tenant_id=None, display_name=None, volume_type=None, - timestamp=None, attached_to=None, volume_size=1): - volume_id = volume_id or "64a0ca7f-5f5a-4dc5-a1e1-e04e89eb95ed" - tenant_id = tenant_id or "46eeb8e44298460899cf4b3554bfe11f" - display_name = display_name or "mytenant-0001-myvolume" - volume_type = volume_type or DEFAULT_VOLUME_TYPE - timestamp = timestamp if timestamp else "2014-02-14T17:18:40.888401Z" - attached_to = attached_to - volume_attachment = [] - - if not isinstance(timestamp, datetime): - timestamp = dateutil.parser.parse(timestamp) - - if attached_to: - for instance_id in attached_to: - volume_attachment.append({ - "instance_uuid": instance_id, - "attach_time": _format_date(timestamp - timedelta(seconds=10)), - "deleted": False, - "attach_mode": "ro", - "created_at": _format_date(timestamp - timedelta(seconds=10)), - "attached_host": "", - "updated_at": _format_date(timestamp - timedelta(seconds=10)), - "attach_status": 'available', - "detach_time": "", - "volume_id": volume_id, - "mountpoint": "/dev/vdd", - "deleted_at": "", - "id": "228345ee-0520-4d45-86fa-1e4c9f8d057d" - }) - - return { - "event_type": event_type, - "_context_timestamp": _format_date(timestamp), - "publisher_id": "volume.cinder01", - "payload": { - "status": "in-use", - "display_name": display_name, - "volume_attachment": volume_attachment, - "availability_zone": "nova", - "tenant_id": tenant_id, - "created_at": "2015-07-27T16:11:07Z", - "volume_id": volume_id, - "volume_type": volume_type, - "host": "web@lvmdriver-1#lvmdriver-1", - "replication_status": "disabled", - "user_id": "aa518ac79d4c4d61b806e64600fcad21", - "metadata": [], - "launched_at": "2015-07-27T16:11:08Z", - "size": volume_size - }, - "priority": "INFO", - "updated_at": _format_date(timestamp - timedelta(seconds=10)), - } - - -def get_volume_type_create_sample(volume_type_id, volume_type_name): - return { - "priority": "INFO", - "event_type": "volume_type.create", - "publisher_id": "volume.cinder01", - "payload": { - "volume_types": { - "name": volume_type_name, - "qos_specs_id": None, - "deleted": False, - "created_at": "2014-02-14T17:18:35.036186Z", - "extra_specs": {}, - "deleted_at": None, - "id": volume_type_id, - } - }, - "updated_at": "2014-02-14T17:18:35.036186Z", - } diff --git a/integration_tests/helpers/__init__.py b/integration_tests/helpers/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/integration_tests/helpers/almanach_helper.py b/integration_tests/helpers/almanach_helper.py deleted file mode 100644 index 13246b1..0000000 --- a/integration_tests/helpers/almanach_helper.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import os -import requests - - -class AlmanachHelper(object): - x_auth_token = 'secret' - - def __init__(self): - is_container = True if os.environ.get('TEST_CONTAINER') else False - port = 8000 if is_container else 80 - hostname = "api" if is_container else "127.0.0.1" - self.base_url = "http://{url}:{port}".format(url=hostname, port=port) - - def get_entities(self, tenant_id, start): - url = "{url}/project/{project}/entities?start={start}".format( - url=self.base_url, project=tenant_id, start=start - ) - - response = requests.get(url, headers=self._get_query_headers()) - return response.json() - - def get(self, url, headers=None, **params): - return requests.get( - url.format(url=self.base_url, **params), - headers=headers if headers else self._get_query_headers() - ) - - def head(self, url, headers=None, **params): - return requests.head( - url.format(url=self.base_url, **params), - headers=headers if headers else self._get_query_headers() - ) - - def post(self, url, data, **params): - return requests.post( - url.format(url=self.base_url, **params), - data=json.dumps(data), - headers=self._get_query_headers() - ) - - def put(self, url, data, **params): - return requests.put( - url.format(url=self.base_url, **params), - data=json.dumps(data), - headers=self._get_query_headers() - ) - - def delete(self, url, data, **params): - return requests.delete( - url.format(url=self.base_url, **params), - data=json.dumps(data), - headers=self._get_query_headers() - ) - - def _get_query_headers(self): - return { - 'X-Auth-Token': self.x_auth_token, - 'Accept': 'application/json' - } diff --git a/integration_tests/helpers/mongo_helper.py b/integration_tests/helpers/mongo_helper.py deleted file mode 100644 index 5382a81..0000000 --- a/integration_tests/helpers/mongo_helper.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os - -from pymongo import MongoClient - - -class MongoHelper(object): - - def __init__(self): - is_container = True if os.environ.get('TEST_CONTAINER') else False - self.mongo = MongoClient(host="database" if is_container else "127.0.0.1") - - def drop_database(self): - self.mongo.drop_database('almanach') diff --git a/integration_tests/helpers/rabbit_mq_helper.py b/integration_tests/helpers/rabbit_mq_helper.py deleted file mode 100644 index a857605..0000000 --- a/integration_tests/helpers/rabbit_mq_helper.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os - -from kombu import BrokerConnection -from kombu.common import maybe_declare -from kombu import Exchange -from kombu.pools import producers - - -class RabbitMqHelper(object): - def __init__(self): - is_container = True if os.environ.get('TEST_CONTAINER') else False - hostname = "messaging" if is_container else "127.0.0.1" - amqp_url = "amqp://guest:guest@{url}:{port}".format(url=hostname, port=5672) - self.task_exchange = Exchange("almanach.info", type="topic") - self.connection = BrokerConnection(amqp_url) - - def push(self, message): - with producers[self.connection].acquire(block=True) as producer: - maybe_declare(self.task_exchange, producer.channel) - producer.publish(message, routing_key="almanach.info") diff --git a/integration_tests/test_api_authentication.py b/integration_tests/test_api_authentication.py deleted file mode 100644 index 3feb55a..0000000 --- a/integration_tests/test_api_authentication.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from hamcrest import assert_that -from hamcrest import equal_to - -from base_api_testcase import BaseApiTestCase - - -class ApiAuthenticationTest(BaseApiTestCase): - - def test_list_entities_unauthorized(self): - list_query = "{url}/project/{project}/instances?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, headers={'Accept': 'application/json'}, - project="e455d65807cb4796bd72abecdc8a76ba", - start="2014-02-28 18:50:00.000", end="2014-03-21 22:00:00.000") - assert_that(response.status_code, equal_to(401)) diff --git a/integration_tests/test_api_entity.py b/integration_tests/test_api_entity.py deleted file mode 100644 index d09cd05..0000000 --- a/integration_tests/test_api_entity.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from hamcrest import assert_that -from hamcrest import equal_to - -from base_api_testcase import BaseApiTestCase - - -class ApiInstanceEntityTest(BaseApiTestCase): - def test_head_entity_by_id_with_entity_return_200(self): - instance_id = self._create_instance_entity() - response = self.almanachHelper.head(url="{url}/entity/{instance_id}", - instance_id=instance_id) - - assert_that(response.status_code, equal_to(200)) - - def test_head_entity_by_id_without_entity_return_404(self): - instance_id = "some_uuid" - response = self.almanachHelper.head(url="{url}/entity/{instance_id}", - instance_id=instance_id) - - assert_that(response.status_code, equal_to(404)) - - def test_get_entity_by_id_with_entity_return_200(self): - instance_id = self._create_instance_entity() - response = self.almanachHelper.get(url="{url}/entity/{instance_id}", instance_id=instance_id) - - result = response.json() - assert_that(response.status_code, equal_to(200)) - assert_that(len(result), equal_to(1)) - assert_that(result[0]["entity_id"], equal_to(instance_id)) - - def test_get_entity_by_id_with_entity_return_404(self): - response = self.almanachHelper.get(url="{url}/entity/{instance_id}", instance_id="foobar") - - result = response.json() - assert_that(result, equal_to({"error": "Entity not found"})) - assert_that(response.status_code, equal_to(404)) diff --git a/integration_tests/test_api_info.py b/integration_tests/test_api_info.py deleted file mode 100644 index 688b223..0000000 --- a/integration_tests/test_api_info.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from base_api_testcase import BaseApiTestCase - - -class ApiInfoTest(BaseApiTestCase): - - def test_the_info_page(self): - response = self.almanachHelper.get(url="{url}/info") - self.assertEqual(response.status_code, 200) diff --git a/integration_tests/test_api_instance_create.py b/integration_tests/test_api_instance_create.py deleted file mode 100644 index 45f3a6e..0000000 --- a/integration_tests/test_api_instance_create.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_testcase import BaseApiTestCase - - -class ApiInstanceCreateTest(BaseApiTestCase): - def test_instance_create(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - list_query = "{url}/project/{project}/instances?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, project=project_id, - start="2016-01-01 18:29:00.000", end="2016-01-01 18:31:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': instance_id, - 'end': None, - 'entity_type': 'instance', - 'flavor': data['flavor'], - 'last_event': '2016-01-01 18:30:00+00:00', - 'name': data['name'], - 'os': { - 'distro': data['os_distro'], - 'os_type': data['os_type'], - 'version': data['os_version'] - }, - 'project_id': project_id, - 'start': '2016-01-01 18:30:00+00:00', - 'metadata': {}})) - - def test_instance_create_bad_date_format(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - data = {'id': instance_id, - 'created_at': 'A_BAD_DATE_FORMAT', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=data, project=project_id) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_instance_create_missing_flavor_param(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=data, project=project_id) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'flavor' param is mandatory for the request you have made." - )) - - def test_instance_create_missing_type_name_param(self): - volume_type_query = "{url}/volume_type" - volume_type_id = str(uuid4()) - data = dict( - type_id=volume_type_id - ) - - response = self.almanachHelper.post(url=volume_type_query, data=data) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'type_name' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_instance_delete.py b/integration_tests/test_api_instance_delete.py deleted file mode 100644 index e8e2eec..0000000 --- a/integration_tests/test_api_instance_delete.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_testcase import BaseApiTestCase - - -class ApiInstanceDelete(BaseApiTestCase): - def test_instance_delete(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - create_data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=create_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - instance_delete_query = "{url}/instance/{instance_id}" - delete_data = {'date': '2016-01-01T18:50:00Z'} - response = self.almanachHelper.delete(url=instance_delete_query, data=delete_data, instance_id=instance_id) - assert_that(response.status_code, equal_to(202)) - - list_query = "{url}/project/{project}/instances?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, - project=project_id, - start="2016-01-01 18:49:00.000", - end="2016-01-01 18:51:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': instance_id, - 'end': '2016-01-01 18:50:00+00:00', - 'entity_type': 'instance', - 'flavor': create_data['flavor'], - 'last_event': '2016-01-01 18:50:00+00:00', - 'name': create_data['name'], - 'os': { - 'distro': create_data['os_distro'], - 'os_type': create_data['os_type'], - 'version': create_data['os_version'] - }, - 'project_id': project_id, - 'start': '2016-01-01 18:30:00+00:00', - 'metadata': {}})) - - def test_instance_delete_bad_date_format(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = str(uuid4()) - instance_id = str(uuid4()) - data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - instance_delete_query = "{url}/instance/{instance_id}" - delete_data = {'date': 'A_BAD_DATE'} - - response = self.almanachHelper.delete(url=instance_delete_query, data=delete_data, instance_id=instance_id) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_instance_delete_missing_param(self): - instance_delete_query = "{url}/instance/{instance_id}" - - response = self.almanachHelper.delete(url=instance_delete_query, data=dict(), instance_id="my_instance_id") - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'date' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_instance_entity.py b/integration_tests/test_api_instance_entity.py deleted file mode 100644 index a840be0..0000000 --- a/integration_tests/test_api_instance_entity.py +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry - -from base_api_testcase import BaseApiTestCase - - -class ApiInstanceEntityTest(BaseApiTestCase): - def test_update_entity_instance_with_multiple_attributes(self): - instance_id = self._create_instance_entity() - - response = self.almanachHelper.put(url="{url}/entity/instance/{instance_id}", - data={"start_date": "2016-04-14T18:30:00.00Z", "flavor": "FlavorB"}, - instance_id=instance_id, - ) - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_entry("entity_id", instance_id)) - assert_that(response.json(), has_entry("start", "2016-04-14 18:30:00+00:00")) - assert_that(response.json(), has_entry("flavor", "FlavorB")) - - def test_update_entity_instance_with_multiple_wrong_attributes(self): - instance_id = self._create_instance_entity() - - response = self.almanachHelper.put(url="{url}/entity/instance/{instance_id}", - data={"start_date": "2016-04-14T18:30:00.00Z", "flavor": 123, "os": 123}, - instance_id=instance_id, - ) - - assert_that(response.status_code, equal_to(400)) - error_dict = response.json()['error'] - assert_that(len(error_dict), equal_to(2)) - assert_that(sorted(error_dict.keys()), equal_to(["flavor", "os"])) - - def test_update_entity_instance_with_one_attribute(self): - instance_id = self._create_instance_entity() - - response = self.almanachHelper.put(url="{url}/entity/instance/{instance_id}", - data={"start_date": "2016-04-14T18:30:00.00Z"}, - instance_id=instance_id, - ) - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_entry("entity_id", instance_id)) - assert_that(response.json(), has_entry("start", "2016-04-14 18:30:00+00:00")) - - def test_update_entity_instance_with_invalid_attribute(self): - project_id = "my_test_project_id" - instance_id = self._create_instance_entity() - data = { - 'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'FreeBSD', - 'os_distro': 'Stable', - 'os_version': '10', - } - - response = self.almanachHelper.post(url="{url}/project/{project}/instance", data=data, - project=project_id) - assert_that(response.status_code, equal_to(201)) - - response = self.almanachHelper.put(url="{url}/entity/instance/{instance_id}", - data={'flavor_flavor': 'FlavorA'}, - instance_id=instance_id, - ) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), equal_to({"error": {"flavor_flavor": "extra keys not allowed"}})) - - def test_update_entity_instance_with_wrong_date_format(self): - instance_id = self._create_instance_entity() - - response = self.almanachHelper.put(url="{url}/entity/instance/{instance_id}", - data={"start_date": "my date"}, - instance_id=instance_id, - ) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), equal_to( - {"error": {"start_date": "value does not match expected format %Y-%m-%dT%H:%M:%S.%fZ"}} - )) - - def test_update_entity_change_flavor_of_closed(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - self.almanachHelper.post(url=instance_create_query, data=data, project=project_id) - instance_delete_query = "{url}/instance/{instance_id}" - delete_data = {'date': '2016-01-01T18:50:00Z'} - self.almanachHelper.delete(url=instance_delete_query, data=delete_data, instance_id=instance_id) - - response = self.almanachHelper.put(url="{url}/entity/instance/{instance_id}?start={start}&end={end}", - start="2016-01-01 18:29:59.0", - end="2016-01-01 18:50:00.0", - data={"flavor": "FlavorB", - "end_date": "2016-01-02 18:50:00.0Z"}, - instance_id=instance_id, - ) - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_entry("flavor", "FlavorB")) - assert_that(response.json(), has_entry("end", "2016-01-02 18:50:00+00:00")) diff --git a/integration_tests/test_api_instance_rebuild.py b/integration_tests/test_api_instance_rebuild.py deleted file mode 100644 index 7bdcec2..0000000 --- a/integration_tests/test_api_instance_rebuild.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_testcase import BaseApiTestCase - - -class ApiInstanceRebuildTest(BaseApiTestCase): - def test_instance_rebuild(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - create_data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '12.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=create_data, project=project_id) - - assert_that(response.status_code, equal_to(201)) - - update_instance_rebuild_query = "{url}/instance/{instance_id}/rebuild" - rebuild_data = { - 'distro': 'Ubuntu', - 'version': '14.04', - 'os_type': 'Linux', - 'rebuild_date': '2016-01-01T18:40:00Z' - } - - response = self.almanachHelper.put(url=update_instance_rebuild_query, data=rebuild_data, - instance_id=instance_id) - - assert_that(response.status_code, equal_to(200)) - - list_query = "{url}/project/{project}/instances?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, project=project_id, - start="2016-01-01 18:39:00.000", end="2016-01-01 18:41:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': instance_id, - 'end': None, - 'entity_type': 'instance', - 'flavor': create_data['flavor'], - 'last_event': '2016-01-01 18:40:00+00:00', - 'name': create_data['name'], - 'os': { - 'distro': create_data['os_distro'], - 'os_type': create_data['os_type'], - 'version': rebuild_data['version'] - }, - 'project_id': project_id, - 'start': '2016-01-01 18:40:00+00:00', - 'metadata': {}})) - - def test_instance_rebuild_bad_date_format(self): - update_instance_rebuild_query = "{url}/instance/{instance_id}/rebuild" - instance_id = str(uuid4()) - rebuild_data = { - 'distro': 'Ubuntu', - 'version': '14.04', - 'os_type': 'Linux', - 'rebuild_date': 'A_BAD_DATE' - } - response = self.almanachHelper.put(url=update_instance_rebuild_query, data=rebuild_data, - instance_id=instance_id) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_instance_rebuild_missing_param(self): - update_instance_rebuild_query = "{url}/instance/{instance_id}/rebuild" - instance_id = str(uuid4()) - rebuild_data = { - 'distro': 'Ubuntu', - 'os_type': 'Linux', - 'rebuild_date': 'A_BAD_DATE' - } - - response = self.almanachHelper.put(url=update_instance_rebuild_query, data=rebuild_data, - instance_id=instance_id) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'version' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_instance_resize.py b/integration_tests/test_api_instance_resize.py deleted file mode 100644 index 7448b72..0000000 --- a/integration_tests/test_api_instance_resize.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_testcase import BaseApiTestCase - - -class ApiInstanceDelete(BaseApiTestCase): - def test_instance_resize(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - create_data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=create_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - instance_resize_query = "{url}/instance/{instance_id}/resize" - resize_data = {'date': '2016-01-01T18:40:00Z', - 'flavor': 'FlavorC'} - - response = self.almanachHelper.put(url=instance_resize_query, data=resize_data, instance_id=instance_id) - assert_that(response.status_code, equal_to(200)) - - list_query = "{url}/project/{project}/instances?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, - project=project_id, - start="2016-01-01 18:39:00.000", - end="2016-01-01 18:41:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': instance_id, - 'end': None, - 'entity_type': 'instance', - 'flavor': resize_data['flavor'], - 'last_event': '2016-01-01 18:40:00+00:00', - 'name': create_data['name'], - 'os': { - 'distro': create_data['os_distro'], - 'os_type': create_data['os_type'], - 'version': create_data['os_version'] - }, - 'project_id': project_id, - 'start': '2016-01-01 18:40:00+00:00', - 'metadata': {}})) - - def test_instance_resize_bad_date_format(self): - instance_resize_query = "{url}/instance/{instance_id}/resize" - resize_data = {'date': 'A_BAD_DATE', - 'flavor': 'FlavorC'} - - response = self.almanachHelper.put(url=instance_resize_query, data=resize_data, instance_id="my_instance_id") - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_instance_resize_missing_param(self): - instance_resize_query = "{url}/instance/{instance_id}/resize" - resize_data = {'flavor': 'FlavorC'} - - response = self.almanachHelper.put(url=instance_resize_query, data=resize_data, instance_id="my_instance_id") - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'date' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_volume_attach.py b/integration_tests/test_api_volume_attach.py deleted file mode 100644 index 1f10a80..0000000 --- a/integration_tests/test_api_volume_attach.py +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTest(BaseApiVolumeTestCase): - def test_volume_attach(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - instance_data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=instance_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - volume_create_query = "{url}/project/{project}/volume" - volume_id = str(uuid4()) - volume_data = {'volume_id': volume_id, - 'attached_to': [], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01T18:30:30Z', - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=volume_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - attach_data = {'date': '2016-01-01T18:40:00Z', 'attachments': [instance_id]} - - volume_attach_query = "{url}/volume/{volume_id}/attach" - response = self.almanachHelper.put(url=volume_attach_query, data=attach_data, volume_id=volume_id) - assert_that(response.status_code, equal_to(200)) - - list_query = "{url}/project/{project}/volumes?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, - project=project_id, - start="2016-01-01 18:39:00.000", - end="2016-01-01 18:41:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': volume_id, - 'attached_to': [instance_id], - 'end': None, - 'name': volume_data['volume_name'], - 'entity_type': 'volume', - 'last_event': '2016-01-01 18:40:00+00:00', - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01 18:40:00+00:00', - 'project_id': project_id, - 'size': volume_data['size']})) - - def test_volume_attach_bad_date_format(self): - volume_attach_query = "{url}/volume/my_test_volume_id/attach" - attach_data = {'date': 'A_BAD_DATE', - 'attachments': ['AN_INSTANCE']} - - response = self.almanachHelper.put(url=volume_attach_query, data=attach_data) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_volume_attach_missing_param(self): - volume_attach_query = "{url}/volume/my_test_volume_id/attach" - attach_data = {'attachments': ['AN_INSTANCE']} - - response = self.almanachHelper.put(url=volume_attach_query, data=attach_data) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'date' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_volume_create.py b/integration_tests/test_api_volume_create.py deleted file mode 100644 index c281978..0000000 --- a/integration_tests/test_api_volume_create.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTest(BaseApiVolumeTestCase): - def test_volume_create(self): - volume_create_query = "{url}/project/{project}/volume" - project_id = "my_test_project_id" - volume_id = str(uuid4()) - data = {'volume_id': volume_id, - 'attached_to': [], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01T18:30:00Z', - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - list_query = "{url}/project/{project}/volumes?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, - project=project_id, - start="2016-01-01 18:29:00.000", end="2016-01-01 18:31:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': volume_id, - 'attached_to': data['attached_to'], - 'end': None, - 'name': data['volume_name'], - 'entity_type': 'volume', - 'last_event': '2016-01-01 18:30:00+00:00', - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01 18:30:00+00:00', - 'project_id': project_id, - 'size': data['size']})) - - def test_volume_create_bad_date_format(self): - volume_create_query = "{url}/project/{project}/volume" - project_id = "my_test_project_id" - volume_id = str(uuid4()) - data = {'volume_id': volume_id, - 'attached_to': [], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': 'BAD_DATE_FORMAT', - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=data, project=project_id) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_volume_create_missing_param(self): - volume_create_query = "{url}/project/{project}/volume" - project_id = "my_test_project_id" - volume_id = str(uuid4()) - data = {'volume_id': volume_id, - 'attached_to': [], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=data, project=project_id) - - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'start' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_volume_delete.py b/integration_tests/test_api_volume_delete.py deleted file mode 100644 index 3895bfa..0000000 --- a/integration_tests/test_api_volume_delete.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTest(BaseApiVolumeTestCase): - def test_volume_delete(self): - volume_create_query = "{url}/project/{project}/volume" - project_id = "my_test_project_id" - volume_id = str(uuid4()) - create_data = {'volume_id': volume_id, - 'attached_to': [], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01T18:30:00Z', - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=create_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - volume_delete_query = "{url}/volume/{volume_id}" - delete_data = {'date': '2016-01-01T18:50:00Z'} - response = self.almanachHelper.delete(url=volume_delete_query, data=delete_data, volume_id=volume_id) - assert_that(response.status_code, equal_to(202)) - - list_query = "{url}/project/{project}/volumes?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, project=project_id, - start="2016-01-01 18:49:00.000", end="2016-01-01 18:51:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': volume_id, - 'attached_to': create_data['attached_to'], - 'end': '2016-01-01 18:50:00+00:00', - 'name': create_data['volume_name'], - 'entity_type': 'volume', - 'last_event': '2016-01-01 18:50:00+00:00', - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01 18:30:00+00:00', - 'project_id': project_id, - 'size': create_data['size']})) - - def test_volume_delete_bad_date_format(self): - volume_delete_query = "{url}/volume/{volume_id}" - delete_data = {'date': 'A_BAD_DATE'} - - response = self.almanachHelper.delete(url=volume_delete_query, data=delete_data, volume_id="my_test_volume_id") - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_volume_delete_missing_param(self): - instance_delete_query = "{url}/volume/{volume_id}" - - response = self.almanachHelper.delete(url=instance_delete_query, data=dict(), volume_id="my_test_volume_id") - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'date' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_volume_detach.py b/integration_tests/test_api_volume_detach.py deleted file mode 100644 index 979ba89..0000000 --- a/integration_tests/test_api_volume_detach.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTest(BaseApiVolumeTestCase): - def test_volume_detach(self): - instance_create_query = "{url}/project/{project}/instance" - project_id = "my_test_project_id" - instance_id = str(uuid4()) - instance_data = {'id': instance_id, - 'created_at': '2016-01-01T18:30:00Z', - 'name': 'integration_test_instance_FlavorA', - 'flavor': 'FlavorA', - 'os_type': 'Linux', - 'os_distro': 'Ubuntu', - 'os_version': '14.04'} - - response = self.almanachHelper.post(url=instance_create_query, data=instance_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - volume_create_query = "{url}/project/{project}/volume" - project_id = "my_test_project_id" - volume_id = str(uuid4()) - volume_data = {'volume_id': volume_id, - 'attached_to': [instance_id], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01T18:30:30Z', - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=volume_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - detach_data = {'date': '2016-01-01T18:40:00Z', - 'attachments': []} - - volume_detach_query = "{url}/volume/{volume_id}/detach" - response = self.almanachHelper.put(url=volume_detach_query, data=detach_data, volume_id=volume_id) - assert_that(response.status_code, equal_to(200)) - - list_query = "{url}/project/{project}/volumes?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, - project=project_id, - start="2016-01-01 18:39:00.000", - end="2016-01-01 18:41:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': volume_id, - 'attached_to': detach_data['attachments'], - 'end': None, - 'name': volume_data['volume_name'], - 'entity_type': 'volume', - 'last_event': '2016-01-01 18:40:00+00:00', - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01 18:40:00+00:00', - 'project_id': project_id, - 'size': volume_data['size']})) - - def test_volume_detach_bad_date_format(self): - volume_detach_query = "{url}/volume/my_test_volume_id/detach" - attach_data = {'date': 'A_BAD_DATE', - 'attachments': ['AN_INSTANCE']} - - response = self.almanachHelper.put(url=volume_detach_query, data=attach_data) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_volume_detach_missing_param(self): - volume_detach_query = "{url}/volume/my_test_volume_id/detach" - attach_data = {'attachments': ['AN_INSTANCE']} - - response = self.almanachHelper.put(url=volume_detach_query, data=attach_data) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'date' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_volume_resize.py b/integration_tests/test_api_volume_resize.py deleted file mode 100644 index b4625df..0000000 --- a/integration_tests/test_api_volume_resize.py +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import has_item - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTest(BaseApiVolumeTestCase): - def test_volume_resize(self): - volume_create_query = "{url}/project/{project}/volume" - project_id = "my_test_project_id" - volume_id = str(uuid4()) - create_data = {'volume_id': volume_id, - 'attached_to': [], - 'volume_name': messages.DEFAULT_VOLUME_NAME, - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01T18:30:00Z', - 'size': 100} - - response = self.almanachHelper.post(url=volume_create_query, data=create_data, project=project_id) - assert_that(response.status_code, equal_to(201)) - - resize_data = {'date': '2016-01-01T18:40:00Z', - 'size': '150'} - - volume_resize_query = "{url}/volume/{volume_id}/resize" - response = self.almanachHelper.put(url=volume_resize_query, data=resize_data, volume_id=volume_id) - assert_that(response.status_code, equal_to(200)) - - list_query = "{url}/project/{project}/volumes?start={start}&end={end}" - response = self.almanachHelper.get(url=list_query, - project=project_id, - start="2016-01-01 18:39:00.000", - end="2016-01-01 18:41:00.000") - - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), has_item({'entity_id': volume_id, - 'attached_to': create_data['attached_to'], - 'end': None, - 'name': create_data['volume_name'], - 'entity_type': 'volume', - 'last_event': '2016-01-01 18:40:00+00:00', - 'volume_type': messages.DEFAULT_VOLUME_TYPE, - 'start': '2016-01-01 18:40:00+00:00', - 'project_id': project_id, - 'size': resize_data['size']})) - - def test_volume_resize_bad_date_format(self): - volume_resize_query = "{url}/volume/my_test_volume_id/resize" - resize_data = {'date': 'A_BAD_DATE', - 'size': '150'} - - response = self.almanachHelper.put(url=volume_resize_query, data=resize_data) - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - 'error', - 'The provided date has an invalid format. Format should be of yyyy-mm-ddThh:mm:ss.msZ, ' - 'ex: 2015-01-31T18:24:34.1523Z' - )) - - def test_volume_resize_missing_param(self): - volume_resize_query = "{url}/volume/my_test_volume_id/resize" - resize_data = {'size': '250'} - - response = self.almanachHelper.put(url=volume_resize_query, data=resize_data, instance_id="my_instance_id") - assert_that(response.status_code, equal_to(400)) - assert_that(response.json(), has_entry( - "error", - "The 'date' param is mandatory for the request you have made." - )) diff --git a/integration_tests/test_api_volume_type.py b/integration_tests/test_api_volume_type.py deleted file mode 100644 index 90e3a60..0000000 --- a/integration_tests/test_api_volume_type.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTypeTest(BaseApiVolumeTestCase): - def test_volume_type_create(self): - volume_type_query = "{url}/volume_type" - volume_type_id = str(uuid4()) - data = dict( - type_id=volume_type_id, - type_name=messages.DEFAULT_VOLUME_NAME - ) - - response = self.almanachHelper.post(url=volume_type_query, data=data) - assert_that(response.status_code, equal_to(201)) - - volume_type_get_query = "{url}/volume_type/{volume_type_id}" - - response = self.almanachHelper.get(url=volume_type_get_query, volume_type_id=volume_type_id) - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), equal_to({'volume_type_id': data['type_id'], - 'volume_type_name': data['type_name']})) diff --git a/integration_tests/test_collector_instance_create.py b/integration_tests/test_collector_instance_create.py deleted file mode 100644 index 21e2aa8..0000000 --- a/integration_tests/test_collector_instance_create.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from datetime import datetime -from retry import retry -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -import pytz - -from base_api_testcase import BaseApiTestCase -from builders.messages import get_instance_create_end_sample - - -class CollectorInstanceCreateTest(BaseApiTestCase): - def test_instance_create(self): - instance_id = str(uuid4()) - tenant_id = str(uuid4()) - - self.rabbitMqHelper.push( - get_instance_create_end_sample( - instance_id=instance_id, - tenant_id=tenant_id, - creation_timestamp=datetime(2016, 2, 1, 9, 0, 0, tzinfo=pytz.utc) - )) - - self.assert_that_instance_entity_is_created(instance_id, tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_instance_entity_is_created(self, instance_id, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("entity_id", instance_id)) diff --git a/integration_tests/test_collector_instance_delete.py b/integration_tests/test_collector_instance_delete.py deleted file mode 100644 index 0f3aa7f..0000000 --- a/integration_tests/test_collector_instance_delete.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from datetime import datetime -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import is_not -import pytz -from retry import retry - -from base_api_testcase import BaseApiTestCase -from builders.messages import get_instance_create_end_sample -from builders.messages import get_instance_delete_end_sample - - -class CollectorInstanceDeleteTest(BaseApiTestCase): - def test_instance_delete(self): - tenant_id = str(uuid.uuid4()) - instance_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push( - get_instance_create_end_sample( - instance_id=instance_id, - tenant_id=tenant_id, - creation_timestamp=datetime(2016, 2, 1, 9, 0, 0, tzinfo=pytz.utc) - )) - - self.rabbitMqHelper.push( - get_instance_delete_end_sample( - instance_id=instance_id, - tenant_id=tenant_id, - deletion_timestamp=datetime(2016, 2, 1, 10, 0, 0, tzinfo=pytz.utc) - )) - - self.assert_instance_entity_is_closed(tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_instance_entity_is_closed(self, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], is_not(has_entry("end", None))) diff --git a/integration_tests/test_collector_instance_delete_before_create.py b/integration_tests/test_collector_instance_delete_before_create.py deleted file mode 100644 index f588227..0000000 --- a/integration_tests/test_collector_instance_delete_before_create.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from datetime import datetime -import uuid - -from hamcrest import assert_that -from hamcrest import has_entry -from hamcrest import is_not -import pytz -from retry import retry - -from base_api_testcase import BaseApiTestCase -from builders.messages import get_instance_create_end_sample -from builders.messages import get_instance_delete_end_sample - - -class CollectorInstanceDeleteBeforeCreateTest(BaseApiTestCase): - def test_when_instance_delete_received_before_create_instance(self): - tenant_id = str(uuid.uuid4()) - instance_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push( - get_instance_delete_end_sample( - instance_id=instance_id, - tenant_id=tenant_id, - deletion_timestamp=datetime(2016, 2, 1, 10, 0, 0, tzinfo=pytz.utc) - )) - - self.rabbitMqHelper.push( - get_instance_create_end_sample( - instance_id=instance_id, - tenant_id=tenant_id, - creation_timestamp=datetime(2016, 2, 1, 9, 0, 0, tzinfo=pytz.utc) - )) - - self.assert_instance_delete_received_before_instance_create(tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_instance_delete_received_before_instance_create(self, tenant_id): - assert_that(self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000"), - is_not(has_entry("end", None))) diff --git a/integration_tests/test_collector_volume_attach.py b/integration_tests/test_collector_volume_attach.py deleted file mode 100644 index 629c7ce..0000000 --- a/integration_tests/test_collector_volume_attach.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeAttachTest(BaseApiVolumeTestCase): - def test_attach_volume(self): - tenant_id = str(uuid.uuid4()) - instance_id = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, tenant_id=tenant_id, volume_type=messages.DEFAULT_VOLUME_TYPE)) - - self.rabbitMqHelper.push(message=messages.get_volume_attach_kilo_end_sample( - volume_id=volume_id, tenant_id=tenant_id, attached_to=[instance_id])) - - self.assert_that_volume_entity_has_instance_attached(tenant_id, instance_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_has_instance_attached(self, tenant_id, instance_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("end", None)) - assert_that(entities[0], has_entry("attached_to", [instance_id])) diff --git a/integration_tests/test_collector_volume_create.py b/integration_tests/test_collector_volume_create.py deleted file mode 100644 index cce2333..0000000 --- a/integration_tests/test_collector_volume_create.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeCreateTest(BaseApiVolumeTestCase): - def test_create_volume(self): - tenant_id = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, tenant_id=tenant_id, volume_type=messages.DEFAULT_VOLUME_TYPE)) - - self.assert_that_volume_entity_is_created(tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_is_created(self, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("end", None)) - assert_that(entities[0], has_entry("attached_to", [])) diff --git a/integration_tests/test_collector_volume_delete.py b/integration_tests/test_collector_volume_delete.py deleted file mode 100644 index e4f60e3..0000000 --- a/integration_tests/test_collector_volume_delete.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from datetime import datetime -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import is_not -import pytz -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeDeleteTest(BaseApiVolumeTestCase): - def test_delete_volume(self): - tenant_id = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, - tenant_id=tenant_id, - volume_type=messages.DEFAULT_VOLUME_TYPE, - creation_timestamp=datetime(2016, 1, 2, 15, 1, 1, tzinfo=pytz.utc) - )) - - self.rabbitMqHelper.push(message=messages.get_volume_delete_end_sample( - volume_id=volume_id, - tenant_id=tenant_id, - volume_type=messages.DEFAULT_VOLUME_TYPE, - deletion_timestamp=datetime(2016, 1, 3, 15, 1, 1, tzinfo=pytz.utc) - )) - - self.assert_that_volume_entity_is_closed(tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_is_closed(self, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], is_not(has_entry("end", None))) diff --git a/integration_tests/test_collector_volume_detach.py b/integration_tests/test_collector_volume_detach.py deleted file mode 100644 index e11c0da..0000000 --- a/integration_tests/test_collector_volume_detach.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeDetachTest(BaseApiVolumeTestCase): - def test_detach_volume(self): - tenant_id = str(uuid.uuid4()) - instance_id = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, tenant_id=tenant_id, volume_type=messages.DEFAULT_VOLUME_TYPE)) - - self.rabbitMqHelper.push(message=messages.get_volume_attach_kilo_end_sample( - volume_id=volume_id, tenant_id=tenant_id, attached_to=[instance_id])) - - self.rabbitMqHelper.push(message=messages.get_volume_detach_kilo_end_sample( - volume_id=volume_id, tenant_id=tenant_id, attached_to=[instance_id])) - - self.assert_that_volume_entity_has_instance_detached(tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_has_instance_detached(self, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("end", None)) - assert_that(entities[0], has_entry("attached_to", [])) diff --git a/integration_tests/test_collector_volume_multi_attach.py b/integration_tests/test_collector_volume_multi_attach.py deleted file mode 100644 index 0b9ba8e..0000000 --- a/integration_tests/test_collector_volume_multi_attach.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeMultiAttachTest(BaseApiVolumeTestCase): - def test_multi_attach_volume(self): - tenant_id = str(uuid.uuid4()) - instance_id1 = str(uuid.uuid4()) - instance_id2 = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, tenant_id=tenant_id, volume_type=messages.DEFAULT_VOLUME_TYPE)) - - self.rabbitMqHelper.push(message=messages.get_volume_attach_kilo_end_sample( - volume_id=volume_id, tenant_id=tenant_id, attached_to=[instance_id1, instance_id2])) - - self.assert_that_volume_entity_has_multiple_instances_attached(tenant_id, instance_id1, instance_id2) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_has_multiple_instances_attached(self, tenant_id, instance_id1, instance_id2): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("end", None)) - assert_that(entities[0], has_entry("attached_to", [instance_id1, instance_id2])) diff --git a/integration_tests/test_collector_volume_multi_detach.py b/integration_tests/test_collector_volume_multi_detach.py deleted file mode 100644 index 4980423..0000000 --- a/integration_tests/test_collector_volume_multi_detach.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeMultiDetachTest(BaseApiVolumeTestCase): - def test_multi_detach_volume(self): - tenant_id = str(uuid.uuid4()) - instance_id1 = str(uuid.uuid4()) - instance_id2 = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, tenant_id=tenant_id, volume_type=messages.DEFAULT_VOLUME_TYPE)) - - self.rabbitMqHelper.push(message=messages.get_volume_attach_kilo_end_sample( - volume_id=volume_id, tenant_id=tenant_id, attached_to=[instance_id1, instance_id2])) - - self.rabbitMqHelper.push(message=messages.get_volume_attach_kilo_end_sample( - volume_id=volume_id, tenant_id=tenant_id, attached_to=[instance_id2])) - - self.assert_that_volume_entity_has_only_one_instance_attached(tenant_id, instance_id2) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_has_only_one_instance_attached(self, tenant_id, instance_id2): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("end", None)) - assert_that(entities[0], has_entry("attached_to", [instance_id2])) diff --git a/integration_tests/test_collector_volume_resize.py b/integration_tests/test_collector_volume_resize.py deleted file mode 100644 index 890f218..0000000 --- a/integration_tests/test_collector_volume_resize.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from datetime import datetime -import uuid - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -from hamcrest import is_not -import pytz -from retry import retry - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class CollectorVolumeResizeTest(BaseApiVolumeTestCase): - def test_resize_volume(self): - tenant_id = str(uuid.uuid4()) - volume_id = str(uuid.uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_create_end_sample( - volume_id=volume_id, - tenant_id=tenant_id, - volume_type=messages.DEFAULT_VOLUME_TYPE, - volume_size=10, - creation_timestamp=datetime(2016, 1, 2, 15, 1, 1, tzinfo=pytz.utc) - )) - - self.rabbitMqHelper.push(message=messages.get_volume_resize_end_sample( - volume_id=volume_id, - tenant_id=tenant_id, - volume_type=messages.DEFAULT_VOLUME_TYPE, - volume_size=100, - timestamp=datetime(2016, 1, 3, 15, 1, 1, tzinfo=pytz.utc) - )) - - self.assert_that_volume_entity_is_created(tenant_id) - - @retry(exceptions=AssertionError, delay=1, max_delay=300) - def assert_that_volume_entity_is_created(self, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(2)) - assert_that(entities[0], is_not(has_entry("end", None))) - assert_that(entities[0], has_entry("size", 10)) - assert_that(entities[1], has_entry("end", None)) - assert_that(entities[1], has_entry("size", 100)) diff --git a/integration_tests/test_collector_volume_type.py b/integration_tests/test_collector_volume_type.py deleted file mode 100644 index 8ae4c06..0000000 --- a/integration_tests/test_collector_volume_type.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to - -from base_api_volume_testcase import BaseApiVolumeTestCase -from builders import messages - - -class ApiVolumeTypeTest(BaseApiVolumeTestCase): - def test_volume_type_create(self): - volume_type_id = str(uuid4()) - volume_type_name = str(uuid4()) - - self.rabbitMqHelper.push(message=messages.get_volume_type_create_sample( - volume_type_id=volume_type_id, volume_type_name=volume_type_name) - ) - - self._wait_until_volume_type_is_created(volume_type_id=volume_type_id) - - volume_type_get_query = "{url}/volume_type/{volume_type_id}" - response = self.almanachHelper.get(url=volume_type_get_query, volume_type_id=volume_type_id) - assert_that(response.status_code, equal_to(200)) - assert_that(response.json(), equal_to({'volume_type_id': volume_type_id, - 'volume_type_name': volume_type_name})) diff --git a/integration_tests/test_metadata_instance_create.py b/integration_tests/test_metadata_instance_create.py deleted file mode 100644 index 2128bd3..0000000 --- a/integration_tests/test_metadata_instance_create.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2016 Internap. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from datetime import datetime -from uuid import uuid4 - -from hamcrest import assert_that -from hamcrest import equal_to -from hamcrest import has_entry -import pytz - -from integration_tests.base_api_testcase import BaseApiTestCase -from integration_tests.builders.messages import get_instance_create_end_sample - - -class MetadataInstanceCreateTest(BaseApiTestCase): - def test_instance_create_with_metadata(self): - instance_id = str(uuid4()) - tenant_id = str(uuid4()) - - self.rabbitMqHelper.push( - get_instance_create_end_sample( - instance_id=instance_id, - tenant_id=tenant_id, - creation_timestamp=datetime(2016, 2, 1, 9, 0, 0, tzinfo=pytz.utc), - metadata={"metering.billing_mode": "42"} - )) - - self.assert_that_instance_entity_is_created_and_have_proper_metadata(instance_id, tenant_id) - - def assert_that_instance_entity_is_created_and_have_proper_metadata(self, instance_id, tenant_id): - entities = self.almanachHelper.get_entities(tenant_id, "2016-01-01 00:00:00.000") - assert_that(len(entities), equal_to(1)) - assert_that(entities[0], has_entry("entity_id", instance_id)) - assert_that(entities[0], has_entry("metadata", {'metering.billing_mode': '42'})) diff --git a/tox-integration.ini b/tox-integration.ini deleted file mode 100644 index 032d3cb..0000000 --- a/tox-integration.ini +++ /dev/null @@ -1,8 +0,0 @@ -[tox] -envlist = integration-tests -skipsdist = True - -[testenv:integration-tests] -passenv = * -deps = -r{toxinidir}/integration-test-requirements.txt -commands = nosetests --nocapture --verbosity 2 --tests integration_tests