aws-must-templates 0.1.6 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +97 -44
- data/lib/tasks/cross-ref.rb +6 -0
- data/lib/tasks/suite.rake +150 -48
- data/lib/test-suites/test_suites.rb +13 -13
- data/mustache/commonDependsOn.mustache +24 -2
- data/mustache/commonRef.mustache +22 -0
- data/mustache/commonValue.mustache +1 -1
- data/mustache/commonXGressRule.mustache +31 -0
- data/mustache/mapping.mustache +3 -1
- data/mustache/mappingAmazonVpcNat.mustache +38 -0
- data/mustache/resource.mustache +4 -0
- data/mustache/resourceInstance.mustache +26 -7
- data/mustache/resourceInternetGateway.mustache +30 -16
- data/mustache/resourceRoute.mustache +50 -0
- data/mustache/resourceRouteTable.mustache +67 -0
- data/mustache/resourceSecurityGroup.mustache +13 -12
- data/mustache/resourceSubnet.mustache +20 -8
- data/mustache/root.mustache +26 -11
- data/spec/aws-must-templates/AllwaysOk/AllwaysOk_spec.rb +35 -0
- data/spec/aws-must-templates/AwsCommandLineInterfaceInstalled/AwsCommandLineInterfaceInstalled_spec.rb +19 -1
- data/spec/aws-must-templates/AwsMustTestRunnerProperties/AwsMustTestRunnerProperties_spec.rb +16 -1
- data/spec/aws-must-templates/CloudFormationHelperScriptsInstalled/CloudFormationHelperScriptsInstalled_spec.rb +17 -0
- data/spec/aws-must-templates/Ec2InstanceType/Ec2InstanceType_spec.rb +47 -0
- data/spec/aws-must-templates/Ec2PrivateIp/Ec2PrivateIp_spec.rb +49 -0
- data/spec/aws-must-templates/Ec2PublicIp/Ec2PublicIp_spec.rb +68 -0
- data/spec/aws-must-templates/Ec2Routes/Ec2Routes_spec.rb +69 -0
- data/spec/aws-must-templates/Ec2SecurityGroups/Ec2SecurityGroups_spec.rb +151 -0
- data/spec/aws-must-templates/Ec2StatusNormal/Ec2StatusNormal_spec.rb +55 -0
- data/spec/aws-must-templates/NetworkCanPing/NetworkCanPing_spec.rb +36 -0
- data/spec/aws-must-templates/ParameterTest/ParameterTest_spec.rb +17 -1
- data/spec/aws-must-templates/RespondsToPing/RespondsToPing_spec.rb +46 -0
- data/spec/aws-must-templates/S3NoAccess/S3NoAccess_spec.rb +17 -3
- data/spec/aws-must-templates/S3ReadAccessAllowed/S3ReadAccessAllowed_spec.rb +18 -1
- data/spec/aws-must-templates/Stack/Stack_spec.rb +28 -1
- data/spec/aws-must-templates/ValidOSVersion/ValidOSVersion_spec.rb +16 -1
- data/spec/aws-must-templates/Vpc/vpc_spec.rb +51 -0
- data/spec/aws-must-templates/table_of_content.mustache +67 -0
- data/spec/lib/test_suites_spec.rb +101 -28
- data/spec/mustache/commonDependsOn_spec.rb +57 -2
- data/spec/mustache/commonInstanceType_spec.rb +1 -1
- data/spec/mustache/mappingAmazonVpcNat_spec.rb +56 -0
- data/spec/mustache/mapping_spec.rb +48 -7
- data/spec/mustache/resourceInstance_spec.rb +102 -1
- data/spec/mustache/resourceInternetGateway_spec.rb +14 -9
- data/spec/mustache/resourcePolicy_spec.rb +1 -1
- data/spec/mustache/resourceS3Bucket_spec.rb +1 -1
- data/spec/mustache/resourceSecurityGroup_spec.rb +3 -3
- data/spec/mustache/resourceSubnet_spec.rb +50 -3
- data/spec/support/lib/aws/aws.rb +6 -0
- data/spec/support/lib/aws/ec2_resource.rb +177 -0
- data/spec/support/lib/aws/mixin_cidr.rb +18 -0
- data/spec/support/lib/aws/mixin_ec2.rb +53 -0
- data/spec/support/lib/aws/mixin_security_group.rb +15 -0
- data/spec/support/lib/aws/mixin_subnet.rb +77 -0
- data/spec/support/lib/aws/mixin_vpc.rb +10 -0
- data/spec/support/lib/aws/route_resource.rb +86 -0
- data/spec/support/lib/aws/security_group_resource.rb +120 -0
- data/spec/support/lib/aws/vpc_resource.rb +69 -0
- data/spec/support/lib/suite_value.rb +38 -0
- data/spec/support/lib/test_parameter.rb +12 -8
- data/spec/support/lib/valid_property.rb +29 -9
- data/spec/support/spec_helper.rb +75 -44
- data/spec/support/utils.rb +4 -0
- metadata +34 -24
@@ -1,6 +1,22 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="AwsCommandLineInterfaceInstalled"></a>AwsCommandLineInterfaceInstalled<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate that command `aws` is installed.
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
|
1
15
|
require 'spec_helper'
|
2
16
|
|
3
|
-
|
17
|
+
current_test = File.basename File.dirname __FILE__
|
18
|
+
|
19
|
+
describe current_test do
|
4
20
|
|
5
21
|
describe command('type aws') do
|
6
22
|
its( :exit_status ) { should eq 0 }
|
@@ -8,3 +24,5 @@ describe "AwsCommandLineInterfaceInstalled" do
|
|
8
24
|
|
9
25
|
|
10
26
|
end
|
27
|
+
|
28
|
+
# +++fold-off+++
|
data/spec/aws-must-templates/AwsMustTestRunnerProperties/AwsMustTestRunnerProperties_spec.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
=begin
|
4
|
+
|
5
|
+
+++start+++
|
6
|
+
|
7
|
+
## <a id="AwsMustTestRunnerProperties"></a>AwsMustTestRunnerProperties<a class='navigator' href='#top'>[top]</a>
|
8
|
+
|
9
|
+
Validata that Test Runner works correctly and set properties
|
10
|
+
|
11
|
+
+++close+++
|
12
|
+
|
13
|
+
=end
|
14
|
+
|
15
|
+
# +++fold-on+++
|
3
16
|
|
4
17
|
|
5
18
|
# ------------------------------------------------------------------
|
6
19
|
# Configuration
|
7
20
|
#
|
8
21
|
|
9
|
-
current_test =
|
22
|
+
current_test = File.basename File.dirname __FILE__
|
10
23
|
|
11
24
|
# every suite should define these paramentes
|
12
25
|
system_properties = [
|
@@ -37,3 +50,5 @@ describe current_test do
|
|
37
50
|
|
38
51
|
end
|
39
52
|
|
53
|
+
# +++fold-off+++
|
54
|
+
|
@@ -1,3 +1,17 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="CloudFormationHelperScriptsInstalled"></a>CloudFormationHelperScriptsInstalled<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate that CloudFormation Helper script is installed.
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
|
1
15
|
require 'spec_helper'
|
2
16
|
|
3
17
|
describe "CloudFormationHelperScriptsInstalled" do
|
@@ -19,3 +33,6 @@ describe "CloudFormationHelperScriptsInstalled" do
|
|
19
33
|
end
|
20
34
|
|
21
35
|
end
|
36
|
+
|
37
|
+
|
38
|
+
# +++fold-off+++
|
@@ -0,0 +1,47 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Ec2InstanceType"></a>Ec2InstanceType<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates `InstanceType` of EC2 `InstanceId` as returned by `describe_instance_attribute`
|
8
|
+
|
9
|
+
* `:instance_type` == `InstanceType`
|
10
|
+
|
11
|
+
**Parameters**
|
12
|
+
|
13
|
+
- `test_parameter( current_test, "InstanceType" )`
|
14
|
+
|
15
|
+
+++close+++
|
16
|
+
|
17
|
+
=end
|
18
|
+
|
19
|
+
# +++fold-on+++
|
20
|
+
|
21
|
+
require 'spec_helper'
|
22
|
+
|
23
|
+
current_test = File.basename File.dirname __FILE__
|
24
|
+
|
25
|
+
describe current_test do
|
26
|
+
|
27
|
+
# ------------------------------------------------------------------
|
28
|
+
# test parameters
|
29
|
+
|
30
|
+
instance = suite_value( :instance_name ) # set in spec_helper
|
31
|
+
instanceType = test_parameter( current_test, "InstanceType" )
|
32
|
+
|
33
|
+
# ------------------------------------------------------------------
|
34
|
+
# tests
|
35
|
+
describe "instance '#{instance.value}'" do
|
36
|
+
|
37
|
+
|
38
|
+
describe ec2_named_resource( instance ) do
|
39
|
+
its( :instance_type ) { should eq instanceType.value }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# +++fold-off+++
|
@@ -0,0 +1,49 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Ec2PrivateIp"></a>Ec2PrivateIp<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates EC2 `InstanceId` public ip 'private_ip_address' is with
|
8
|
+
`CidrBlock`
|
9
|
+
|
10
|
+
**Parameters**
|
11
|
+
|
12
|
+
* `instance = suite_value( :instance_name )` : name of instance being tested
|
13
|
+
* `test_parameter( current_test, "CidrBlock" )` : mandatory, should be valid Cidr
|
14
|
+
|
15
|
+
+++close+++
|
16
|
+
|
17
|
+
=end
|
18
|
+
|
19
|
+
# +++fold-on+++
|
20
|
+
|
21
|
+
require 'spec_helper'
|
22
|
+
|
23
|
+
current_test = File.basename File.dirname __FILE__
|
24
|
+
|
25
|
+
describe current_test do
|
26
|
+
|
27
|
+
# ------------------------------------------------------------------
|
28
|
+
# test parameters
|
29
|
+
|
30
|
+
instance = suite_value( :instance_name ) # set in spec_helper
|
31
|
+
cidr_block = test_parameter( current_test, "CidrBlock" )
|
32
|
+
|
33
|
+
# ------------------------------------------------------------------
|
34
|
+
# tests
|
35
|
+
describe "instance '#{instance.value}'" do
|
36
|
+
|
37
|
+
describe ec2_named_resource_attribute( instance, "private_ip_address" ) do
|
38
|
+
|
39
|
+
it "#valid cidr #{cidr_block.value}" do
|
40
|
+
expect( subject.private_ip_address_valid_cidr?( cidr_block.value ) ).to eql( true )
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end # instance
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# +++fold-off+++
|
@@ -0,0 +1,68 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Ec2PublicIp"></a>Ec2PublicIp<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates that EC2 `InstanceId` `:public_ip_address` (none/defined/CidrBlock)
|
8
|
+
|
9
|
+
**Parameters**
|
10
|
+
|
11
|
+
* `instance = suite_value( :instance_name )` : name of instance being tested
|
12
|
+
* `test_parameter( current_test, "PublicIp" )` valid values
|
13
|
+
* `nil` OR `none` : should not be defined
|
14
|
+
* V4 address public_ip_address belong to CidrBlock
|
15
|
+
* `defined`: should not be nill
|
16
|
+
|
17
|
+
+++close+++
|
18
|
+
|
19
|
+
=end
|
20
|
+
|
21
|
+
# +++fold-on+++
|
22
|
+
|
23
|
+
require 'spec_helper'
|
24
|
+
|
25
|
+
current_test = File.basename File.dirname __FILE__
|
26
|
+
|
27
|
+
describe current_test do
|
28
|
+
|
29
|
+
# ------------------------------------------------------------------
|
30
|
+
# test parameters
|
31
|
+
|
32
|
+
instance = suite_value( :instance_name ) # set in spec_help
|
33
|
+
public_ip = test_parameter( current_test, "PublicIp" )
|
34
|
+
|
35
|
+
|
36
|
+
# ------------------------------------------------------------------
|
37
|
+
# tests
|
38
|
+
describe "instance '#{instance.value}'" do
|
39
|
+
|
40
|
+
|
41
|
+
describe "Public IP" do
|
42
|
+
|
43
|
+
case public_ip.value
|
44
|
+
|
45
|
+
when /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z/
|
46
|
+
describe ec2_named_resource_attribute( instance, "public_ip_address" ) do
|
47
|
+
its( :public_ip_address ) { should eql public_ip.value }
|
48
|
+
end
|
49
|
+
when "none", "nil"
|
50
|
+
describe ec2_named_resource( instance ) do
|
51
|
+
its( :public_ip_address ) { should eql nil }
|
52
|
+
end
|
53
|
+
when "defined"
|
54
|
+
describe ec2_named_resource( instance ) do
|
55
|
+
its( :public_ip_address ) { should_not eql nil }
|
56
|
+
end
|
57
|
+
else
|
58
|
+
raise "Invalid value '#{public_ip.value}' in parameter '#{public_ip}'"
|
59
|
+
end # case
|
60
|
+
end # public ip
|
61
|
+
|
62
|
+
|
63
|
+
end # instance
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
# +++fold-off+++
|
@@ -0,0 +1,69 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Ec2Routes"></a>Ec2Routes<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates that routes in EC2 `InstanceId`
|
8
|
+
|
9
|
+
**Parameters**
|
10
|
+
|
11
|
+
* `instance = suite_value( :instance_name )` : name of instance being tested
|
12
|
+
* `test_parameter( current_test, "Routes" )` : and array of route definitions
|
13
|
+
|
14
|
+
For example: Validata that 'Instance1' in output section defines two
|
15
|
+
routes. Fist route forwards VPC traffic to 'local' gateway, and
|
16
|
+
default route forwards to internet gateway (matched using regexp).
|
17
|
+
|
18
|
+
|
19
|
+
- Ec2Routes:
|
20
|
+
Routes:
|
21
|
+
- :destination_cidr_block: 10.0.0.0/16
|
22
|
+
:gateway_id: local
|
23
|
+
:state: active
|
24
|
+
- :destination_cidr_block: "0.0.0.0/0"
|
25
|
+
:gateway_id: !ruby/regexp '/^ig.*/'
|
26
|
+
:state: active
|
27
|
+
|
28
|
+
+++close+++
|
29
|
+
|
30
|
+
=end
|
31
|
+
|
32
|
+
# +++fold-on+++
|
33
|
+
|
34
|
+
require 'spec_helper'
|
35
|
+
|
36
|
+
current_test = File.basename File.dirname __FILE__
|
37
|
+
|
38
|
+
describe current_test do
|
39
|
+
|
40
|
+
# ------------------------------------------------------------------
|
41
|
+
# test parameters
|
42
|
+
|
43
|
+
instance = suite_value( :instance_name )
|
44
|
+
routes = test_parameter( current_test, "Routes" )
|
45
|
+
|
46
|
+
# ------------------------------------------------------------------
|
47
|
+
# tests
|
48
|
+
|
49
|
+
describe route_resource_for_ec2( instance ) do
|
50
|
+
|
51
|
+
let( :implemented_routes ) { subject.subnet_routes() }
|
52
|
+
|
53
|
+
# iterate 'expacted routes'
|
54
|
+
routes.value.each_with_index do |expected_route,i|
|
55
|
+
|
56
|
+
# use to validate corresponding implemented route
|
57
|
+
it "implement route #{expected_route}" do
|
58
|
+
expect( implemented_routes[i] ).to include( expected_route )
|
59
|
+
end
|
60
|
+
|
61
|
+
end # iterate expections
|
62
|
+
|
63
|
+
|
64
|
+
end # instance
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
# +++fold-off+++
|
@@ -0,0 +1,151 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Ec2SecurityGroups"></a>Ec2SecurityGroups<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates EC2 security group ingress/egress rules. A
|
8
|
+
|
9
|
+
**Parameters**
|
10
|
+
|
11
|
+
* `instance = suite_value( :instance_name )` : name of instance being tested
|
12
|
+
* `ingress = test_parameter( current_test, "Ingress" )` : ingress on
|
13
|
+
the EC2 instance to validate
|
14
|
+
* `egress = test_parameter( current_test, "Egress" )`: egress rules on
|
15
|
+
the EC2 instance to validate
|
16
|
+
* `strictIngress = test_parameter( current_test, "StrictIngress",
|
17
|
+
false )`: validate exactly |Ingress| rules
|
18
|
+
* `strictEgress = test_parameter( current_test, "StrictEgress", false )`:
|
19
|
+
validate exactly |Egress| rules
|
20
|
+
|
21
|
+
|
22
|
+
- Ec2SecurityGroups:
|
23
|
+
StrictIngress: false
|
24
|
+
StrictEgress: false
|
25
|
+
Ingress:
|
26
|
+
# ping response only in local subnet
|
27
|
+
- :ip_protocol: icmp
|
28
|
+
:from_port: -1
|
29
|
+
:to_port: -1
|
30
|
+
:ip_ranges:
|
31
|
+
- :cidr_ip: *SubNetPrivate
|
32
|
+
Egress:
|
33
|
+
# allow ping Internet
|
34
|
+
- :ip_protocol: icmp
|
35
|
+
:from_port: -1
|
36
|
+
:to_port: -1
|
37
|
+
:ip_ranges:
|
38
|
+
- :cidr_ip: "0.0.0.0/0"
|
39
|
+
|
40
|
+
+++close+++
|
41
|
+
|
42
|
+
=end
|
43
|
+
|
44
|
+
# +++fold-on+++
|
45
|
+
|
46
|
+
require 'spec_helper'
|
47
|
+
|
48
|
+
current_test = File.basename File.dirname __FILE__
|
49
|
+
|
50
|
+
# ------------------------------------------------------------------
|
51
|
+
# Use custom matcher to loop array of rules and validate that expected
|
52
|
+
# rule is "included" to one of these rules.
|
53
|
+
|
54
|
+
RSpec::Matchers.define :define_rule do |expected|
|
55
|
+
|
56
|
+
match do |actual_rules|
|
57
|
+
|
58
|
+
result = false
|
59
|
+
|
60
|
+
actual_rules.each do |rule|
|
61
|
+
# puts "rule=#{rule} vs. #{expected}"
|
62
|
+
begin
|
63
|
+
result |= expect( rule ).to include( expected )
|
64
|
+
break if result
|
65
|
+
rescue Exception => e
|
66
|
+
# puts "Rescued #{e}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
return result
|
70
|
+
# actual % expected == 0
|
71
|
+
end
|
72
|
+
|
73
|
+
failure_message do |actual_rules|
|
74
|
+
"rule #{expected} was not included in actual rules #{actual_rules} "
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe current_test do
|
79
|
+
|
80
|
+
# ------------------------------------------------------------------
|
81
|
+
# test parameters
|
82
|
+
|
83
|
+
instance = suite_value( :instance_name )
|
84
|
+
ingress = test_parameter( current_test, "Ingress" )
|
85
|
+
egress = test_parameter( current_test, "Egress" )
|
86
|
+
strictIngress = test_parameter( current_test, "StrictIngress", false )
|
87
|
+
strictEgress = test_parameter( current_test, "StrictEgress", false )
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
# ------------------------------------------------------------------
|
92
|
+
# tests
|
93
|
+
describe security_group_resource_for_ec2( instance ) do
|
94
|
+
|
95
|
+
let( :implemented_ingress_rules ) { subject.instance_ingress_rules() }
|
96
|
+
let( :implemented_egress_rules ) { subject.instance_egress_rules() }
|
97
|
+
|
98
|
+
# ------------------------------------------------------------------
|
99
|
+
# ingresss rules
|
100
|
+
context "ingress rules" do
|
101
|
+
|
102
|
+
if strictIngress.value then
|
103
|
+
it "validate all ingress rules in test suite" do
|
104
|
+
expect( implemented_ingress_rules.length ).to eql( ingress.value.length )
|
105
|
+
end
|
106
|
+
else
|
107
|
+
it "WARNING does not validate all ingress rules in test suite" do
|
108
|
+
expect( ingress.value.length ).to eql( ingress.value.length )
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# iterate 'expacted ingress' rules
|
113
|
+
ingress && ingress.value && ingress.value.each do |expected_rule|
|
114
|
+
# use to validate corresponding implemented route
|
115
|
+
it "implement ingress rule: #{expected_rule}" do
|
116
|
+
expect( implemented_ingress_rules ).to define_rule( expected_rule )
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
# ------------------------------------------------------------------
|
123
|
+
# egress
|
124
|
+
|
125
|
+
context "egress rules" do
|
126
|
+
|
127
|
+
if strictEgress.value then
|
128
|
+
it "validates all egress rules in test suite" do
|
129
|
+
expect( implemented_egress_rules.length ).to eql( egress.value.length )
|
130
|
+
end
|
131
|
+
else
|
132
|
+
it "WARNING does not validate all egress rules in test suite" do
|
133
|
+
expect( egress.value.length ).to eql( egress.value.length )
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
# iterate 'expacted egress' rules
|
139
|
+
egress && egress.value && egress.value.each do |expected_rule|
|
140
|
+
# use to validate corresponding implemented route
|
141
|
+
it "implement egress rule: #{expected_rule}" do
|
142
|
+
expect( implemented_egress_rules ).to define_rule( expected_rule )
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end # instance
|
149
|
+
end
|
150
|
+
|
151
|
+
# +++fold-off+++
|
@@ -0,0 +1,55 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="Ec2StatusNormal"></a>Ec2StatusNormal<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validates that status of `InstanceId` EC2 status for `describe_instance_status` normal:
|
8
|
+
|
9
|
+
* defefines `:availability_zone`
|
10
|
+
* `:system_status_ok?`
|
11
|
+
* `:instance_state_running?`
|
12
|
+
|
13
|
+
**Parameters**
|
14
|
+
|
15
|
+
* `instance = suite_value( :instance_name )` : name of instance being tested
|
16
|
+
|
17
|
+
|
18
|
+
+++close+++
|
19
|
+
|
20
|
+
=end
|
21
|
+
|
22
|
+
# +++fold-on+++
|
23
|
+
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
current_test = File.basename File.dirname __FILE__
|
27
|
+
|
28
|
+
describe current_test do
|
29
|
+
|
30
|
+
# ------------------------------------------------------------------
|
31
|
+
# test parameters
|
32
|
+
|
33
|
+
instanceName = suite_value( :instance_name )
|
34
|
+
|
35
|
+
expected = [
|
36
|
+
{ :prop => :system_status_not_impaired?, :expect => true },
|
37
|
+
{ :prop => :instance_state_running?, :expect => true }
|
38
|
+
]
|
39
|
+
|
40
|
+
# ------------------------------------------------------------------
|
41
|
+
# tests
|
42
|
+
|
43
|
+
describe "instanceName '#{instanceName.value}'" do
|
44
|
+
|
45
|
+
expected.each do |prop|
|
46
|
+
describe ec2_named_resource( instanceName ) do
|
47
|
+
its( prop[:prop] ) { should eq prop[:expect] }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end # describe instanceId
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# +++fold-off+++
|
@@ -0,0 +1,36 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="NetworkCanPing"></a>NetworkCanPing<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Can ping to `test_parameter( current_test, "Destination" )`
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
require 'spec_helper'
|
15
|
+
|
16
|
+
current_test = File.basename File.dirname __FILE__
|
17
|
+
|
18
|
+
describe current_test do
|
19
|
+
|
20
|
+
# defined in test-suites.yaml
|
21
|
+
timeout = 20 # seconds
|
22
|
+
testcount = 3 # times
|
23
|
+
|
24
|
+
destination = test_parameter( current_test, "Destination" )
|
25
|
+
|
26
|
+
|
27
|
+
describe "ping #{testcount} times to '#{destination.value}', wait response within #{timeout} seconds" do
|
28
|
+
cmd = "ping #{destination.value} -W #{timeout} -c #{testcount}"
|
29
|
+
describe command( cmd ) do
|
30
|
+
its(:exit_status) { should eq 0 }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# +++fold-off+++
|
@@ -1,7 +1,21 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="ParameterTest"></a>ParameterTest<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Demonstrate a test accessing `test_parameters`
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
|
1
15
|
require 'spec_helper'
|
2
16
|
|
3
17
|
|
4
|
-
current_test =
|
18
|
+
current_test = File.basename File.dirname __FILE__
|
5
19
|
|
6
20
|
describe current_test do |ex|
|
7
21
|
|
@@ -33,3 +47,5 @@ describe current_test do |ex|
|
|
33
47
|
end # describe "Test parameters" do
|
34
48
|
|
35
49
|
end
|
50
|
+
|
51
|
+
# +++fold-off+++
|
@@ -0,0 +1,46 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="RespondsToPing"></a>RespondsToPing<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate that host `test_parameter( current_test, "Hostname" )` answers to ping
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
|
17
|
+
current_test = File.basename File.dirname __FILE__
|
18
|
+
|
19
|
+
describe current_test do
|
20
|
+
|
21
|
+
# ------------------------------------------------------------------
|
22
|
+
# test parameters
|
23
|
+
|
24
|
+
hostname = test_parameter( current_test, "Hostname" )
|
25
|
+
timeout = 20 # seconds
|
26
|
+
testcount = 3 # times
|
27
|
+
|
28
|
+
# ------------------------------------------------------------------
|
29
|
+
# tests
|
30
|
+
|
31
|
+
describe "ping '#{hostname.value}'" do
|
32
|
+
|
33
|
+
it "#reponds within #{timeout} seconds with #{testcount} test counts" do
|
34
|
+
# -W: Time to wait for a response, in seconds
|
35
|
+
# -c: Stop after sending count ECHO_REQUEST packets. With deadline
|
36
|
+
# -option, ping waits for count ECHO_REPLY packets, until the
|
37
|
+
# -timeout expires
|
38
|
+
|
39
|
+
cmd = "ping #{hostname.value} -W 20 -c 3"
|
40
|
+
# puts cmd `#{cmd}`
|
41
|
+
raise "Error in '#{cmd}' " unless $? == 0 end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
# +++fold-off+++
|
@@ -1,9 +1,23 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
+++start+++
|
4
|
+
|
5
|
+
## <a id="S3NoAccess"></a>S3NoAccess<a class='navigator' href='#top'>[top]</a>
|
6
|
+
|
7
|
+
Validate no access to S3 bucket `test_parameter( current_test, "Bucket" )`
|
8
|
+
|
9
|
+
+++close+++
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# +++fold-on+++
|
14
|
+
|
1
15
|
require 'spec_helper'
|
2
16
|
|
3
17
|
# ------------------------------------------------------------------
|
4
18
|
# config
|
5
19
|
|
6
|
-
current_test =
|
20
|
+
current_test = File.basename File.dirname __FILE__
|
7
21
|
|
8
22
|
# ------------------------------------------------------------------
|
9
23
|
# Tests
|
@@ -66,7 +80,7 @@ describe current_test do
|
|
66
80
|
|
67
81
|
end
|
68
82
|
|
83
|
+
end
|
69
84
|
|
70
85
|
|
71
|
-
|
72
|
-
end
|
86
|
+
# +++fold-off+++
|