-
Notifications
You must be signed in to change notification settings - Fork 57
208 lines (203 loc) · 7.5 KB
/
test.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
name: ansible-test
on:
workflow_dispatch:
pull_request:
paths:
- plugins/**
- tests/**
push:
branches:
- main
paths:
- plugins/**
- tests/**
jobs:
ansible-galaxy-importer:
name: ansible-galaxy-importer
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.11"
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Build the collection
run: |
echo "> ansible-galaxy collection build --force"
ansible-galaxy collection build --force
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Test importer on generated tarball
run: |
# export GALAXY_IMPORTER_CONFIG=./galaxy-importer.cfg
# python -m pip install -r requirements.txt
echo "> python --version"
python --version
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install galaxy_importer
python${{ matrix.python-version }} -m galaxy_importer.main netscaler-adc-*.tar.gz 2>&1 | tee importer.log
if grep -Eq "ERROR:" importer.log; then
echo "ERROR: galaxy-importer failed"
echo "> grep -E "ERROR:" importer.log"
grep -E "ERROR:" importer.log
exit 1
fi
- name: Archive recent build
uses: actions/upload-artifact@v4
with:
name: collection-build
path: netscaler-adc-*.tar.gz
retention-days: 1
sanity-test:
name: Sanity test with Ansible ${{ matrix.ansible }} and Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
ansible:
- stable-2.15
- stable-2.16
python-version:
- "3.11"
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install \
https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz \
--disable-pip-version-check
- name: Run `ansible-test sanity`
run: |
echo "> pwd"
pwd
# tree . || ls -R
echo "> mkdir -p ansible_collections/netscaler/adc"
mkdir -p ansible_collections/netscaler/adc
echo "> rsync -av . ansible_collections/netscaler/adc \
--exclude ansible_collection/netscaler/adc \
--exclude .git \
--exclude .github \
--exclude .gitignore \
--exclude docs"
rsync -av . ansible_collections/netscaler/adc \
--exclude ansible_collection/netscaler/adc \
--exclude .git \
--exclude .github \
--exclude .gitignore \
--exclude docs
echo "> cd ansible_collections/netscaler/adc"
cd ansible_collections/netscaler/adc
echo "> ansible-test --version"
ansible-test --version
echo "> ansible-test sanity -v --color yes"
ansible-test sanity -v --color yes
integration-test:
name: >
Integration test with Ansible ${{ matrix.ansible }} and Python ${{ matrix.python-version }}
against NetScaler ${{ matrix.netscaler-version }}
runs-on: ubuntu-latest
strategy:
matrix:
ansible:
- stable-2.15
python-version:
- 3.11
netscaler-version:
- 13.1-49.15
- 14.1-4.42
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Start NetScaler CPX container
run: |
# docker-compose -f "docker-compose.yml" up -d
docker run -d \
--name netscaler \
-p 33443:9443 \
-p 33022:22 \
-p 33080:9080 \
-p 161/udp \
-p 33888:8888 \
--tty \
--cap-add NET_ADMIN \
--ulimit core=-1 \
--env CPX_CORES=2 \
--env EULA=yes \
quay.io/netscaler/netscaler-cpx:${{ matrix.netscaler-version }}
sleep 30
- name: export NetScaler vars to environment
run: |
bash tests/integration/generate_integration_config_yml.sh
export NS_NITRO_PORT=$(docker port netscaler 9080 | cut -d ':' -f2)
export NETSCALER_NSIP=localhost:$NS_NITRO_PORT
export NETSCALER_NITRO_PASS=$(docker exec netscaler cat /var/random_id)
export NETSCALER_NITRO_USER=nsroot
export NETSCALER_NITRO_PROTOCOL=http
export NETSCALER_VALIDATE_CERTS=false
export NETSCALER_SAVE_CONFIG=false
# save vars to github environment variables for use in next steps
echo "NS_NITRO_PORT=$NS_NITRO_PORT" >> $GITHUB_ENV
echo "NETSCALER_NSIP=$NETSCALER_NSIP" >> $GITHUB_ENV
echo "NETSCALER_NITRO_PASS=$NETSCALER_NITRO_PASS" >> $GITHUB_ENV
env
echo "end of env\n\n\n\n\n"
echo $GITHUB_ENV
- name: Run `curl` to check if netscaler is up
run: |
echo "> curl -kL http://$NETSCALER_NSIP/nitro/v1/config/nsip -u nsroot:$NETSCALER_NITRO_PASS"
curl -kL http://$NETSCALER_NSIP/nitro/v1/config/nsip -u nsroot:$NETSCALER_NITRO_PASS
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install \
https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz \
--disable-pip-version-check
- name: Run `ansible-test integration`
run: |
echo "> pwd"
pwd
# tree . || ls -R
echo "> mkdir -p ansible_collections/netscaler/adc"
mkdir -p ansible_collections/netscaler/adc
echo "> rsync -av . ansible_collections/netscaler/adc \
--exclude ansible_collection/netscaler/adc \
--exclude .git \
--exclude .github \
--exclude .gitignore \
--exclude docs"
rsync -av . ansible_collections/netscaler/adc \
--exclude ansible_collection/netscaler/adc \
--exclude .git \
--exclude .github \
--exclude .gitignore \
--exclude docs
echo "> cd ansible_collections/netscaler/adc"
cd ansible_collections/netscaler/adc
echo "> cat tests/integration/integration_config.yml || \
echo \"tests/integration/integration_config.yml is not present\""
cat tests/integration/integration_config.yml || \
echo "tests/integration/integration_config.yml is not present"
echo "> ansible-test --version"
ansible-test --version
echo "> ansible-test integration -v --color yes"
ansible-test integration netscaler/cpx/ -v --color yes
- name: Stop containers
if: always()
run: |
# docker-compose -f "docker-compose.yml" down
docker stop netscaler
docker rm netscaler