forked from cloudfoundry/cf-deployment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemantic-tests.sh
executable file
·144 lines (117 loc) · 5.25 KB
/
semantic-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
test_rename_network_and_deployment_opsfile() {
local new_network="test_network"
local new_deployment="test_deployment"
local manifest_file=$(mktemp)
bosh int cf-deployment.yml \
-o operations/rename-network-and-deployment.yml \
-v network_name=$new_network \
-v deployment_name=$new_deployment > $manifest_file
local interpolated_network_names=$(yq r $manifest_file -j | jq -r .instance_groups[].networks[].name | uniq)
local num_uniq_networks=$(echo "$interpolated_network_names" | wc -l)
if [ $num_uniq_networks != "1" ]; then
fail "rename-network-and-deployment.yml: expected to find the same network name for all instance groups"
elif [ $interpolated_network_names != $new_network ]; then
fail "rename-network-and-deployment.yml: expected network name to be changed to ${new_network}"
else
pass "rename-network-and-deployment.yml"
fi
}
test_aws_opsfile() {
local aws_doppler_port="4443"
local manifest_file=$(mktemp)
bosh int cf-deployment.yml \
-o operations/aws.yml > $manifest_file
local interpolated_doppler_ports=$( yq r $manifest_file -j | jq -r '.instance_groups[].jobs[].properties.doppler.port|numbers')
for i in $interpolated_doppler_ports; do
if [ $i != $aws_doppler_port ]; then
fail "Not all doppler ports are $aws_doppler_port"
fi
done
pass "aws.yml"
}
test_scale_to_one_az() {
local manifest_file=$(mktemp)
bosh int cf-deployment.yml \
-o operations/scale-to-one-az.yml > $manifest_file
local interpolated_instance_counts=$(yq r $manifest_file -j | jq -r .instance_groups[].instances | uniq)
local interpolated_azs=$(yq r $manifest_file -j | jq -r .instance_groups[].azs[] | uniq)
if [ "$interpolated_instance_counts" != "1" ]; then
fail "scale-to-one-az.yml: expected all instance counts to be 1"
elif [ "$interpolated_azs" != "z1" ]; then
fail "scale-to-one-az.yml: expected to find a single AZ for all instance groups"
else
pass "scale-to-one-az.yml"
fi
}
test_use_compiled_releases() {
local manifest_file=$(mktemp)
bosh int cf-deployment.yml \
-o operations/use-compiled-releases.yml > $manifest_file
set +e
missing_releases=$(yq r $manifest_file -j | jq -r .releases[].url | grep -E '(github\.com|bosh\.io)')
local non_recently_added_releases=""
for r in $missing_releases; do
git show | grep "+ url: $r" > /dev/null
local is_recently_added=$?
if [[ $is_recently_added -ne 0 ]]; then
non_recently_added_releases="$non_recently_added_releases $r"
fi
done
set -e
if [ -z "$non_recently_added_releases" ]; then
pass "use-compiled-releases.yml"
else
fail "use-compiled-releases.yml: the following releases were not compiled releases and use a github.com or bosh.io url: $non_recently_added_releases."
fi
}
test_disable_consul() {
local manifest_file=$(mktemp)
bosh int cf-deployment.yml \
-o operations/experimental/disable-consul.yml > $manifest_file
set +e
yq r $manifest_file -j | jq -r .instance_groups[].jobs[].name | grep 'consul_agent' > /dev/null
local has_consul_agent=$?
set -e
if [[ $has_consul_agent -eq 0 ]]; then
fail "experimental/disable-consul.yml: expected to find no 'consul_agent' jobs"
else
pass "experimental/disable-consul.yml"
fi
}
test_use_trusted_ca_cert_for_apps_includes_diego_instance_ca() {
local trusted_app_cas=$(bosh int cf-deployment.yml -o operations/use-trusted-ca-cert-for-apps.yml --path /instance_groups/name=diego-cell/jobs/name=cflinuxfs2-rootfs-setup/properties/cflinuxfs2-rootfs/trusted_certs)
if [[ $trusted_app_cas != $'((application_ca.certificate))\n((trusted_cert_for_apps.ca))' ]]; then
fail "experimental/use-trusted-ca-cert-for-apps.yml [ $trusted_app_cas ] doesn't include diego_instance_identity_ca from cf-deployment.yml"
else
pass "experimental/use-trusted-ca-cert-for-apps.yml"
fi
}
test_add_persistent_isolation_segment_diego_cell() {
local diego_cell_rep_properties=$(bosh int cf-deployment.yml --path /instance_groups/name=diego-cell/jobs/name=rep/properties)
local iso_seg_diego_cell_rep_properties=$(bosh int cf-deployment.yml -o operations/test/add-persistent-isolation-segment-diego-cell.yml \
--path /instance_groups/name=isolated-diego-cell/jobs/name=rep/properties | grep -v placement_tags | grep -v persistent_isolation_segment)
set +e
diff <(echo "$diego_cell_rep_properties") <(echo "$iso_seg_diego_cell_rep_properties")
local rep_diff_exit_code=$?
set -e
if [[ $rep_diff_exit_code != 0 ]]; then
fail "rep properties on diego-cell have diverged between cf-deployment.yml and test/add-persistent-isolation-segment-diego-cell.yml"
else
pass "test/add-persistent-isolation-segment-diego-cell.yml is consistent with cf-deployment.yml"
fi
}
semantic_tests() {
# padded for pretty output
suite_name="semantic "
pushd ${home} > /dev/null
test_rename_network_and_deployment_opsfile
test_aws_opsfile
test_scale_to_one_az
test_use_compiled_releases
test_disable_consul
test_use_trusted_ca_cert_for_apps_includes_diego_instance_ca
test_add_persistent_isolation_segment_diego_cell
popd > /dev/null
exit $exit_code
}