Unverified Commit f823b303 authored by Konstantinos Tsakalozos's avatar Konstantinos Tsakalozos Committed by GitHub
Browse files

Better dns testing (#190)

parent 10664374
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Python 3.4.3 (/usr/bin/python3)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="kubernetes-jenkins" />
<orderEntry type="module" module-name="microk8s-addons" />
</component>
<component name="TestRunnerService">
<option name="projectConfiguration" value="py.test" />
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/../kubernetes-jenkins/.idea/kubernetes-jenkins.iml" filepath="$PROJECT_DIR$/../kubernetes-jenkins/.idea/kubernetes-jenkins.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/microk8s.iml" filepath="$PROJECT_DIR$/.idea/microk8s.iml" />
<module fileurl="file://$PROJECT_DIR$/../microk8s-addons/.idea/microk8s-addons.iml" filepath="$PROJECT_DIR$/../microk8s-addons/.idea/microk8s-addons.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../kubernetes-jenkins" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../microk8s-addons" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -6,7 +6,7 @@ metadata:
spec:
containers:
- name: busybox
image: busybox
image: busybox:1.28.4
command:
- sleep
- "3600"
......
......@@ -2,8 +2,7 @@ import pytest
import platform
from validators import (
validate_dns,
validate_dashboard,
validate_dns_dashboard,
validate_storage,
validate_ingress,
validate_gpu,
......@@ -26,21 +25,7 @@ class TestAddons(object):
yield
microk8s_reset()
def test_dns(self):
"""
Sets up DNS addon and validates it works.
"""
print("Enabling DNS")
microk8s_enable("dns")
wait_for_pod_state("", "kube-system", "running", label="k8s-app=kube-dns")
# Create a bbox
print("Validating dns")
validate_dns()
print("Disabling DNS")
microk8s_disable("dns")
def test_dashboard(self):
def test_dns_dashboard(self):
"""
Sets up dashboard and validates it works.
......@@ -51,7 +36,7 @@ class TestAddons(object):
print("Enabling dashboard")
microk8s_enable("dashboard")
print("Validating dashboard")
validate_dashboard()
validate_dns_dashboard()
print("Disabling DNS")
microk8s_disable("dns")
print("Disabling dashboard")
......
from validators import (
validate_dns,
validate_dashboard,
validate_dns_dashboard,
validate_storage,
validate_ingress,
validate_istio,
......@@ -16,22 +15,13 @@ class TestLiveAddons(object):
Validates a microk8s with all the addons enabled
"""
def test_dns(self):
def test_dns_dashboard(self):
"""
Validates DNS works.
Validates dns and dashboards work.
"""
wait_for_pod_state("", "kube-system", "running", label="k8s-app=kube-dns")
# Create a bbox
validate_dns()
def test_dashboard(self):
"""
Validates dashboards works.
"""
wait_for_pod_state("", "kube-system", "running", label="k8s-app=kube-dns")
validate_dashboard()
validate_dns_dashboard()
def test_storage(self):
"""
......
import os
import time
from validators import (
validate_dns,
validate_dashboard,
validate_dns_dashboard,
validate_storage,
validate_ingress,
validate_gpu,
......@@ -53,18 +52,12 @@ class TestUpgrade(object):
enable = microk8s_enable("dns")
wait_for_pod_state("", "kube-system", "running", label="k8s-app=kube-dns")
assert "Nothing to do for" not in enable
validate_dns()
test_matrix['dns'] = validate_dns
except:
print('Will not test dns')
try:
enable = microk8s_enable("dashboard")
assert "Nothing to do for" not in enable
validate_dashboard()
test_matrix['dashboard'] = validate_dashboard
validate_dns_dashboard()
test_matrix['dns_dashboard'] = validate_dns_dashboard
except:
print('Will not test dashboard')
print('Will not test dns-dashboard')
try:
enable = microk8s_enable("storage")
......
......@@ -14,22 +14,10 @@ from utils import (
)
def validate_dns():
"""
Validate DNS by starting a busy box and nslookuping the kubernetes default service.
"""
here = os.path.dirname(os.path.abspath(__file__))
manifest = os.path.join(here, "templates", "bbox.yaml")
kubectl("apply -f {}".format(manifest))
wait_for_pod_state("busybox", "default", "running")
output = kubectl("exec -ti busybox -- nslookup kubernetes.default.svc.cluster.local")
assert "10.152.183.1" in output
kubectl("delete -f {}".format(manifest))
def validate_dashboard():
def validate_dns_dashboard():
"""
Validate the dashboard addon by looking at the grafana URL.
Validate DNS by starting a busy box and nslookuping the kubernetes default service.
"""
wait_for_pod_state("", "kube-system", "running", label="k8s-app=influxGrafana")
cluster_info = kubectl("cluster-info")
......@@ -110,12 +98,9 @@ def validate_ingress():
attempt = 50
while attempt >= 0:
try:
resp = requests.get("http://microbot.127.0.0.1.xip.io")
if resp.status_code == 200:
break
except:
pass
resp = requests.get("http://microbot.127.0.0.1.xip.io")
if resp.status_code == 200:
break
time.sleep(2)
attempt -= 1
assert resp.status_code == 200
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment