|
|
|
|
@@ -24,6 +24,7 @@ import (
|
|
|
|
|
"net"
|
|
|
|
|
"net/http"
|
|
|
|
|
"os"
|
|
|
|
|
"path"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"sync"
|
|
|
|
|
@@ -47,7 +48,6 @@ import (
|
|
|
|
|
clientsetv1 "k8s.io/client-go/kubernetes"
|
|
|
|
|
clienttypedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
|
|
|
|
restclient "k8s.io/client-go/rest"
|
|
|
|
|
"k8s.io/kubernetes/pkg/api/testapi"
|
|
|
|
|
api "k8s.io/kubernetes/pkg/apis/core"
|
|
|
|
|
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
|
|
|
|
"k8s.io/kubernetes/pkg/master"
|
|
|
|
|
@@ -298,7 +298,7 @@ func TestObjectSizeResponses(t *testing.T) {
|
|
|
|
|
_, s, closeFn := framework.RunAMaster(nil)
|
|
|
|
|
defer closeFn()
|
|
|
|
|
|
|
|
|
|
client := clientsetv1.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}})
|
|
|
|
|
client := clientsetv1.NewForConfigOrDie(&restclient.Config{Host: s.URL})
|
|
|
|
|
|
|
|
|
|
const DeploymentMegabyteSize = 100000
|
|
|
|
|
const DeploymentTwoMegabyteSize = 1000000
|
|
|
|
|
@@ -403,7 +403,7 @@ var deploymentExtensions string = `
|
|
|
|
|
|
|
|
|
|
var deploymentApps string = `
|
|
|
|
|
{
|
|
|
|
|
"apiVersion": "apps/v1beta1",
|
|
|
|
|
"apiVersion": "apps/v1",
|
|
|
|
|
"kind": "Deployment",
|
|
|
|
|
"metadata": {
|
|
|
|
|
"name": "test-deployment2",
|
|
|
|
|
@@ -411,6 +411,11 @@ var deploymentApps string = `
|
|
|
|
|
},
|
|
|
|
|
"spec": {
|
|
|
|
|
"replicas": 1,
|
|
|
|
|
"selector": {
|
|
|
|
|
"matchLabels": {
|
|
|
|
|
"app": "nginx0"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"template": {
|
|
|
|
|
"metadata": {
|
|
|
|
|
"labels": {
|
|
|
|
|
@@ -429,19 +434,31 @@ var deploymentApps string = `
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func autoscalingPath(resource, namespace, name string) string {
|
|
|
|
|
return testapi.Autoscaling.ResourcePath(resource, namespace, name)
|
|
|
|
|
if namespace != "" {
|
|
|
|
|
namespace = path.Join("namespaces", namespace)
|
|
|
|
|
}
|
|
|
|
|
return path.Join("/apis/autoscaling/v1", namespace, resource, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func batchPath(resource, namespace, name string) string {
|
|
|
|
|
return testapi.Batch.ResourcePath(resource, namespace, name)
|
|
|
|
|
if namespace != "" {
|
|
|
|
|
namespace = path.Join("namespaces", namespace)
|
|
|
|
|
}
|
|
|
|
|
return path.Join("/apis/batch/v1", namespace, resource, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func extensionsPath(resource, namespace, name string) string {
|
|
|
|
|
return testapi.Extensions.ResourcePath(resource, namespace, name)
|
|
|
|
|
if namespace != "" {
|
|
|
|
|
namespace = path.Join("namespaces", namespace)
|
|
|
|
|
}
|
|
|
|
|
return path.Join("/apis/extensions/v1beta1", namespace, resource, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func appsPath(resource, namespace, name string) string {
|
|
|
|
|
return testapi.Apps.ResourcePath(resource, namespace, name)
|
|
|
|
|
if namespace != "" {
|
|
|
|
|
namespace = path.Join("namespaces", namespace)
|
|
|
|
|
}
|
|
|
|
|
return path.Join("/apis/apps/v1", namespace, resource, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
|
|
|
|
|
@@ -457,7 +474,7 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
|
|
|
|
|
expectedVersion string
|
|
|
|
|
}{
|
|
|
|
|
{"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""},
|
|
|
|
|
{"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, testapi.Autoscaling.GroupVersion().String()},
|
|
|
|
|
{"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, "autoscaling/v1"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, r := range requests {
|
|
|
|
|
@@ -503,14 +520,15 @@ func TestAppsGroupBackwardCompatibility(t *testing.T) {
|
|
|
|
|
}{
|
|
|
|
|
// Post to extensions endpoint and get back from both: extensions and apps
|
|
|
|
|
{"POST", extensionsPath("deployments", metav1.NamespaceDefault, ""), deploymentExtensions, integration.Code201, ""},
|
|
|
|
|
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
|
|
|
|
|
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
|
|
|
|
|
{"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
|
|
|
|
|
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"},
|
|
|
|
|
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "apps/v1"},
|
|
|
|
|
{"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"},
|
|
|
|
|
// Post to apps endpoint and get back from both: apps and extensions
|
|
|
|
|
{"POST", appsPath("deployments", metav1.NamespaceDefault, ""), deploymentApps, integration.Code201, ""},
|
|
|
|
|
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
|
|
|
|
|
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
|
|
|
|
|
{"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
|
|
|
|
|
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "apps/v1"},
|
|
|
|
|
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "extensions/v1beta1"},
|
|
|
|
|
// set propagationPolicy=Orphan to force the object to be returned so we can check the apiVersion (otherwise, we just get a status object back)
|
|
|
|
|
{"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2") + "?propagationPolicy=Orphan", "", integration.Code200, "apps/v1"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, r := range requests {
|
|
|
|
|
@@ -624,7 +642,7 @@ func TestMasterService(t *testing.T) {
|
|
|
|
|
_, s, closeFn := framework.RunAMaster(framework.NewIntegrationTestMasterConfig())
|
|
|
|
|
defer closeFn()
|
|
|
|
|
|
|
|
|
|
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}})
|
|
|
|
|
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL})
|
|
|
|
|
|
|
|
|
|
err := wait.Poll(time.Second, time.Minute, func() (bool, error) {
|
|
|
|
|
svcList, err := client.Core().Services(metav1.NamespaceDefault).List(metav1.ListOptions{})
|
|
|
|
|
@@ -666,7 +684,7 @@ func TestServiceAlloc(t *testing.T) {
|
|
|
|
|
_, s, closeFn := framework.RunAMaster(cfg)
|
|
|
|
|
defer closeFn()
|
|
|
|
|
|
|
|
|
|
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}})
|
|
|
|
|
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL})
|
|
|
|
|
|
|
|
|
|
svc := func(i int) *api.Service {
|
|
|
|
|
return &api.Service{
|
|
|
|
|
|