-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (108 loc) · 4.54 KB
/
provider-test-pipeline.yml
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
name: Provider Test Pipeline
on: workflow_call
jobs:
test:
name: Run Provider setup and tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Check out code
uses: actions/checkout@v4
- name: Set up Terraform latest
uses: hashicorp/setup-terraform@v2
- name: Setup test broker
run: |
mkdir -p $HOME/solace; chmod 777 $HOME/solace
docker run -d -p 8080:8080 -p 55555:55555 --shm-size=1g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --env system_scaling_maxkafkabridgecount="10" --name=solace \
--env system_scaling_maxconnectioncount="1000" --mount type=bind,source=$HOME/solace,destination=/var/lib/solace,ro=false solace/solace-pubsub-standard:"10.9.1.115"
while ! curl -s localhost:8080 | grep aurelia ; do sleep 1 ; done
- name: Use local provider
run: |
echo "
provider_installation {
dev_overrides {
\"registry.terraform.io/solaceproducts/solacebroker\" = \"${HOME}/go/bin\"
}
direct {}
}" > ~/.terraformrc
- name: Build provider
run: |
go mod tidy
make install
ls ~/go/bin
- name: Check provider available
run: |
pushd ci/broker_vpn_q
terraform plan
popd
- name: Test provider on test broker
run: |
pushd ci/broker_vpn_q
# Create
terraform plan
terraform apply -auto-approve
sleep 1
# Modify
cat ../broker_vpn_q2/testconfig2.tf >> testconfig.tf
terraform plan
terraform apply -auto-approve
sleep 1
# Delete
terraform destroy -auto-approve
sleep 1
# import
terraform apply -auto-approve
sleep 1
rm terraform.tfstate*
terraform import solacebroker_msg_vpn.newone new
popd
- name: Test provider params from env
run: |
pushd ci/broker_vpn_test2
SOLACEBROKER_USERNAME=admin SOLACEBROKER_PASSWORD=admin terraform apply -auto-approve
SOLACEBROKER_BEARER_TOKEN=abc terraform apply -auto-approve | grep 401
popd
- name: Test broker object attributes override
run: |
pushd ci/brokertest
terraform apply -auto-approve
terraform plan | grep "No changes"
popd
- name: Test larger config
run: |
pushd ci/bigtest
terraform plan
terraform apply -auto-approve
terraform plan
terraform destroy -auto-approve
popd
- name: Test unknown provider param, proving that the solace provider can tolerate unknown provider params until later when it is defined
run: |
pushd ci/provider_dependency
terraform init # sets up the random provider, which will be used to generate a random password (which will be used but login will fail)
bash -c "terraform apply -auto-approve &> results.out" || echo "Expecting terraform apply to fail"
cat results.out | grep "401 Unauthorized"
popd
- name: Test state upgrade
run: |
pushd ci/state_upgrade
bash -c "terraform plan &> results.out" || echo "Expecting terraform plan to fail"
cat results.out | grep "Found deprecated state key 'deprecated_att"
cp terraform.tfstate terraform.tfstate.bak
sed -i '/deprecated_att/d' terraform.tfstate # remove deprecated non-null attributes from state
terraform plan | grep "3 to add"
terraform apply -auto-approve | grep "Apply complete"
# GH actions fails on following commands, need to investigate. Passes locally.
# diff terraform.tfstate terraform.tfstate.bak > diff.out
# ls -l
# cat diff.out
# grep "> \"schema_version\": 0," diff.out | wc -l | grep 3 # verify schema has been upgraded
# grep "> \"deprecated1\": null," diff.out # verify deprecated has been removed
# grep "> \"deprecated2\": null," diff.out # verify deprecated has been removed
# grep "< \"clear_percent\": 20," diff.out # verify string has been converted to number
# grep "< \"egress_enabled\": true," diff.out # verify string has been converted to bool
# terraform destroy -auto-approve
popd