Removing some references to v1beta1 from test code

This commit is contained in:
nikhiljindal 2015-04-08 16:28:28 -07:00
parent c4cbc9bc46
commit 08d9e244f7
7 changed files with 49 additions and 45 deletions

View File

@ -127,7 +127,7 @@ APISERVER_PID=$!
# Wait for kube-apiserver to come up before launching the rest of the components.
echo "Waiting for apiserver to come up"
kube::util::wait_for_url "http://${API_HOST}:${API_PORT}/api/v1beta1/pods" "apiserver: " 1 10 || exit 1
kube::util::wait_for_url "http://${API_HOST}:${API_PORT}/api/v1beta3/pods" "apiserver: " 1 10 || exit 1
CTLRMGR_LOG=/tmp/kube-controller-manager.log
sudo -E "${GO_OUT}/kube-controller-manager" \

View File

@ -40,13 +40,13 @@ func TestGetReference(t *testing.T) {
Name: "foo",
UID: "bar",
ResourceVersion: "42",
SelfLink: "/api/v1beta1/pods/foo",
SelfLink: "/api/version1/pods/foo",
},
},
fieldPath: ".desiredState.containers[0]",
ref: &ObjectReference{
Kind: "Pod",
APIVersion: "v1beta1",
APIVersion: "version1",
Name: "foo",
UID: "bar",
ResourceVersion: "42",
@ -57,12 +57,12 @@ func TestGetReference(t *testing.T) {
obj: &ServiceList{
ListMeta: ListMeta{
ResourceVersion: "42",
SelfLink: "/api/v1beta2/services",
SelfLink: "/api/version2/services",
},
},
ref: &ObjectReference{
Kind: "ServiceList",
APIVersion: "v1beta2",
APIVersion: "version2",
ResourceVersion: "42",
},
},
@ -70,7 +70,7 @@ func TestGetReference(t *testing.T) {
obj: &ServiceList{
ListMeta: ListMeta{
ResourceVersion: "42",
SelfLink: "v1beta2/services",
SelfLink: "version2/services",
},
},
shouldErr: true,

View File

@ -59,7 +59,7 @@ func (t *testEventSink) Update(e *api.Event) (*api.Event, error) {
func TestEventf(t *testing.T) {
testPod := &api.Pod{
ObjectMeta: api.ObjectMeta{
SelfLink: "/api/v1beta1/pods/foo",
SelfLink: "/api/version/pods/foo",
Name: "foo",
Namespace: "baz",
UID: "bar",
@ -67,13 +67,12 @@ func TestEventf(t *testing.T) {
}
testPod2 := &api.Pod{
ObjectMeta: api.ObjectMeta{
SelfLink: "/api/v1beta1/pods/foo",
SelfLink: "/api/version/pods/foo",
Name: "foo",
Namespace: "baz",
UID: "differentUid",
},
}
testRef, err := api.GetPartialReference(testPod, "desiredState.manifest.containers[2]")
testRef2, err := api.GetPartialReference(testPod2, "desiredState.manifest.containers[3]")
if err != nil {
@ -103,7 +102,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1beta1",
APIVersion: "version",
FieldPath: "desiredState.manifest.containers[2]",
},
Reason: "Started",
@ -111,7 +110,7 @@ func TestEventf(t *testing.T) {
Source: api.EventSource{Component: "eventTest"},
Count: 1,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
{
@ -129,14 +128,14 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1beta1",
APIVersion: "version",
},
Reason: "Killed",
Message: "some other verbose message: 1",
Source: api.EventSource{Component: "eventTest"},
Count: 1,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:""}): reason: 'Killed' some other verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): reason: 'Killed' some other verbose message: 1`,
expectUpdate: false,
},
{
@ -154,7 +153,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1beta1",
APIVersion: "version",
FieldPath: "desiredState.manifest.containers[2]",
},
Reason: "Started",
@ -162,7 +161,7 @@ func TestEventf(t *testing.T) {
Source: api.EventSource{Component: "eventTest"},
Count: 2,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
expectUpdate: true,
},
{
@ -180,7 +179,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1beta1",
APIVersion: "version",
FieldPath: "desiredState.manifest.containers[3]",
},
Reason: "Started",
@ -188,7 +187,7 @@ func TestEventf(t *testing.T) {
Source: api.EventSource{Component: "eventTest"},
Count: 1,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[3]"}): reason: 'Started' some verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[3]"}): reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
{
@ -206,7 +205,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1beta1",
APIVersion: "version",
FieldPath: "desiredState.manifest.containers[2]",
},
Reason: "Started",
@ -214,7 +213,7 @@ func TestEventf(t *testing.T) {
Source: api.EventSource{Component: "eventTest"},
Count: 3,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`,
expectUpdate: true,
},
{
@ -232,7 +231,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1beta1",
APIVersion: "version",
FieldPath: "desiredState.manifest.containers[3]",
},
Reason: "Stopped",
@ -240,7 +239,7 @@ func TestEventf(t *testing.T) {
Source: api.EventSource{Component: "eventTest"},
Count: 1,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[3]"}): reason: 'Stopped' some verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[3]"}): reason: 'Stopped' some verbose message: 1`,
expectUpdate: false,
},
{
@ -258,7 +257,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1beta1",
APIVersion: "version",
FieldPath: "desiredState.manifest.containers[3]",
},
Reason: "Stopped",
@ -266,7 +265,7 @@ func TestEventf(t *testing.T) {
Source: api.EventSource{Component: "eventTest"},
Count: 2,
},
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[3]"}): reason: 'Stopped' some verbose message: 1`,
expectLog: `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[3]"}): reason: 'Stopped' some verbose message: 1`,
expectUpdate: true,
},
}
@ -350,7 +349,7 @@ func TestWriteEventError(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1beta1",
APIVersion: "version",
}
type entry struct {
timesToSendError int
@ -455,7 +454,7 @@ func TestLotsOfEvents(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1beta1",
APIVersion: "version",
}
for i := 0; i < maxQueuedEvents; i++ {
go recorder.Eventf(ref, "Reason", strconv.Itoa(i))

View File

@ -34,7 +34,7 @@ func TestAddOrUpdateEventNoExisting(t *testing.T) {
Name: "awesome.name",
Namespace: "betterNamespace",
UID: "C934D34AFB20242",
APIVersion: "v1beta1",
APIVersion: "version",
},
Source: api.EventSource{
Component: "kubelet",
@ -148,7 +148,7 @@ func TestGetEventExisting(t *testing.T) {
Name: "clever.name.here",
Namespace: "spaceOfName",
UID: "D933D32AFB2A238",
APIVersion: "v1beta1",
APIVersion: "version",
},
Source: api.EventSource{
Component: "kubelet",

View File

@ -25,8 +25,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
var apiVersionToUse = "v1beta1"
const kubectlAnnotationPrefix = "kubectl.kubernetes.io/"
type NamespaceInfo struct {

View File

@ -47,8 +47,8 @@ var codec runtime.Codec
func init() {
scheme = runtime.NewScheme()
scheme.AddKnownTypes("", &TestResource{})
scheme.AddKnownTypes("v1beta1", &TestResource{})
codec = runtime.CodecFor(scheme, "v1beta1")
scheme.AddKnownTypes(testapi.Version(), &TestResource{})
codec = runtime.CodecFor(scheme, testapi.Version())
scheme.AddConversionFuncs(
func(in *TestResource, out *TestResource, s conversion.Scope) error {
*out = *in
@ -69,6 +69,14 @@ func TestIsEtcdNotFound(t *testing.T) {
try(fmt.Errorf("some other kind of error"), false)
}
// Returns an encoded version of api.Pod with the given name.
func getEncodedPod(name string) string {
pod, _ := testapi.Codec().Encode(&api.Pod{
ObjectMeta: api.ObjectMeta{Name: name},
})
return string(pod)
}
func TestExtractToList(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
fakeClient.Data["/some/key"] = EtcdResponseWithError{
@ -79,19 +87,19 @@ func TestExtractToList(t *testing.T) {
Nodes: []*etcd.Node{
{
Key: "/foo",
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("foo"),
Dir: false,
ModifiedIndex: 1,
},
{
Key: "/bar",
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("bar"),
Dir: false,
ModifiedIndex: 2,
},
{
Key: "/baz",
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("baz"),
Dir: false,
ModifiedIndex: 3,
},
@ -153,13 +161,13 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
Nodes: []*etcd.Node{
{
Key: "/foo",
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("foo"),
Dir: false,
ModifiedIndex: 1,
},
{
Key: "/baz",
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("baz"),
Dir: false,
ModifiedIndex: 1,
},
@ -172,7 +180,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
Nodes: []*etcd.Node{
{
Key: "/bar",
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("bar"),
ModifiedIndex: 2,
},
},
@ -230,17 +238,17 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
Nodes: []*etcd.Node{
{
Key: "/foo",
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("foo"),
ModifiedIndex: 1,
},
{
Key: "/bar",
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("bar"),
ModifiedIndex: 2,
},
{
Key: "/baz",
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
Value: getEncodedPod("baz"),
ModifiedIndex: 3,
},
{

View File

@ -22,8 +22,7 @@ import (
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
@ -37,17 +36,17 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
{
watch.Added,
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
v1beta1.Codec,
testapi.Codec(),
},
{
watch.Modified,
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
v1beta2.Codec,
testapi.Codec(),
},
{
watch.Deleted,
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
api.Codec,
testapi.Codec(),
},
}
for i, testCase := range testCases {