-
Notifications
You must be signed in to change notification settings - Fork 50
221 lines (186 loc) · 7.95 KB
/
full-bundle-tests.yaml
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
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Tests
on:
workflow_dispatch:
inputs:
bundle-test-path:
description: 'Test folder to run'
required: true
bundle-source:
description: 'Either `--channel <channel_name>` or `--file <bundle_file>.yaml`'
required: true
uats-branch:
description: 'The branch of `charmed-kubeflow-uats` to run, e.g. `track/1.7`'
type: string
default: 'main'
required: true
workflow_call:
inputs:
bundle-test-path:
description: 'Test folder to run'
type: string
required: true
bundle-source:
description: 'Either `--channel <channel_name>` or `--file <bundle_file>.yaml`'
type: string
required: true
uats-branch:
description: 'The branch of `charmed-kubeflow-uats` to run, e.g. `track/1.7`'
type: string
default: 'main'
required: true
jobs:
test-bundle:
runs-on: [self-hosted, linux, X64, two-xlarge]
steps:
- uses: actions/checkout@v3
- name: Parse and enable DNS server
id: dns-name
run: |
dns_server=$(grep -oPm1 'Current DNS Server: \K[^\s]+' <<< "$(resolvectl status)")
echo "Using following DNS Server: $dns_server"
echo "MY_ADDONS=hostpath-storage ingress dns:$dns_server rbac registry metallb:'10.64.140.43-10.64.140.49,192.168.0.105-192.168.0.111'" >> $GITHUB_OUTPUT
- name: Setup Python
run: |
echo "deb-src http://archive.ubuntu.com/ubuntu/ jammy main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update -yqq
sudo apt-get build-dep -yqq python3
sudo apt-get install -yqq pkg-config
sudo apt-get install -yqq build-essential gdb lcov pkg-config \
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
lzma lzma-dev tk-dev uuid-dev zlib1g-dev
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
pyenv install 3.8.16
pyenv global 3.8.16
# configure environment variables to be available in subsequent steps
echo "PYENV_ROOT=$PYENV_ROOT" >> "$GITHUB_ENV"
echo "PATH=$PATH" >> "$GITHUB_ENV"
- name: Install tools
run: |
eval "$(pyenv init -)"
pip install tox
sudo snap install charmcraft --classic
sudo snap install kubectl --classic
sudo snap install firefox
- name: Setup microk8s
run: |
sudo snap install microk8s --classic --channel=1.24/stable
sudo usermod -a -G microk8s $USER
# - name: update registry
# run: |
# sg microk8s -c "cat > /var/snap/microk8s/current/args/certs.d/docker.io/hosts.toml << EOF
# server = \"https://rocks.canonical.com\"
# [host.\"https://rocks.canonical.com\"]
# capabilities = [\"pull\", \"resolve\"]
# EOF"
#
# - run: |
# sudo cat /var/snap/microk8s/current/args/certs.d/docker.io/hosts.toml
- name: Update credentials
run: |
sg microk8s -c "cat >> /var/snap/microk8s/current/args/containerd-template.toml << EOF
[plugins.\"io.containerd.grpc.v1.cri\".registry.configs.\"registry-1.docker.io\".auth]
username = \"${{ secrets.MAKSIM_DOCKERHUB_USER }}\"
password = \"${{ secrets.MAKSIM_DOCKERHUB_PASSWORD }}\"
EOF"
- name: Restart microk8s
run: |
sg microk8s -c "microk8s stop"
sg microk8s -c "microk8s start"
sg microk8s -c "microk8s status --wait-ready --timeout 150"
- name: Enable addons
run: |
sg microk8s -c "microk8s enable ${{ steps.dns-name.outputs.MY_ADDONS }}"
- name: Wait for microk8s to be ready and give time for addons
run: |
sleep 90
sg microk8s -c "microk8s status --wait-ready --timeout 150"
sg microk8s -c "mkdir -p ~/.kube"
sg microk8s -c "microk8s config > ~/.kube/config"
- name: Install and bootstrap Juju
run: |
sudo snap install juju --classic --channel=2.9/stable
sg microk8s -c 'juju bootstrap microk8s bundle-controller --model-default test-mode=true --model-default logging-config="<root>=DEBUG" --agent-version="2.9.44" --debug --verbose'
- name: Show all pods status
run: |
sg microk8s -c "microk8s kubectl get pods --all-namespaces"
- name: Increase file system limits
run: |
sudo sysctl fs.inotify.max_user_instances=1280
sudo sysctl fs.inotify.max_user_watches=655360
- name: Configure Juju model
run: |
sg microk8s -c "juju add-model kubeflow --config default-series=focal --config automatically-retry-hooks=true"
sg microk8s -c "juju model-config"
sg microk8s -c "juju status"
- name: Configure env for Gecko driver
run: |
# required for gecko driver
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
echo "$(id -u)"
loginctl enable-linger $USER
sudo apt-get install dbus-user-session -yqq
systemctl --user start dbus.service
- name: Run bundle tests
run: |
eval "$(pyenv init -)"
export BUNDLE_TEST_PATH=${{ inputs.bundle-test-path }}
export GH_TOKEN=${{ secrets.GITHUB_TOKEN }}
sg microk8s -c "tox -e full_bundle_tests -- ${{ inputs.bundle-source }}"
- name: Checkout Kubeflow UATs
run: |
git clone https://github.com/canonical/charmed-kubeflow-uats.git ~/charmed-kubeflow-uats
cd ~/charmed-kubeflow-uats
git checkout ${{ inputs.uats-branch }}
- name: Create UAT environment configuration file
run: |
# Define the environment variables to include in the configuration file
variables=("HTTP_PROXY" "HTTPS_PROXY")
# Create the params.env file and populate it with the values of the specified variables
for var in "${variables[@]}"; do
echo "$var=$(eval echo \$$var)" >> params.env
done
- name: Run UATs
run: |
eval "$(pyenv init -)"
sg microk8s -c "tox -c ~/charmed-kubeflow-uats/ -e kubeflow -- --env params.env"
- name: Upload selenium screenshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: selenium-screenshots
path: |
sel-screenshots
**/sel-screenshots
**/**/sel-screenshots
- name: Run connectivity check
if: always()
run: |
sg microk8s -c "curl --max-time 10 --connect-timeout 10 http://10.64.140.43.nip.io"
- name: Dump Juju/k8s logs on failure
if: failure() || cancelled()
run: |
sg microk8s -c "juju status"
echo "Dumping k8s logs"
sg microk8s -c "microk8s kubectl get all --all-namespaces"
- name: Descript all pods
if: failure()
run: |
sg microk8s -c "microk8s kubectl describe pods --all-namespaces"
- name: Get logs from failed pods
if: failure() || cancelled()
run: |
POD_LIST=$(sg microk8s -c "microk8s kubectl get pods --all-namespaces -o 'custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace,CONTAINERS:.status.containerStatuses[*].ready'" | awk '$3 == "false" {print $1,$2}')
if [ -n "$POD_LIST" ]; then
echo "Actual Logs"
while read -r POD NAMESPACE; do
echo "\n\n\nPod: $POD"
sg microk8s -c "microk8s kubectl logs -n $NAMESPACE $POD"
done <<< "$POD_LIST"
fi
- name: Save debug artifacts
uses: canonical/kubeflow-ci/actions/dump-charm-debug-artifacts@main
if: always()