Class: AWSCDK::CloudAssemblySchema::TestCase

Inherits:
TestOptions
  • Object
show all
Defined in:
cloud_assembly_schema/test_case.rb

Overview

Represents an integration test case.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_delete_failures: nil, allow_destroy: nil, cdk_command_options: nil, diff_assets: nil, hooks: nil, regions: nil, stack_update_workflow: nil, stacks:, assertion_stack: nil, assertion_stack_name: nil) ⇒ TestCase

Returns a new instance of TestCase.

Parameters:

  • allow_delete_failures (Boolean, nil) (defaults to: nil)

    Whether to allow resources that fail to delete during a stack update.

  • allow_destroy (Array<String>, nil) (defaults to: nil)

    List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test.

  • cdk_command_options (AWSCDK::CloudAssemblySchema::CDKCommands, nil) (defaults to: nil)

    Additional options to use for each CDK command.

  • diff_assets (Boolean, nil) (defaults to: nil)

    Whether or not to include asset hashes in the diff Asset hashes can introduces a lot of unneccessary noise into tests, but there are some cases where asset hashes should be included.

  • hooks (AWSCDK::CloudAssemblySchema::Hooks, nil) (defaults to: nil)

    Additional commands to run at predefined points in the test workflow.

  • regions (Array<String>, nil) (defaults to: nil)

    Limit deployment to these regions.

  • stack_update_workflow (Boolean, nil) (defaults to: nil)

    Run update workflow on this test case This should only be set to false to test scenarios that are not possible to test as part of the update workflow.

  • stacks (Array<String>)

    Stacks that should be tested as part of this test case The stackNames will be passed as args to the cdk commands so dependent stacks will be automatically deployed unless exclusively is passed.

  • assertion_stack (String, nil) (defaults to: nil)

    The node id of the stack that contains assertions.

  • assertion_stack_name (String, nil) (defaults to: nil)

    The name of the stack that contains assertions.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'cloud_assembly_schema/test_case.rb', line 17

def initialize(allow_delete_failures: nil, allow_destroy: nil, cdk_command_options: nil, diff_assets: nil, hooks: nil, regions: nil, stack_update_workflow: nil, stacks:, assertion_stack: nil, assertion_stack_name: nil)
  @allow_delete_failures = allow_delete_failures
  Jsii::Type.check_type(@allow_delete_failures, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "allowDeleteFailures") unless @allow_delete_failures.nil?
  @allow_destroy = allow_destroy
  Jsii::Type.check_type(@allow_destroy, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowDestroy") unless @allow_destroy.nil?
  @cdk_command_options = cdk_command_options.is_a?(Hash) ? ::AWSCDK::CloudAssemblySchema::CDKCommands.new(**cdk_command_options.transform_keys(&:to_sym)) : cdk_command_options
  Jsii::Type.check_type(@cdk_command_options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZF9hc3NlbWJseV9zY2hlbWEuQ2RrQ29tbWFuZHMifQ==")), "cdkCommandOptions") unless @cdk_command_options.nil?
  @diff_assets = diff_assets
  Jsii::Type.check_type(@diff_assets, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "diffAssets") unless @diff_assets.nil?
  @hooks = hooks.is_a?(Hash) ? ::AWSCDK::CloudAssemblySchema::Hooks.new(**hooks.transform_keys(&:to_sym)) : hooks
  Jsii::Type.check_type(@hooks, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZF9hc3NlbWJseV9zY2hlbWEuSG9va3MifQ==")), "hooks") unless @hooks.nil?
  @regions = regions
  Jsii::Type.check_type(@regions, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "regions") unless @regions.nil?
  @stack_update_workflow = stack_update_workflow
  Jsii::Type.check_type(@stack_update_workflow, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "stackUpdateWorkflow") unless @stack_update_workflow.nil?
  @stacks = stacks
  Jsii::Type.check_type(@stacks, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "stacks")
  @assertion_stack = assertion_stack
  Jsii::Type.check_type(@assertion_stack, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assertionStack") unless @assertion_stack.nil?
  @assertion_stack_name = assertion_stack_name
  Jsii::Type.check_type(@assertion_stack_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assertionStackName") unless @assertion_stack_name.nil?
end

Instance Attribute Details

#allow_delete_failuresBoolean? (readonly)

Note:

Default: false

Whether to allow resources that fail to delete during a stack update.

When false, the test will fail if CloudFormation skips deleting a resource during a stack update. When true, only a warning is printed.

Returns:

  • (Boolean, nil)


47
48
49
# File 'cloud_assembly_schema/test_case.rb', line 47

def allow_delete_failures
  @allow_delete_failures
end

#allow_destroyArray<String>? (readonly)

Note:

Default: - do not allow destruction of any resources on update

List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test.

This list should only include resources that for this specific integration test we are sure will not cause errors or an outage if destroyed. For example, maybe we know that a new resource will be created first before the old resource is destroyed which prevents any outage.

e.g. ['AWS::IAM::Role']

Returns:

  • (Array<String>, nil)


59
60
61
# File 'cloud_assembly_schema/test_case.rb', line 59

def allow_destroy
  @allow_destroy
end

#assertion_stackString? (readonly)

Note:

Default: - no assertion stack

The node id of the stack that contains assertions.

This is the value that can be used to deploy the stack with the CDK CLI

Returns:

  • (String, nil)


100
101
102
# File 'cloud_assembly_schema/test_case.rb', line 100

def assertion_stack
  @assertion_stack
end

#assertion_stack_nameString? (readonly)

Note:

Default: - no assertion stack

The name of the stack that contains assertions.

Returns:

  • (String, nil)


105
106
107
# File 'cloud_assembly_schema/test_case.rb', line 105

def assertion_stack_name
  @assertion_stack_name
end

#cdk_command_optionsAWSCDK::CloudAssemblySchema::CDKCommands? (readonly)

Note:

Default: - runner default options

Additional options to use for each CDK command.



64
65
66
# File 'cloud_assembly_schema/test_case.rb', line 64

def cdk_command_options
  @cdk_command_options
end

#diff_assetsBoolean? (readonly)

Note:

Default: false

Whether or not to include asset hashes in the diff Asset hashes can introduces a lot of unneccessary noise into tests, but there are some cases where asset hashes should be included.

For example any tests involving custom resources or bundling

Returns:

  • (Boolean, nil)


72
73
74
# File 'cloud_assembly_schema/test_case.rb', line 72

def diff_assets
  @diff_assets
end

#hooksAWSCDK::CloudAssemblySchema::Hooks? (readonly)

Note:

Default: - no hooks

Additional commands to run at predefined points in the test workflow.

e.g. { postDeploy: ['yarn', 'test'] }



79
80
81
# File 'cloud_assembly_schema/test_case.rb', line 79

def hooks
  @hooks
end

#regionsArray<String>? (readonly)

Note:

Default: - can run in any region

Limit deployment to these regions.

Returns:

  • (Array<String>, nil)


84
85
86
# File 'cloud_assembly_schema/test_case.rb', line 84

def regions
  @regions
end

#stack_update_workflowBoolean? (readonly)

Note:

Default: true

Run update workflow on this test case This should only be set to false to test scenarios that are not possible to test as part of the update workflow.

Returns:

  • (Boolean, nil)


89
90
91
# File 'cloud_assembly_schema/test_case.rb', line 89

def stack_update_workflow
  @stack_update_workflow
end

#stacksArray<String> (readonly)

Stacks that should be tested as part of this test case The stackNames will be passed as args to the cdk commands so dependent stacks will be automatically deployed unless exclusively is passed.

Returns:

  • (Array<String>)


93
94
95
# File 'cloud_assembly_schema/test_case.rb', line 93

def stacks
  @stacks
end

Class Method Details

.jsii_propertiesObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'cloud_assembly_schema/test_case.rb', line 107

def self.jsii_properties
  {
    :allow_delete_failures => "allowDeleteFailures",
    :allow_destroy => "allowDestroy",
    :cdk_command_options => "cdkCommandOptions",
    :diff_assets => "diffAssets",
    :hooks => "hooks",
    :regions => "regions",
    :stack_update_workflow => "stackUpdateWorkflow",
    :stacks => "stacks",
    :assertion_stack => "assertionStack",
    :assertion_stack_name => "assertionStackName",
  }
end

Instance Method Details

#to_jsiiObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'cloud_assembly_schema/test_case.rb', line 122

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "allowDeleteFailures" => @allow_delete_failures,
    "allowDestroy" => @allow_destroy,
    "cdkCommandOptions" => @cdk_command_options,
    "diffAssets" => @diff_assets,
    "hooks" => @hooks,
    "regions" => @regions,
    "stackUpdateWorkflow" => @stack_update_workflow,
    "stacks" => @stacks,
    "assertionStack" => @assertion_stack,
    "assertionStackName" => @assertion_stack_name,
  })
  result.compact
end