From cf9cdbb58f8339280d4c7571b3bbd4c117027786 Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Thu, 22 Sep 2016 20:29:10 -0700 Subject: [PATCH] Remove dependency on stacker_blueprints --- setup.py | 1 - stacker/tests/factories.py | 4 +- stacker/tests/fixtures/__init__.py | 0 stacker/tests/fixtures/mock_blueprints.py | 93 +++++++++++++++++++ .../tests/fixtures/vpc-bastion-db-web.yaml | 33 +------ stacker/tests/test_plan.py | 1 + 6 files changed, 98 insertions(+), 34 deletions(-) create mode 100644 stacker/tests/fixtures/__init__.py create mode 100644 stacker/tests/fixtures/mock_blueprints.py diff --git a/setup.py b/setup.py index 96ed88109..4cde24266 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ tests_require = [ "nose~=1.0", "mock~=2.0.0", - "stacker_blueprints~=0.6.0", "moto~=0.4.25", "testfixtures~=4.10.0", ] diff --git a/stacker/tests/factories.py b/stacker/tests/factories.py index 068b4d356..ed6bbf8d7 100644 --- a/stacker/tests/factories.py +++ b/stacker/tests/factories.py @@ -4,8 +4,8 @@ def generate_definition(base_name, stack_id, **overrides): definition = { "name": "%s.%d" % (base_name, stack_id), - "class_path": "stacker_blueprints.%s.%s" % (base_name, - base_name.upper()), + "class_path": "stacker.tests.fixtures.mock_blueprints.%s" % ( + base_name.upper()), "namespace": "example-com", "parameters": { "InstanceType": "m3.medium", diff --git a/stacker/tests/fixtures/__init__.py b/stacker/tests/fixtures/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/stacker/tests/fixtures/mock_blueprints.py b/stacker/tests/fixtures/mock_blueprints.py new file mode 100644 index 000000000..bd09b9be9 --- /dev/null +++ b/stacker/tests/fixtures/mock_blueprints.py @@ -0,0 +1,93 @@ +from stacker.blueprints.base import Blueprint + + +class VPC(Blueprint): + LOCAL_PARAMETERS = { + "AZCount": { + "type": int, + "default": 2, + } + } + + PARAMETERS = { + "PrivateSubnets": { + "type": "CommaDelimitedList", + "description": "Comma separated list of subnets to use for " + "non-public hosts. NOTE: Must have as many subnets " + "as AZCount"}, + "PublicSubnets": { + "type": "CommaDelimitedList", + "description": "Comma separated list of subnets to use for " + "public hosts. NOTE: Must have as many subnets " + "as AZCount"}, + "InstanceType": { + "type": "String", + "description": "NAT EC2 instance type.", + "default": "m3.medium"}, + "SshKeyName": { + "type": "AWS::EC2::KeyPair::KeyName"}, + "BaseDomain": { + "type": "String", + "default": "", + "description": "Base domain for the stack."}, + "InternalDomain": { + "type": "String", + "default": "", + "description": "Internal domain name, if you have one."}, + "CidrBlock": { + "type": "String", + "description": "Base CIDR block for subnets.", + "default": "10.128.0.0/16"}, + "ImageName": { + "type": "String", + "description": "The image name to use from the AMIMap (usually " + "found in the config file.)", + "default": "NAT"}, + "UseNatGateway": { + "type": "String", + "allowed_values": ["true", "false"], + "description": "If set to true, will configure a NAT Gateway" + "instead of NAT instances.", + "default": "false"}, + } + + def create_template(self): + return + + +class Bastion(Blueprint): + PARAMETERS = { + "VpcId": {"type": "AWS::EC2::VPC::Id", "description": "Vpc Id"}, + "DefaultSG": {"type": "AWS::EC2::SecurityGroup::Id", + "description": "Top level security group."}, + "PublicSubnets": {"type": "List", + "description": "Subnets to deploy public " + "instances in."}, + "PrivateSubnets": {"type": "List", + "description": "Subnets to deploy private " + "instances in."}, + "AvailabilityZones": {"type": "CommaDelimitedList", + "description": "Availability Zones to deploy " + "instances in."}, + "InstanceType": {"type": "String", + "description": "EC2 Instance Type", + "default": "m3.medium"}, + "MinSize": {"type": "Number", + "description": "Minimum # of instances.", + "default": "1"}, + "MaxSize": {"type": "Number", + "description": "Maximum # of instances.", + "default": "5"}, + "SshKeyName": {"type": "AWS::EC2::KeyPair::KeyName"}, + "OfficeNetwork": { + "type": "String", + "description": "CIDR block allowed to connect to bastion hosts."}, + "ImageName": { + "type": "String", + "description": "The image name to use from the AMIMap (usually " + "found in the config file.)", + "default": "bastion"}, + } + + def create_template(self): + return diff --git a/stacker/tests/fixtures/vpc-bastion-db-web.yaml b/stacker/tests/fixtures/vpc-bastion-db-web.yaml index 941a8b65e..4a4aeaec7 100644 --- a/stacker/tests/fixtures/vpc-bastion-db-web.yaml +++ b/stacker/tests/fixtures/vpc-bastion-db-web.yaml @@ -30,7 +30,7 @@ vpc_parameters: &vpc_parameters stacks: - name: vpc - class_path: stacker_blueprints.vpc.VPC + class_path: stacker.tests.fixtures.mock_blueprints.VPC parameters: InstanceType: m3.medium SshKeyName: default @@ -48,7 +48,7 @@ stacks: # Options #InternalDomain: internal - name: bastion - class_path: stacker_blueprints.bastion.Bastion + class_path: stacker.tests.fixtures.mock_blueprints.Bastion parameters: # Extends the parameters dict with the contents of the vpc_parameters # anchor. Basically we're including all VPC Outputs in the parameters @@ -63,32 +63,3 @@ stacks: MaxSize: 2 SshKeyName: default ImageName: bastion - - name: myDB - class_path: stacker_blueprints.postgres.PostgresRDS - parameters: - << : *vpc_parameters - InstanceType: db.m3.medium - AllocatedStorage: 10 - MasterUser: dbuser - MasterUserPassword: ExamplePassword! - DBName: db1 - # If the following are uncommented and you set an InternalDomain above - # in the VPC a CNAME alias of InternalHostname will be setup pointing at - # the database. - #InternalZoneId: vpc::InternalZoneId - #InternalZoneName: vpc::InternalZoneName - #InternalHostname: mydb - - name: myWeb - class_path: stacker_blueprints.asg.AutoscalingGroup - parameters: - << : *vpc_parameters - InstanceType: m3.medium - ImageName: ubuntu1404 - MinSize: 2 - MaxSize: 2 - SshKeyName: default - # If commented out, no load balancer will be created. - ELBHostName: mysite - # Uncomment if you have a cert loaded in EC2 already and want to enable - # SSL on the load balancer. - #ELBCertName: mycert diff --git a/stacker/tests/test_plan.py b/stacker/tests/test_plan.py index ff9efc517..f719f928d 100644 --- a/stacker/tests/test_plan.py +++ b/stacker/tests/test_plan.py @@ -1,4 +1,5 @@ import unittest + import mock from stacker.context import Context