mirror of https://github.com/k3s-io/k3s
Merge pull request #72694 from liggitt/integration-api-versions
Use apps/v1 APIs in integration, explicitly enable all resources for print/etcd/scale testspull/564/head
commit
c6d0cdf309
|
@ -66,7 +66,7 @@ kube::log::status "Starting kube-apiserver"
|
|||
--etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}" \
|
||||
--advertise-address="10.10.10.10" \
|
||||
--cert-dir="${TMP_DIR}/certs" \
|
||||
--runtime-config="api/all=true" \
|
||||
--runtime-config="api/all=true,extensions/v1beta1/daemonsets=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicasets=true,extensions/v1beta1/networkpolicies=true,extensions/v1beta1/podsecuritypolicies=true,extensions/v1beta1/replicationcontrollers=true" \
|
||||
--token-auth-file="${TMP_DIR}/tokenauth.csv" \
|
||||
--logtostderr \
|
||||
--v=2 \
|
||||
|
|
|
@ -20,16 +20,17 @@ go_test(
|
|||
],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/api/testapi:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/kubectl/cmd/util:go_default_library",
|
||||
"//pkg/master:go_default_library",
|
||||
"//pkg/printers:go_default_library",
|
||||
"//pkg/printers/internalversion:go_default_library",
|
||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/apps/v1beta2:go_default_library",
|
||||
"//staging/src/k8s.io/api/auditregistration/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/batch/v2alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/rbac/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/scheduling/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
|
@ -39,17 +40,20 @@ import (
|
|||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/pager"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/master"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
func setup(t *testing.T, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||
return setupWithResources(t, groupVersions, nil)
|
||||
}
|
||||
|
||||
func setupWithResources(t *testing.T, groupVersions []schema.GroupVersion, resources []schema.GroupVersionResource) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||
if len(groupVersions) > 0 {
|
||||
if len(groupVersions) > 0 || len(resources) > 0 {
|
||||
resourceConfig := master.DefaultAPIResourceConfigSource()
|
||||
resourceConfig.EnableVersions(groupVersions...)
|
||||
resourceConfig.EnableResources(resources...)
|
||||
masterConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
|
||||
}
|
||||
_, s, closeFn := framework.RunAMaster(masterConfig)
|
||||
|
@ -82,10 +86,6 @@ func verifyStatusCode(t *testing.T, verb, URL, body string, expectedStatusCode i
|
|||
}
|
||||
}
|
||||
|
||||
func path(resource, namespace, name string) string {
|
||||
return testapi.Extensions.ResourcePath(resource, namespace, name)
|
||||
}
|
||||
|
||||
func newRS(namespace string) *apps.ReplicaSet {
|
||||
return &apps.ReplicaSet{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
|
@ -118,7 +118,7 @@ func newRS(namespace string) *apps.ReplicaSet {
|
|||
var cascDel = `
|
||||
{
|
||||
"kind": "DeleteOptions",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"orphanDependents": false
|
||||
}
|
||||
`
|
||||
|
@ -139,7 +139,7 @@ func Test202StatusCode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Failed to create rs: %v", err)
|
||||
}
|
||||
verifyStatusCode(t, "DELETE", s.URL+path("replicasets", ns.Name, rs.Name), "", 200)
|
||||
verifyStatusCode(t, "DELETE", s.URL+path.Join("/apis/apps/v1/namespaces", ns.Name, "replicasets", rs.Name), "", 200)
|
||||
|
||||
// 2. Create the resource with a finalizer so that the resource is not immediately deleted and then delete it without setting DeleteOptions.
|
||||
// Verify that the apiserver still returns 200 since DeleteOptions.OrphanDependents is not set.
|
||||
|
@ -149,7 +149,7 @@ func Test202StatusCode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Failed to create rs: %v", err)
|
||||
}
|
||||
verifyStatusCode(t, "DELETE", s.URL+path("replicasets", ns.Name, rs.Name), "", 200)
|
||||
verifyStatusCode(t, "DELETE", s.URL+path.Join("/apis/apps/v1/namespaces", ns.Name, "replicasets", rs.Name), "", 200)
|
||||
|
||||
// 3. Create the resource and then delete it with DeleteOptions.OrphanDependents=false.
|
||||
// Verify that the server still returns 200 since the resource is immediately deleted.
|
||||
|
@ -158,7 +158,7 @@ func Test202StatusCode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Failed to create rs: %v", err)
|
||||
}
|
||||
verifyStatusCode(t, "DELETE", s.URL+path("replicasets", ns.Name, rs.Name), cascDel, 200)
|
||||
verifyStatusCode(t, "DELETE", s.URL+path.Join("/apis/apps/v1/namespaces", ns.Name, "replicasets", rs.Name), cascDel, 200)
|
||||
|
||||
// 4. Create the resource with a finalizer so that the resource is not immediately deleted and then delete it with DeleteOptions.OrphanDependents=false.
|
||||
// Verify that the server returns 202 in this case.
|
||||
|
@ -168,7 +168,7 @@ func Test202StatusCode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Failed to create rs: %v", err)
|
||||
}
|
||||
verifyStatusCode(t, "DELETE", s.URL+path("replicasets", ns.Name, rs.Name), cascDel, 202)
|
||||
verifyStatusCode(t, "DELETE", s.URL+path.Join("/apis/apps/v1/namespaces", ns.Name, "replicasets", rs.Name), cascDel, 202)
|
||||
}
|
||||
|
||||
func TestAPIListChunking(t *testing.T) {
|
||||
|
|
|
@ -26,8 +26,11 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
||||
auditregv1alpha1 "k8s.io/api/auditregistration/v1alpha1"
|
||||
batchv2alpha1 "k8s.io/api/batch/v2alpha1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
|
||||
schedulerapi "k8s.io/api/scheduling/v1beta1"
|
||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
||||
|
@ -35,6 +38,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/client-go/discovery"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
@ -131,14 +135,27 @@ var missingHanlders = sets.NewString(
|
|||
)
|
||||
|
||||
func TestServerSidePrint(t *testing.T) {
|
||||
s, _, closeFn := setup(t,
|
||||
s, _, closeFn := setupWithResources(t,
|
||||
// additional groupversions needed for the test to run
|
||||
auditregv1alpha1.SchemeGroupVersion,
|
||||
batchv2alpha1.SchemeGroupVersion,
|
||||
rbacv1alpha1.SchemeGroupVersion,
|
||||
settingsv1alpha1.SchemeGroupVersion,
|
||||
schedulerapi.SchemeGroupVersion,
|
||||
storagev1alpha1.SchemeGroupVersion)
|
||||
[]schema.GroupVersion{
|
||||
auditregv1alpha1.SchemeGroupVersion,
|
||||
batchv2alpha1.SchemeGroupVersion,
|
||||
rbacv1alpha1.SchemeGroupVersion,
|
||||
settingsv1alpha1.SchemeGroupVersion,
|
||||
schedulerapi.SchemeGroupVersion,
|
||||
storagev1alpha1.SchemeGroupVersion,
|
||||
appsv1beta1.SchemeGroupVersion,
|
||||
appsv1beta2.SchemeGroupVersion,
|
||||
extensionsv1beta1.SchemeGroupVersion,
|
||||
},
|
||||
[]schema.GroupVersionResource{
|
||||
extensionsv1beta1.SchemeGroupVersion.WithResource("daemonsets"),
|
||||
extensionsv1beta1.SchemeGroupVersion.WithResource("deployments"),
|
||||
extensionsv1beta1.SchemeGroupVersion.WithResource("networkpolicies"),
|
||||
extensionsv1beta1.SchemeGroupVersion.WithResource("podsecuritypolicies"),
|
||||
extensionsv1beta1.SchemeGroupVersion.WithResource("replicasets"),
|
||||
},
|
||||
)
|
||||
defer closeFn()
|
||||
|
||||
ns := framework.CreateTestingNamespace("server-print", s, t)
|
||||
|
|
|
@ -15,6 +15,7 @@ go_test(
|
|||
"integration",
|
||||
],
|
||||
deps = [
|
||||
"//cmd/kube-apiserver/app/options:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
|
|
|
@ -35,6 +35,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
||||
)
|
||||
|
||||
// Only add kinds to this list when this a virtual resource with get and create verbs that doesn't actually
|
||||
|
@ -49,7 +50,15 @@ const testNamespace = "etcdstoragepathtestnamespace"
|
|||
// It will also fail when a type gets moved to a different location. Be very careful in this situation because
|
||||
// it essentially means that you will be break old clusters unless you create some migration path for the old data.
|
||||
func TestEtcdStoragePath(t *testing.T) {
|
||||
master := StartRealMasterOrDie(t)
|
||||
master := StartRealMasterOrDie(t, func(opts *options.ServerRunOptions) {
|
||||
// force enable all resources so we can check storage.
|
||||
// TODO: drop these once we stop allowing them to be served.
|
||||
opts.APIEnablement.RuntimeConfig["extensions/v1beta1/deployments"] = "true"
|
||||
opts.APIEnablement.RuntimeConfig["extensions/v1beta1/daemonsets"] = "true"
|
||||
opts.APIEnablement.RuntimeConfig["extensions/v1beta1/replicasets"] = "true"
|
||||
opts.APIEnablement.RuntimeConfig["extensions/v1beta1/podsecuritypolicies"] = "true"
|
||||
opts.APIEnablement.RuntimeConfig["extensions/v1beta1/networkpolicies"] = "true"
|
||||
})
|
||||
defer master.Cleanup()
|
||||
defer dumpEtcdKVOnFailure(t, master.KV)
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ import (
|
|||
)
|
||||
|
||||
// StartRealMasterOrDie starts an API master that is appropriate for use in tests that require one of every resource
|
||||
func StartRealMasterOrDie(t *testing.T) *Master {
|
||||
func StartRealMasterOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOptions)) *Master {
|
||||
certDir, err := ioutil.TempDir("", t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -79,13 +79,14 @@ func StartRealMasterOrDie(t *testing.T) *Master {
|
|||
kubeAPIServerOptions.ServiceClusterIPRange = *defaultServiceClusterIPRange
|
||||
kubeAPIServerOptions.Authorization.Modes = []string{"RBAC"}
|
||||
kubeAPIServerOptions.Admission.GenericAdmission.DisablePlugins = []string{"ServiceAccount"}
|
||||
kubeAPIServerOptions.APIEnablement.RuntimeConfig["api/all"] = "true"
|
||||
for _, f := range configFuncs {
|
||||
f(kubeAPIServerOptions)
|
||||
}
|
||||
completedOptions, err := app.Complete(kubeAPIServerOptions)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := completedOptions.APIEnablement.RuntimeConfig.Set("api/all=true"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// get etcd client before starting API server
|
||||
rawClient, kvClient, err := integration.GetEtcdClients(completedOptions.Etcd.StorageConfig.Transport)
|
||||
|
|
|
@ -52,7 +52,11 @@ func TestMain(m *testing.M) {
|
|||
}
|
||||
|
||||
func TestScaleSubresources(t *testing.T) {
|
||||
clientSet, tearDown := setup(t)
|
||||
clientSet, tearDown := setupWithOptions(t, nil, []string{
|
||||
"--runtime-config",
|
||||
// TODO(liggitt): remove these once apps/v1beta1, apps/v1beta2, and extensions/v1beta1 can no longer be served
|
||||
"api/all=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicationcontrollers=true,extensions/v1beta1/replicasets=true",
|
||||
})
|
||||
defer tearDown()
|
||||
|
||||
resourceLists, err := clientSet.Discovery().ServerResources()
|
||||
|
@ -63,6 +67,7 @@ func TestScaleSubresources(t *testing.T) {
|
|||
expectedScaleSubresources := map[schema.GroupVersionResource]schema.GroupVersionKind{
|
||||
makeGVR("", "v1", "replicationcontrollers/scale"): makeGVK("autoscaling", "v1", "Scale"),
|
||||
|
||||
// TODO(liggitt): remove these once apps/v1beta1, apps/v1beta2, and extensions/v1beta1 can no longer be served
|
||||
makeGVR("extensions", "v1beta1", "deployments/scale"): makeGVK("extensions", "v1beta1", "Scale"),
|
||||
makeGVR("extensions", "v1beta1", "replicationcontrollers/scale"): makeGVK("extensions", "v1beta1", "Scale"),
|
||||
makeGVR("extensions", "v1beta1", "replicasets/scale"): makeGVK("extensions", "v1beta1", "Scale"),
|
||||
|
@ -215,7 +220,11 @@ var (
|
|||
)
|
||||
|
||||
func setup(t *testing.T) (client kubernetes.Interface, tearDown func()) {
|
||||
result := apitesting.StartTestServerOrDie(t, nil, nil, framework.SharedEtcd())
|
||||
return setupWithOptions(t, nil, nil)
|
||||
}
|
||||
|
||||
func setupWithOptions(t *testing.T, instanceOptions *apitesting.TestServerInstanceOptions, flags []string) (client kubernetes.Interface, tearDown func()) {
|
||||
result := apitesting.StartTestServerOrDie(t, instanceOptions, flags, framework.SharedEtcd())
|
||||
|
||||
// TODO: Disable logging here until we resolve teardown issues which result in
|
||||
// massive log spam. Another path forward would be to refactor
|
||||
|
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
deps = [
|
||||
#"//pkg/api:go_default_library",
|
||||
"//pkg/controller/statefulset:go_default_library",
|
||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
@ -16,7 +16,7 @@ go_library(
|
|||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/apps/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
|
||||
|
@ -34,7 +34,7 @@ go_test(
|
|||
embed = [":go_default_library"],
|
||||
tags = ["integration"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/apps/v1beta1"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
@ -37,7 +37,7 @@ func TestSpecReplicasChange(t *testing.T) {
|
|||
|
||||
createHeadlessService(t, c, newHeadlessService(ns.Name))
|
||||
sts := newSTS("sts", ns.Name, 2)
|
||||
stss, _ := createSTSsPods(t, c, []*v1beta1.StatefulSet{sts}, []*v1.Pod{})
|
||||
stss, _ := createSTSsPods(t, c, []*appsv1.StatefulSet{sts}, []*v1.Pod{})
|
||||
sts = stss[0]
|
||||
waitSTSStable(t, c, sts)
|
||||
|
||||
|
@ -48,9 +48,9 @@ func TestSpecReplicasChange(t *testing.T) {
|
|||
|
||||
// Add a template annotation change to test STS's status does update
|
||||
// without .Spec.Replicas change
|
||||
stsClient := c.AppsV1beta1().StatefulSets(ns.Name)
|
||||
stsClient := c.AppsV1().StatefulSets(ns.Name)
|
||||
var oldGeneration int64
|
||||
newSTS := updateSTS(t, stsClient, sts.Name, func(sts *v1beta1.StatefulSet) {
|
||||
newSTS := updateSTS(t, stsClient, sts.Name, func(sts *appsv1.StatefulSet) {
|
||||
oldGeneration = sts.Generation
|
||||
sts.Spec.Template.Annotations = map[string]string{"test": "annotation"}
|
||||
})
|
||||
|
@ -64,7 +64,7 @@ func TestSpecReplicasChange(t *testing.T) {
|
|||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return *newSTS.Status.ObservedGeneration >= savedGeneration, nil
|
||||
return newSTS.Status.ObservedGeneration >= savedGeneration, nil
|
||||
}); err != nil {
|
||||
t.Fatalf("failed to verify .Status.ObservedGeneration has incremented for sts %s: %v", sts.Name, err)
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ func TestDeletingAndFailedPods(t *testing.T) {
|
|||
|
||||
labelMap := labelMap()
|
||||
sts := newSTS("sts", ns.Name, 2)
|
||||
stss, _ := createSTSsPods(t, c, []*v1beta1.StatefulSet{sts}, []*v1.Pod{})
|
||||
stss, _ := createSTSsPods(t, c, []*appsv1.StatefulSet{sts}, []*v1.Pod{})
|
||||
sts = stss[0]
|
||||
waitSTSStable(t, c, sts)
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/apps/v1beta1"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -30,10 +30,11 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
typedv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||
typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1"
|
||||
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/util/retry"
|
||||
|
||||
//svc "k8s.io/kubernetes/pkg/api/v1/service"
|
||||
"k8s.io/kubernetes/pkg/controller/statefulset"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
|
@ -51,7 +52,7 @@ type statefulsetTester struct {
|
|||
t *testing.T
|
||||
c clientset.Interface
|
||||
service *v1.Service
|
||||
statefulset *v1beta1.StatefulSet
|
||||
statefulset *appsv1.StatefulSet
|
||||
}
|
||||
|
||||
func labelMap() map[string]string {
|
||||
|
@ -80,19 +81,19 @@ func newHeadlessService(namespace string) *v1.Service {
|
|||
}
|
||||
|
||||
// newSTS returns a StatefulSet with a fake container image
|
||||
func newSTS(name, namespace string, replicas int) *v1beta1.StatefulSet {
|
||||
func newSTS(name, namespace string, replicas int) *appsv1.StatefulSet {
|
||||
replicasCopy := int32(replicas)
|
||||
return &v1beta1.StatefulSet{
|
||||
return &appsv1.StatefulSet{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "StatefulSet",
|
||||
APIVersion: "apps/v1beta1",
|
||||
APIVersion: "apps/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: namespace,
|
||||
Name: name,
|
||||
},
|
||||
Spec: v1beta1.StatefulSetSpec{
|
||||
PodManagementPolicy: v1beta1.ParallelPodManagement,
|
||||
Spec: appsv1.StatefulSetSpec{
|
||||
PodManagementPolicy: appsv1.ParallelPodManagement,
|
||||
Replicas: &replicasCopy,
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: labelMap(),
|
||||
|
@ -133,8 +134,8 @@ func newSTS(name, namespace string, replicas int) *v1beta1.StatefulSet {
|
|||
},
|
||||
},
|
||||
ServiceName: "fake-service-name",
|
||||
UpdateStrategy: v1beta1.StatefulSetUpdateStrategy{
|
||||
Type: v1beta1.RollingUpdateStatefulSetStrategyType,
|
||||
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
|
||||
Type: appsv1.RollingUpdateStatefulSetStrategyType,
|
||||
},
|
||||
VolumeClaimTemplates: []v1.PersistentVolumeClaim{
|
||||
// for volume mount "datadir"
|
||||
|
@ -204,11 +205,11 @@ func createHeadlessService(t *testing.T, clientSet clientset.Interface, headless
|
|||
}
|
||||
}
|
||||
|
||||
func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*v1beta1.StatefulSet, pods []*v1.Pod) ([]*v1beta1.StatefulSet, []*v1.Pod) {
|
||||
var createdSTSs []*v1beta1.StatefulSet
|
||||
func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*appsv1.StatefulSet, pods []*v1.Pod) ([]*appsv1.StatefulSet, []*v1.Pod) {
|
||||
var createdSTSs []*appsv1.StatefulSet
|
||||
var createdPods []*v1.Pod
|
||||
for _, sts := range stss {
|
||||
createdSTS, err := clientSet.AppsV1beta1().StatefulSets(sts.Namespace).Create(sts)
|
||||
createdSTS, err := clientSet.AppsV1().StatefulSets(sts.Namespace).Create(sts)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create sts %s: %v", sts.Name, err)
|
||||
}
|
||||
|
@ -226,15 +227,15 @@ func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*v1beta1
|
|||
}
|
||||
|
||||
// Verify .Status.Replicas is equal to .Spec.Replicas
|
||||
func waitSTSStable(t *testing.T, clientSet clientset.Interface, sts *v1beta1.StatefulSet) {
|
||||
stsClient := clientSet.AppsV1beta1().StatefulSets(sts.Namespace)
|
||||
func waitSTSStable(t *testing.T, clientSet clientset.Interface, sts *appsv1.StatefulSet) {
|
||||
stsClient := clientSet.AppsV1().StatefulSets(sts.Namespace)
|
||||
desiredGeneration := sts.Generation
|
||||
if err := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) {
|
||||
newSTS, err := stsClient.Get(sts.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return newSTS.Status.Replicas == *newSTS.Spec.Replicas && *newSTS.Status.ObservedGeneration >= desiredGeneration, nil
|
||||
return newSTS.Status.Replicas == *newSTS.Spec.Replicas && newSTS.Status.ObservedGeneration >= desiredGeneration, nil
|
||||
}); err != nil {
|
||||
t.Fatalf("failed to verify .Status.Replicas is equal to .Spec.Replicas for sts %s: %v", sts.Name, err)
|
||||
}
|
||||
|
@ -285,8 +286,8 @@ func getPods(t *testing.T, podClient typedv1.PodInterface, labelMap map[string]s
|
|||
return pods
|
||||
}
|
||||
|
||||
func updateSTS(t *testing.T, stsClient typedv1beta1.StatefulSetInterface, stsName string, updateFunc func(*v1beta1.StatefulSet)) *v1beta1.StatefulSet {
|
||||
var sts *v1beta1.StatefulSet
|
||||
func updateSTS(t *testing.T, stsClient typedappsv1.StatefulSetInterface, stsName string, updateFunc func(*appsv1.StatefulSet)) *appsv1.StatefulSet {
|
||||
var sts *appsv1.StatefulSet
|
||||
if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
|
||||
newSTS, err := stsClient.Get(stsName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
@ -302,8 +303,8 @@ func updateSTS(t *testing.T, stsClient typedv1beta1.StatefulSetInterface, stsNam
|
|||
}
|
||||
|
||||
// Update .Spec.Replicas to replicas and verify .Status.Replicas is changed accordingly
|
||||
func scaleSTS(t *testing.T, c clientset.Interface, sts *v1beta1.StatefulSet, replicas int32) {
|
||||
stsClient := c.AppsV1beta1().StatefulSets(sts.Namespace)
|
||||
func scaleSTS(t *testing.T, c clientset.Interface, sts *appsv1.StatefulSet, replicas int32) {
|
||||
stsClient := c.AppsV1().StatefulSets(sts.Namespace)
|
||||
if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
|
||||
newSTS, err := stsClient.Get(sts.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue