Merge pull request #4639 from castlemilk/registry-integration-tests
Added integration tests for registrypull/4791/head
commit
1d567eabad
|
@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
|
|||
kind: DaemonSet
|
||||
metadata:
|
||||
labels:
|
||||
kubernetes.io/minikube-addons: registry
|
||||
kubernetes.io/minikube-addons: registry-proxy
|
||||
addonmanager.kubernetes.io/mode: Reconcile
|
||||
name: registry-proxy
|
||||
namespace: kube-system
|
||||
|
@ -10,6 +10,7 @@ spec:
|
|||
template:
|
||||
metadata:
|
||||
labels:
|
||||
kubernetes.io/minikube-addons: registry-proxy
|
||||
addonmanager.kubernetes.io/mode: Reconcile
|
||||
spec:
|
||||
containers:
|
||||
|
|
|
@ -190,7 +190,74 @@ func testServicesList(t *testing.T) {
|
|||
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")
|
||||
_, out := minikubeRunner.RunDaemon("ip")
|
||||
s, err := readLineWithTimeout(out, 180*time.Second)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read minikubeIP: %v", err)
|
||||
}
|
||||
|
||||
registryEndpoint := "http://" + strings.TrimSpace(s) + ":5000"
|
||||
u, err := url.Parse(registryEndpoint)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse %q: %v", s, err)
|
||||
}
|
||||
|
||||
resp, err := retryablehttp.Get(u.String())
|
||||
if err != nil {
|
||||
t.Errorf("failed get: %v", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("%s returned status code %d, expected %d.\n", registryEndpoint, resp.StatusCode, http.StatusOK)
|
||||
}
|
||||
|
||||
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) {
|
||||
minikubeRunner := NewMinikubeRunner(t)
|
||||
minikubeRunner.RunCommand("addons enable gvisor", true)
|
||||
|
|
|
@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) {
|
|||
t.Run("DNS", testClusterDNS)
|
||||
t.Run("Logs", testClusterLogs)
|
||||
t.Run("Addons", testAddons)
|
||||
t.Run("Registry", testRegistry)
|
||||
t.Run("Dashboard", testDashboard)
|
||||
t.Run("ServicesList", testServicesList)
|
||||
t.Run("Provisioning", testProvisioning)
|
||||
|
|
|
@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error {
|
|||
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
|
||||
func WaitForIngressDefaultBackendRunning(t *testing.T) error {
|
||||
client, err := commonutil.GetClient()
|
||||
|
|
Loading…
Reference in New Issue