8000 Formalize the existence of external (read-only) stacks by danielkza · Pull Request #618 · cloudtools/stacker · GitHub
[go: up one dir, main page]

Skip to content

Formalize the existence of external (read-only) stacks #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
tests: add functional tests for external stacks
  • Loading branch information
danielkza committed Mar 29, 2019
commit fc868ad1aaf84a3fa9e18fc43d75fb3f0d917243
3 changes: 1 addition & 2 deletions stacker/tests/actions/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
from __future__ import absolute_import
from builtins import str
import unittest
from collections import namedtuple

import mock

from stacker import exceptions
from stacker.actions import build
from stacker.session_cache import get_session
from stacker.actions.build import (
_resolve_parameters,
_handle_missing_parameters,
Expand All @@ -20,6 +18,7 @@
from stacker.exceptions import StackDidNotChange, StackDoesNotExist
from stacker.providers.base import BaseProvider
from stacker.providers.aws.default import Provider
from stacker.session_cache import get_session
from stacker.status import (
NotSubmittedStatus,
COMPLETE,
Expand Down
2 changes: 2 additions & 0 deletions stacker/tests/fixtures/mock_blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ class Dummy(Blueprint):
}

def create_template(self):
input = self.get_variables()["StringVariable"]
self.template.add_resource(WaitConditionHandle("Dummy"))
self.template.add_output(Output("DummyId", Value="dummy-1234"))
self.template.add_output(Output("StringOutput", Value=input))
self.template.add_output(Output("Region", Value=Ref("AWS::Region")))


Expand Down
74 changes: 74 additions & 0 deletions tests/test_suite/34_stacker_build-external-stacks.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bats

load ../test_helper

@test "stacker build - external stack" {
needs_aws

config1() {
cat <<EOF
namespace: ${STACKER_NAMESPACE}
stacks:
- name: vpc/west
stack_name: external-vpc
profile: stacker
region: us-west-1
class_path: stacker.tests.fixtures.mock_blueprints.Dummy
- name: vpc/east
stack_name: external-vpc
profile: stacker
region: us-east-1
class_path: stacker.tests.fixtures.mock_blueprints.Dummy
EOF
}

config2() {
cat <<EOF
namespace: ${STACKER_NAMESPACE}
stacks:
- name: vpc/west
stack_name: external-vpc
profile: stacker
region: us-west-1
external: yes
- name: vpc/east
fqn: ${STACKER_NAMESPACE}-external-vpc
profile: stacker
region: us-east-1
external: yes
- name: vpc/combo
stack_name: vpc
profile: stacker
region: us-east-1
class_path: stacker.tests.fixtures.mock_blueprints.Dummy
variables:
StringVariable: >-
\${output vpc/west::Region}
\${output vpc/east::Region}
EOF
}

teardown() {
stacker destroy --force <(config2)
stacker destroy --force <(config1)
}

# Create the new stacks.
stacker build <(config1)
assert "$status" -eq 0
assert_has_line "Using default AWS provider mode"
assert_has_line "vpc/west: submitted (creating new stack)"
assert_has_line "vpc/west: complete (creating new stack)"
assert_has_line "vpc/east: submitted (creating new stack)"
assert_has_line "vpc/east: complete (creating new stack)"

stacker build <(config2)
assert "$status" -eq 0
assert_has_line "Using default AWS provider mode"
assert_has_line "vpc/combo: submitted (creating new stack)"
assert_has_line "vpc/combo: complete (creating new stack)"

stacker info <(config2)
assert_has_line "StringOutput: us-west-1 us-east-1"

}
0