added integration tests for registry addon
parent
8cd38956f2
commit
de424fe8e8
|
@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
|
||||||
kind: DaemonSet
|
kind: DaemonSet
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
kubernetes.io/minikube-addons: registry
|
kubernetes.io/minikube-addons: registry-proxy
|
||||||
addonmanager.kubernetes.io/mode: Reconcile
|
addonmanager.kubernetes.io/mode: Reconcile
|
||||||
name: registry-proxy
|
name: registry-proxy
|
||||||
namespace: kube-system
|
namespace: kube-system
|
||||||
|
@ -10,6 +10,7 @@ spec:
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
|
kubernetes.io/minikube-addons: registry-proxy
|
||||||
addonmanager.kubernetes.io/mode: Reconcile
|
addonmanager.kubernetes.io/mode: Reconcile
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
|
|
|
@ -190,7 +190,57 @@ func testServicesList(t *testing.T) {
|
||||||
t.Fatalf(err.Error())
|
t.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func testRegistry(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
minikubeRunner := NewMinikubeRunner(t)
|
||||||
|
kubectlRunner := util.NewKubectlRunner(t)
|
||||||
|
minikubeRunner.RunCommand("addons enable registry", true)
|
||||||
|
t.Log("wait for registry to come up")
|
||||||
|
|
||||||
|
if err := util.WaitForDockerRegistryRunning(t); err != nil {
|
||||||
|
t.Fatalf("waiting for registry to be up: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check access from outside the cluster on port 5000, validing connectivity via registry-proxy
|
||||||
|
checkExternalAccess := func() error {
|
||||||
|
t.Log("checking registry access from outside cluster")
|
||||||
|
expectedStr := "200"
|
||||||
|
runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000")
|
||||||
|
externalCheckOutput, _ := minikubeRunner.SSH(runCmd)
|
||||||
|
if !strings.Contains(externalCheckOutput, expectedStr) {
|
||||||
|
return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := util.Retry(t, checkExternalAccess, 2*time.Second, 5); err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
// check access from inside the cluster via a busybox container running inside cluster
|
||||||
|
t.Log("checking registry access from inside cluster")
|
||||||
|
expectedStr := "200"
|
||||||
|
out, _ := kubectlRunner.RunCommand([]string{
|
||||||
|
"run",
|
||||||
|
"registry-test",
|
||||||
|
"--restart=Never",
|
||||||
|
"--image=busybox",
|
||||||
|
"-it",
|
||||||
|
"--",
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
"wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'"})
|
||||||
|
internalCheckOutput := string(out)
|
||||||
|
if !strings.Contains(internalCheckOutput, expectedStr) {
|
||||||
|
t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil {
|
||||||
|
t.Fatalf("failed to delete pod registry-test")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
minikubeRunner.RunCommand("addons disable registry", true)
|
||||||
|
}
|
||||||
func testGvisor(t *testing.T) {
|
func testGvisor(t *testing.T) {
|
||||||
minikubeRunner := NewMinikubeRunner(t)
|
minikubeRunner := NewMinikubeRunner(t)
|
||||||
minikubeRunner.RunCommand("addons enable gvisor", true)
|
minikubeRunner.RunCommand("addons enable gvisor", true)
|
||||||
|
|
|
@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) {
|
||||||
t.Run("DNS", testClusterDNS)
|
t.Run("DNS", testClusterDNS)
|
||||||
t.Run("Logs", testClusterLogs)
|
t.Run("Logs", testClusterLogs)
|
||||||
t.Run("Addons", testAddons)
|
t.Run("Addons", testAddons)
|
||||||
|
t.Run("Registry", testRegistry)
|
||||||
t.Run("Dashboard", testDashboard)
|
t.Run("Dashboard", testDashboard)
|
||||||
t.Run("ServicesList", testServicesList)
|
t.Run("ServicesList", testServicesList)
|
||||||
t.Run("Provisioning", testProvisioning)
|
t.Run("Provisioning", testProvisioning)
|
||||||
|
|
|
@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WaitForDockerRegistryRunning waits until docker registry pod to be running
|
||||||
|
func WaitForDockerRegistryRunning(t *testing.T) error {
|
||||||
|
client, err := commonutil.GetClient()
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "getting kubernetes client")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := commonutil.WaitForRCToStabilize(client, "kube-system", "registry", time.Minute*10); err != nil {
|
||||||
|
return errors.Wrap(err, "waiting for registry replicacontroller to stabilize")
|
||||||
|
}
|
||||||
|
|
||||||
|
registrySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry"}))
|
||||||
|
if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", registrySelector); err != nil {
|
||||||
|
return errors.Wrap(err, "waiting for registry pods")
|
||||||
|
}
|
||||||
|
proxySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry-proxy"}))
|
||||||
|
if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", proxySelector); err != nil {
|
||||||
|
return errors.Wrap(err, "waiting for registry-proxy pods")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running
|
// WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running
|
||||||
func WaitForIngressDefaultBackendRunning(t *testing.T) error {
|
func WaitForIngressDefaultBackendRunning(t *testing.T) error {
|
||||||
client, err := commonutil.GetClient()
|
client, err := commonutil.GetClient()
|
||||||
|
|
Loading…
Reference in New Issue