Skip to content

Commit dd4094d

Browse files
donotmerge: add debug logging to ingress test
1 parent a81fc16 commit dd4094d

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

.github/workflows/build-snap.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
name: Upgrade path test
5858
runs-on: ubuntu-22.04
5959
needs: build
60+
timeout-minutes: 30
6061

6162
steps:
6263
- name: Checking out repo
@@ -76,7 +77,9 @@ jobs:
7677
path: build
7778
- name: Running upgrade path test
7879
run: |
79-
sudo -E UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
80+
sudo -E UPGRADE_MICROK8S_FROM=latest/edge \
81+
UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap \
82+
pytest --log-cli-level debug -s ./tests/test-upgrade-path.py
8083
8184
test-addons-core:
8285
name: Test core addons
@@ -145,6 +148,7 @@ jobs:
145148
name: Test core addons upgrade
146149
runs-on: ubuntu-22.04
147150
needs: build
151+
timeout-minutes: 30
148152

149153
steps:
150154
- name: Checking out repo
@@ -169,7 +173,7 @@ jobs:
169173
UNDER_TIME_PRESSURE: ${{ !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}
170174
run: |
171175
set -x
172-
sudo -E bash -c "UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade.py"
176+
sudo -E bash -c "UPGRADE_MICROK8S_FROM=latest/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap --log-cli-level debug pytest -s ./tests/test-upgrade.py"
173177
174178
test-cluster-agent:
175179
name: Cluster agent health check

tests/test-upgrade.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23
import platform
34
import time
@@ -29,6 +30,9 @@
2930
under_time_pressure = os.environ.get("UNDER_TIME_PRESSURE", "false").lower()
3031

3132

33+
LOG = logging.getLogger(__name__)
34+
35+
3236
class TestUpgrade(object):
3337
"""
3438
Validates a microk8s upgrade path
@@ -39,6 +43,8 @@ def test_upgrade(self):
3943
Deploy, probe, upgrade, validate nothing broke.
4044
4145
"""
46+
LOG.setLevel(logging.DEBUG)
47+
LOG.info("Starting upgrade test")
4248
print("Testing upgrade from {} to {}".format(upgrade_from, upgrade_to))
4349
if is_ipv6_configured:
4450
print("IPv6 is configured, will test dual stack")
@@ -91,7 +97,9 @@ def test_upgrade(self):
9197
print("Will not test storage")
9298

9399
try:
100+
LOG.info("Enabing ingress")
94101
enable = microk8s_enable("ingress")
102+
LOG.info("Enabled ingress. Status: %s", enable)
95103
assert "Nothing to do for" not in enable
96104
validate_ingress()
97105
test_matrix["ingress"] = validate_ingress

tests/utils.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os.path
23
import datetime
34
import time
@@ -9,6 +10,8 @@
910

1011
arch_translate = {"aarch64": "arm64", "x86_64": "amd64"}
1112

13+
LOG = logging.getLogger(__name__)
14+
1215

1316
def get_arch():
1417
"""

tests/validators.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import time
23
import os
34
import re
@@ -17,6 +18,8 @@
1718

1819
TEMPLATES = Path(__file__).absolute().parent / "templates"
1920

21+
LOG = logging.getLogger(__name__)
22+
2023

2124
def validate_dns_dashboard():
2225
"""
@@ -89,7 +92,9 @@ def common_ingress():
8992
"""
9093
attempt = 50
9194
while attempt >= 0:
95+
LOG.info("Getting ingress")
9296
output = kubectl("get ing")
97+
LOG.info("Got ingress: %s", output)
9398
if "microbot.127.0.0.1.nip.io" in output:
9499
break
95100
time.sleep(5)
@@ -100,11 +105,14 @@ def common_ingress():
100105
attempt = 50
101106
while attempt >= 0:
102107
try:
108+
LOG.info("GET http://microbot.127.0.0.1.nip.io")
103109
resp = requests.get("http://microbot.127.0.0.1.nip.io/")
110+
LOG.info("GET http://microbot.127.0.0.1.nip.io -> %s", resp)
104111
if resp.status_code == 200 and "microbot.png" in resp.content.decode("utf-8"):
105112
service_ok = True
106113
break
107-
except requests.RequestException:
114+
except requests.RequestException as ex:
115+
LOG.info("GET http://microbot.127.0.0.1.nip.io -> %s", ex)
108116
time.sleep(5)
109117
attempt -= 1
110118

@@ -115,20 +123,31 @@ def validate_ingress():
115123
"""
116124
Validate ingress by creating a ingress rule.
117125
"""
126+
127+
LOG.info("Validating ingress")
128+
129+
LOG.info("Retrieving daemonset")
118130
daemonset = kubectl("get ds")
131+
LOG.info("Daemonset: %s\n", daemonset)
119132
if "nginx-ingress-microk8s-controller" in daemonset:
133+
LOG.info("Waiting for default-http-backend pod")
120134
wait_for_pod_state("", "default", "running", label="app=default-http-backend")
135+
LOG.info("Waiting for nginx-ingress-microk8s (default)")
121136
wait_for_pod_state("", "default", "running", label="name=nginx-ingress-microk8s")
122137
else:
138+
LOG.info("Waiting for nginx-ingress-microk8s (ingress)")
123139
wait_for_pod_state("", "ingress", "running", label="name=nginx-ingress-microk8s")
124140

125141
manifest = TEMPLATES / "ingress.yaml"
142+
LOG.info("Applying ingress")
126143
update_yaml_with_arch(manifest)
127144
kubectl("apply -f {}".format(manifest))
145+
LOG.info("Waiting for microbot")
128146
wait_for_pod_state("", "default", "running", label="app=microbot")
129147

130148
common_ingress()
131149

150+
LOG.info("Deleting ingress")
132151
kubectl("delete -f {}".format(manifest))
133152

134153

0 commit comments

Comments
 (0)